embedl_hub.tracking package#

Public API for the Embedl Hub tracking package.

Top-level re-exports#

  • Client — Tracking client for projects and runs.

  • RunType — Built-in run-type categories.

class embedl_hub.tracking.Client(api_config: ApiConfig | None = None, *, log_remote_artifacts: bool = True)[source]#

Bases: object

Tracks projects and runs for the Embedl Hub web app.

property active_run: Run#
property api_config: ApiConfig#

Get or create the API config from environment variables.

create_run(type: RunType | str, name: str | None = None, parent_run_id: str | None = None, custom_type: str | None = None) Run[source]#

Create a new run for the current project.

property current_run_log: RunLog | None#

Get the current in-progress RunLog, or None if no run is active.

get_devices() list[Device][source]#

Get the list of supported devices in the Embedl device cloud.

property latest_run_log: RunLog | None#

Get the most recent completed RunLog, or None if no runs have completed.

log_artifact(file_path: Path | str | LoggedArtifact, name: str | None = None, file_name: str | None = None, run_id: str | None = None, *, ctx: HubContext | None = None, device_name: str | None = None, save_to_run_log: bool = True) LoggedArtifact[source]#

Log an artifact file for a run and upload it to artifact storage.

Accepts a local path, a remote path, or an existing LoggedArtifact. Remote artifacts are fetched from the device and uploaded to the Hub when log_remote_artifacts is True (the default). Set it to False to skip remote uploads and speed up execution.

If no name is given, the artifact is logged as unnamed. If no file_name is given, the name from the file path is used. If no run_id is given, the current active run is used.

Parameters:
  • file_path – Local file path, remote path, or a LoggedArtifact.

  • name – Optional artifact name.

  • file_name – Optional file name override.

  • run_id – Optional run ID (defaults to the active run).

  • ctx – Hub context, required when file_path is remote or a LoggedArtifact.

  • device_name – Name of the device that owns the remote artifact. Required for remote paths; ignored for LoggedArtifact (uses its own device info).

  • save_to_run_log – Whether to also record the artifact in the current RunLog.

Returns:

The LoggedArtifact that was recorded.

Raises:
  • RuntimeError – If a remote artifact is received without a ctx, or a remote path is received without device_name.

  • FileTooLargeError – If the file exceeds the maximum allowed upload size.

  • StorageQuotaExceededError – If the storage quota has been exceeded.

  • ArtifactUploadError – If the file upload fails.

log_batch(*, metrics: list[tuple[str, float, int | None]] | None = None, params: list[tuple[str, str]] | None = None, external_links: list[tuple[str, str]] | None = None, save_to_run_log: bool = True) None[source]#

Log multiple metrics and params in a single API call.

This is significantly more efficient than calling log_metric() and log_param() in a loop, as it sends all data in one PATCH request instead of one POST per item.

Parameters:
  • metrics – List of (name, value, step) tuples. step may be None for metrics without a step.

  • params – List of (name, value) tuples.

  • external_links – List of (label, url) tuples.

  • save_to_run_log – Whether to also record entries in the current RunLog. Defaults to True.

Log an external link for the current run.

log_metric(name: str, value: float, step: int | None = None, *, save_to_run_log: bool = True) LoggedMetric[source]#

Log a metric for the current run.

Parameters:
  • name – The metric name.

  • value – The metric value.

  • step – Optional step number.

  • save_to_run_log – Whether to also record this entry in the current RunLog. Defaults to True.

Returns:

The LoggedMetric that was recorded.

log_param(name: str, value: str, *, save_to_run_log: bool = True) LoggedParam[source]#

Log a parameter for the current run.

Parameters:
  • name – The parameter name.

  • value – The parameter value.

  • save_to_run_log – Whether to also record this entry in the current RunLog. Defaults to True.

Returns:

The LoggedParam that was recorded.

property log_remote_artifacts: bool#

Whether remote artifacts are fetched and uploaded to the Hub.

When True (the default), calling log_artifact() with a remote path or a remote LoggedArtifact will download the file from the device and upload it to the Embedl Hub.

Set to False to skip the download-and-upload step and speed up execution. The artifact is still recorded in the run log, but its contents are not transferred.

log_tag(name: str, value: str) Tag[source]#

Log a tag for the current run.

property project: Project#
property run_history: RunLogHistory#

Get the run history (read-only).

Returns:

A RunLogHistory containing all completed RunLog entries. The history cannot be modified.

set_project(name: str) Project[source]#

Set or create the current project by name.

start_run(type: RunType | str, name: str | None = None, parent_run_id: str | None = None, custom_type: str | None = None)[source]#

Context manager to start and finish a run.

update_active_run(status: Literal[RunStatus.FINISHED, RunStatus.KILLED, RunStatus.FAILED] | None = None, ended_at: datetime | None = None, metrics: list[Metric] | None = None, params: list[Parameter] | None = None, external_links: list[ExternalLink] | None = None, parent_run_id: str | _RemoveParent | None = None) None[source]#

Update the status and end time of the active run.

validate_device(device: str) Device[source]#

Check if the specified device is supported in the Embedl device cloud.

Parameters:

device – The device name to check.

Returns:

The Device if supported.

Raises:

UnsupportedDeviceError – If device is not in the supported device list.

class embedl_hub.tracking.RunType(value)[source]#

Bases: Enum

COMPILE = 'COMPILE'#
CUSTOM = 'CUSTOM'#
EVAL = 'EVAL'#
GRAPH = 'GRAPH'#
INFERENCE = 'INFERENCE'#
PROFILE = 'PROFILE'#