embedl_hub.tracking package#
Public API for the Embedl Hub tracking package.
Top-level re-exports#
- class embedl_hub.tracking.Client(api_config: ApiConfig | None = None, *, log_remote_artifacts: bool = True)[source]#
Bases:
objectTracks 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, orNoneif no run is active.
- property latest_run_log: RunLog | None#
Get the most recent completed
RunLog, orNoneif 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 whenlog_remote_artifactsisTrue(the default). Set it toFalseto 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
LoggedArtifactthat 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()andlog_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 beNonefor 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 toTrue.
- log_link(label: str, url: str, *, save_to_run_log: bool = True) LoggedExternalLink[source]#
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 toTrue.
- Returns:
The
LoggedMetricthat 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 toTrue.
- Returns:
The
LoggedParamthat was recorded.
- property log_remote_artifacts: bool#
Whether remote artifacts are fetched and uploaded to the Hub.
When
True(the default), callinglog_artifact()with a remote path or a remoteLoggedArtifactwill download the file from the device and upload it to the Embedl Hub.Set to
Falseto 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.
- property project: Project#
- property run_history: RunLogHistory#
Get the run history (read-only).
- Returns:
A
RunLogHistorycontaining all completedRunLogentries. The history cannot be modified.
- 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.