afnio.tellurio
afnio.tellurio.configure_logging(verbosity='info')
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:
| Name | Type | Description | Default |
|---|---|---|---|
verbosity
|
str
|
Logging level as a string ( |
'info'
|
Source code in afnio/logging_config.py
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | |
afnio.tellurio.suppress_variable_notifications()
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.
Source code in afnio/tellurio/_variable_registry.py
266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 | |
afnio.tellurio.init(namespace_slug, project_display_name, name=None, description=None, status=RunStatus.RUNNING, client=None)
Initializes a new Tellurio Run.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
namespace_slug
|
str
|
The namespace slug where the project resides. It can be either an organization slug or a user slug. |
required |
project_display_name
|
str
|
The display name of the project. This will be used to retrive or create the project through its slugified version. |
required |
name
|
str | None
|
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"). |
None
|
description
|
str | None
|
A description of the run. |
None
|
status
|
RunStatus | None
|
The status of the run (default: "RUNNING"). |
RUNNING
|
client
|
TellurioClient | None
|
An instance of TellurioClient. If not provided, the default client will be used. |
None
|
Returns:
| Type | Description |
|---|---|
Run
|
A Run object representing the created run. |
Raises:
| Type | Description |
|---|---|
Exception
|
If there is an error during the API requests to create the run or
retrieve/create the |
Source code in afnio/tellurio/run.py
252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 | |
afnio.tellurio.login(api_key=None, relogin=False)
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:
| Name | Type | Description | Default |
|---|---|---|---|
api_key
|
str
|
The user's API key. If not provided, the function will
attempt to use the |
None
|
relogin
|
If |
False
|
Returns:
| Type | Description |
|---|---|
dict
|
A dictionary containing the user's email, username, and session ID for the WebSocket connection. Example:
|
Raises:
| Type | Description |
|---|---|
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.
Source code in afnio/tellurio/__init__.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | |
afnio.tellurio.log(name, value, step=None, client=None)
Log a metric to the active Run.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name of the metric. |
required |
value
|
Any
|
Value of the metric. Can be any type that is JSON serializable. |
required |
step
|
int | None
|
Step number. If not provided, the backend will auto-compute it. |
None
|
client
|
TellurioClient | None
|
The client to use for the request. |
None
|
Source code in afnio/tellurio/__init__.py
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | |