embedl_hub.core package#

Public API for the Embedl Hub core package.

Subpackages#

Top-level re-exports#

class embedl_hub.core.HubContext(project_name: str, artifact_base_dir: Path | None = None, devices: Sequence[Device] | None = None, download_artifacts: bool = False, auto_connect: bool = True, log_remote_artifacts: bool = True)[source]#

Bases: object

Context for component execution.

artifact_base_dir: Path#
property artifact_dir: Path#

Get the local artifact directory for the current component run.

Raises:

RuntimeError – If no artifact directory has been set. This typically means the property is accessed outside of a component dispatch.

auto_connect: bool#
client: Client#
devices: dict[str, Device]#
download_artifacts: bool#
property is_active: bool#

Whether this context has been entered and is currently active.

property project_dir: Path#

Get the project-scoped artifact directory.

Returns artifact_base_dir / project_name. Run subdirectories are created beneath this path.

project_name: str#
property run_log: RunLog | None#

The RunLog for the currently active run, or None if no run is active or there is no tracking client.

Shorthand for ctx.client.current_run_log. Return this from a hub_run()-decorated function to enable automatic parent-run linking in downstream calls.

set_tags(**tags: str) None[source]#

Set tags that will be applied to all subsequent runs.

Replaces any previously set tags. Each keyword argument becomes a tag with the argument name as the tag name and its value as the tag value.

Example:

ctx.set_tags(model="resnet50", dataset="imagenet")
Parameters:

tags – Arbitrary keyword arguments where each key is a tag name and each value is a tag value (both str).

Raises:

TypeError – If any value is not a string.

property tags: dict[str, str]#

Get the current tags set on this context (read-only copy).

embedl_hub.core.LocalPath#

alias of Path

embedl_hub.core.RemotePath#

alias of PurePosixPath

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

Bases: Enum

COMPILE = 'COMPILE'#
CUSTOM = 'CUSTOM'#
EVAL = 'EVAL'#
GRAPH = 'GRAPH'#
INFERENCE = 'INFERENCE'#
PROFILE = 'PROFILE'#
embedl_hub.core.hub_run(run_type: RunType | str, *, name: str | None = None) Callable[source]#

Decorator that wraps a plain function as a tracked Hub run.

Provides the same artifact-directory setup, tracking lifecycle, remote-artifact download, and run.yaml saving as a full Component, without requiring a class definition or provider registration. Device narrowing is not performed — the function receives the full devices mapping as supplied by the caller.

The decorated function must accept ctx: HubContext as its first positional parameter and must be called inside an active with ctx: block.

Usage:

@hub_run("analyse")
def analyse(ctx: HubContext, data: pd.DataFrame, *, threshold=0.5):
    ctx.client.log_param("threshold", str(threshold))
    result = run_model(data, threshold)
    ctx.client.log_metric("accuracy", result.accuracy)
    return result

with HubContext(project_name="my-project") as ctx:
    output = analyse(ctx, data, threshold=0.8)

Parent run linking is automatic when a ComponentOutput carrying a run_log is passed as an argument.

Parameters:
  • run_type – The run type. Pass a RunType member or a plain string label (e.g. "analyse"); strings are automatically mapped to RunType.CUSTOM.

  • name – Display name logged to the Hub. Defaults to the function’s __name__.

Returns:

A decorator that wraps the target function.

Raises:
  • TypeError – If the decorated function does not have ctx as its first parameter.

  • RuntimeError – When the wrapped function is called outside an active HubContext (i.e. before with ctx: is entered).

Subpackages#