afnio.tellurio#

Functions

log(name, value[, step, client])

Log a metric to the active run.

login([api_key, relogin])

Logs in the user and establishes both HTTP and WebSocket connections to the Tellurio Studio backend.

afnio.tellurio.configure_logging(verbosity='info')[source]#

Configure logging for the afnio library.

Sets up logging format and levels for CLI, scripts, and Jupyter notebooks. In a notebook, adds a custom handler for INFO-level logs to display user-facing messages with color and formatting.

Parameters:

verbosity (str) – Logging level as a string (“info”, “debug”, etc.).

afnio.tellurio.init(namespace_slug, project_display_name, name=None, description=None, status=RunStatus.RUNNING, client=None)[source]#

Initializes a new Tellurio Run.

Parameters:
  • namespace_slug (str) – The namespace slug where the project resides. It can be either an organization slug or a user slug.

  • project_display_name (str) – The display name of the project. This will be used to retrive or create the project through its slugified version.

  • name (str, optional) – The name of the run. If not provided, a random name is generated (e.g., “brave_pasta_123”). If the name is provided but already exists, an incremental number is appended to the name (e.g., “test_run_1”, “test_run_2”).

  • description (str, optional) – A description of the run.

  • status (str) – The status of the run (default: “RUNNING”).

  • client (TellurioClient, optional) – An instance of TellurioClient. If not provided, the default client will be used.

Returns:

A Run object representing the created run.

Return type:

Run

afnio.tellurio.log(name, value, step=None, client=None)[source]#

Log a metric to the active run.

Parameters:
  • name (str) – Name of the metric.

  • value (Any) – Value of the metric. Can be any type that is JSON serializable.

  • step (int, optional) – Step number. If not provided, the backend will auto-compute it.

  • client (TellurioClient, optional) – The client to use for the request.

afnio.tellurio.login(api_key=None, relogin=False)[source]#

Logs in the user and establishes both HTTP and WebSocket connections to the Tellurio Studio backend.

This function authenticates the user using an API key, which can be provided directly, via the TELLURIO_API_KEY environment variable, or retrieved from the local keyring. On successful authentication, it establishes a WebSocket connection for real-time communication and stores the API key securely for future use.

Parameters:
  • api_key (str, optional) – The user’s API key. If not provided, the function will attempt to use the TELLURIO_API_KEY environment variable. If that is not set, it will look for a stored API key in the local keyring.

  • relogin (bool) – If True, forces a re-login and requires the user to provide a new API key (either directly or via the environment variable).

Returns:

A dictionary containing the user’s email, username, and session ID for the WebSocket connection. Example:

{

“email”: “user@example.com”, “username”: “user123”, “session_id”: “abc123xyz”

}

Return type:

dict

Raises:
  • ValueError – If the API key is not provided during first login or re-login.

  • InvalidAPIKeyError – If the backend rejects the API key.

  • RuntimeError – If the WebSocket connection fails.

  • Exception – For any other unexpected errors during login.

Notes

  • On first login, the API key is stored securely in the local keyring for

    future use.

  • If relogin is True, a new API key must be provided (directly or via

    environment variable).

  • This function is synchronous and can be called from both scripts and

    interactive environments.

afnio.tellurio.suppress_variable_notifications()[source]#

Context manager to temporarily suppress variable change notifications.

When this context manager is active, any attribute changes to afnio.Variable instances will not trigger _on_variable_change notifications. This is useful for internal/client-initiated updates where you do not want to broadcast changes back to the server.

Modules