UpsertProfileOption#

class teamworksams.import_option.UpsertProfileOption(interactive_mode: bool = True, cache: bool = True, id_col: str = 'user_id')[source]#

Bases: object

Options for configuring the upsert_profile_data function.

Customizes the behavior of upsert_profile_data(), controlling user identifier mapping, caching, and interactive feedback. Ensures efficient upserting of profile records in an AMS Profile Form, with one record per user.

Parameters:
  • interactive_mode (bool) – If True, prints status messages (e.g., “Upserted 2 profiles”) and tqdm progress bars during execution, ideal for interactive environments like Jupyter notebooks. Set to False for silent execution. Defaults to True.

  • cache (bool) – If True, reuses an existing AMSClient via get_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’.

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.

Raises:

ValueError – If id_col is not one of the allowed values.

Examples

>>> from teamworksams import UpsertProfileOption, upsert_profile_data
>>> import pandas as pd
>>> df = pd.DataFrame({
...     "username": ["john.doe"],
...     "athlete_id": [8194028]
... })
>>> option = UpsertProfileOption(id_col="username", interactive_mode=True)
>>> upsert_profile_data(
...     df = df,
...     form = "Athlete Profile",
...     url = "https://example.smartabase.com/site",
...     option = option
... )
ℹ Upserting 1 profile records for 'Athlete Profile'
✔ Processed 1 profile records for 'Athlete Profile'
__init__(interactive_mode: bool = True, cache: bool = True, id_col: str = 'user_id')[source]#

Additional Notes#

  • The id_col must be one of ‘user_id’, ‘about’, ‘username’, or ‘email’ and present in the input pandas.DataFrame to map user identifiers; invalid columns raise ValueError.

  • Enable interactive_mode=True for feedback like “Upserted 2 profiles,” useful in interactive environments.

  • Use cache=True to reduce API calls when upserting multiple profiles, improving performance.

See Also#