UpdateEventOption#
- class teamworksams.import_option.UpdateEventOption(interactive_mode: bool = True, cache: bool = True, id_col: str = 'user_id', table_fields: List[str] | None = None, require_confirmation: bool = True)[source]#
Bases:
object
Options for configuring the update_event_data function.
Customizes the behavior of
update_event_data()
, controlling user identifier mapping, confirmation prompts, caching, interactive feedback, and table fields. Ensures safe and efficient updates of existing events in an AMS Event Form. See Importing Data for update workflows.- Parameters:
interactive_mode (bool) – If True, prints status messages (e.g., “Updated 2 events”) and
tqdm
progress bars, and prompts for confirmation ifrequire_confirmation
is True. Set to False for silent execution. Defaults to True.cache (bool) – If True, reuses an existing
AMSClient
viaget_client()
, reducing API calls for multi-function workflows. Set to False for independent sessions. Defaults to True.id_col (str) – Column name in the input
pandas.DataFrame
for user identifiers. Must be one of ‘user_id’, ‘about’, ‘username’, or ‘email’. Used to map identifiers to AMS user IDs. Defaults to ‘user_id’.table_fields (Optional[List[str]]) – List of table field names in the AMS form (e.g., [‘session_details’]). Must match DataFrame columns if specified. If None, assumes no table fields. Defaults to None.
require_confirmation (bool) – If True, prompts for user confirmation before updating events when
interactive_mode
is True, preventing accidental changes. Set to False to skip prompts. Defaults to True.
- interactive_mode#
Boolean indicating if interactive feedback is enabled.
- cache#
Boolean indicating if caching is enabled.
- id_col#
The column name used for mapping user identifiers.
- table_fields#
List of table field names, or an empty list if None.
- Raises:
ValueError – If id_col is not one of the allowed values.
Examples
>>> from teamworksams import UpdateEventOption, update_event_data >>> import pandas as pd >>> df = pd.DataFrame({ ... "event_id": [67890], ... "username": ["john.doe"], ... "duration": [65] ... }) >>> option = UpdateEventOption(id_col = "username", interactive_mode = True) >>> update_event_data( ... df = df, ... form = "Training Log", ... url = "https://example.smartabase.com/site", ... option = option ... ) ℹ Updating 1 events for 'Training Log'... Are you sure you want to update 1 existing events in 'Training Log'? (y/n): y ✔ Processed 1 events for 'Training Log'
Additional Notes#
Set
require_confirmation=True
to prompt for confirmation before updating events wheninteractive_mode=True
, preventing accidental changes.The
id_col
must be one of ‘user_id’, ‘about’, ‘username’, or ‘email’ and present in the inputpandas.DataFrame
to map user identifiers.Use
table_fields
to update table fields, ensuring DataFrame columns align with the AMS form to avoid errors.
See Also#
update_event_data(): Function using
UpdateEventOption
.Importing Data: Event update workflows.