Manager

The Manager is the high-level entry point for most users. It wraps an authenticated ApiClient and offers helper methods that reduce boilerplate when running avatarizations.

Why use the Manager?

  • Single place to authenticate.

  • Shortcuts to create a Runner and load YAML configs.

  • Convenience helpers to inspect recent jobs / results.

Quick example

Using username/password authentication:

from avatars import Manager
manager = Manager(base_url="https://your.instance/api")
manager.authenticate(username="user", password="pass")
runner = manager.create_runner(set_name="demo")
runner.add_table("wbcd", "fixtures/wbcd.csv")
runner.set_parameters("wbcd", k=15)
runner.run()

Using API key authentication:

from avatars import Manager
# No need to call authenticate() when using an API key
manager = Manager(base_url="https://your.instance/api", api_key="your-api-key")
runner = manager.create_runner(set_name="demo")
runner.add_table("wbcd", "fixtures/wbcd.csv")
runner.set_parameters("wbcd", k=15)
runner.run()

Note

When using API key authentication, do not call authenticate(). The API key is set during initialization and is immediately active.

Detailed reference

class avatars.manager.Manager(base_url: str | None = None, *, api_client: ApiClient | None = None, api_key: str | None = None, config: ClientConfig | None = None)[source]

Bases: object

High-level convenience facade for interacting with the Avatar API.

The Manager wraps an authenticated avatars.client.ApiClient instance and exposes a small, task‑oriented surface area so end users can:

  • authenticate once (authenticate) or use API key authentication

  • spin up a avatars.runner.Runner (create_runner / create_runner_from_yaml)

  • quickly inspect recent jobs & results (get_last_jobs / get_last_results)

  • perform simple platform health checks (get_health)

  • handle password reset flows (forgotten_password / reset_password)

It deliberately hides the lower-level resource clients (jobs, results, datasets …) unless you access the underlying auth_client directly. This keeps common workflows succinct while preserving an escape hatch for advanced usage. The Runner objects created through the manager inherit the authenticated context, so you rarely have to pass tokens or low-level clients around manually.

auth_client

The underlying avatars.client.ApiClient used to perform all HTTP requests.

authenticate(username: str, password: str, should_verify_compatibility: bool | None = None) None[source]

Authenticate the user with the given username and password.

Note: This method should not be called if the Manager was initialized with an api_key. API key authentication is already active and doesn’t require calling authenticate().

forgotten_password(email: str) None[source]

Send a forgotten password email to the user.

reset_password(email: str, new_password: str, new_password_repeated: str, token: str | UUID) None[source]

Reset the password of the user.

create_runner(set_name: str, seed: int | None = None, max_distribution_plots: int | None = None) Runner[source]

Create a new runner.

get_last_results(count: int = 1) list[dict[str, str]][source]

Get the last n results.

get_last_jobs(count: int = 1) dict[str, JobWithDisplayNameResponse][source]

Get the last n results.

get_health() dict[str, str][source]

Get the health of the server.

create_runner_from_yaml(yaml_path: str, set_name: str) Runner[source]

Create a new runner from a yaml file. :param yaml_path: :type yaml_path: The path to the yaml file. :param set_name: :type set_name: Name of the set of resources.