component_run

class pcs.component_run.ComponentRun(run_command: Optional[pcs.run_command.RunCommand] = None, experiment_id: Optional[str] = None, existing_run_id: Optional[str] = None)
IS_COMPONENT_RUN_TAG = 'pcs.is_component_run'
IS_FROZEN_KEY = 'agentos.spec_is_frozen'
RUN_COMMAND_ID_KEY = 'pcs.run_command_id'
RUN_COMMAND_REGISTRY_FILENAME = 'pcs.run_command_registry.yaml'

A ComponentRun represents the execution of a specific entry point of a specific Component with a specific ArgumentSet.

__init__(run_command: Optional[pcs.run_command.RunCommand] = None, experiment_id: Optional[str] = None, existing_run_id: Optional[str] = None) None

Run initialization can either create a new underlying MLflowRun or be be based on an existing underlying MLflowRun.

If Python gracefully supported overloading constructors, it would make this code a lot more easy to comprehend, but as it is __init__() handles both cases by inspecting which arguments are provided.

Because of this, we recommend using class factory methods instead of directly using __init__(). For example: Run.from_run_command(), Run.from_existing_run_id().

Parameters
  • experiment_id – Optional Experiment ID.

  • existing_run_id – Optional Run ID.

classmethod from_registry(registry: pcs.registry.Registry, identifier: str) pcs.component_run.ComponentRun
classmethod from_run_command(run_command: pcs.run_command.RunCommand, experiment_id: Optional[str] = None) pcs.component_run.ComponentRun
classmethod from_spec(spec: Mapping, registry: pcs.registry.Registry) pcs.component_run.ComponentRun
property is_publishable: bool
property is_reproducible: bool
log_return_value(ret_val: Any, format: str = 'pickle')

Logs the return value of an entry_point run using the specified serialization format.

Parameters
  • ret_val – The Python object returned by this Run to be logged.

  • format – Valid values are ‘pickle, ‘json’, or ‘yaml’.

property return_value: str
property run_command: pcs.run_command.RunCommand
set_and_log_run_command(run_command: pcs.run_command.RunCommand) None

Log a Registry YAML file for the RunCommand of this run, including the ArgumentSet, entry_point (i.e., function name), component ID, as well as the root component being run and its full transitive dependency graph of other components as part of this Run. This registry file will contain the component spec and repo spec for each component in the root component’s dependency graph. Note that a Run object contains a component object and thus the root component’s full dependency graph of other components, and as such does not depend on a Registry to provide reproducibility. Like a Component, a Run (including its entry point, argument_set, root component, and the root component’s full dependency graph) can be dumped into a Registry for sharing purposes, which essentially normalizes the Run’s root component’s dependency graph into flat component specs.

to_registry(registry: Optional[pcs.registry.Registry] = None, recurse: bool = True, force: bool = False, include_artifacts: bool = False) pcs.registry.Registry
to_spec(flatten: bool = False) Mapping
pcs.component_run.active_component_run(caller: Any, fail_if_none: bool = False) Optional[pcs.run.Run]

A helper function, returns the currently active ComponentRun, if it exists, else None. More specifically, if the caller is an object that is managed by a Component (i.e. if it has a __component__ attribute) that itself has an active_run, return that Run.

Parameters
  • caller – the managed object to fetch the active component run for.

  • fail_if_none – if no active component run found, throw an exception instead of returning None.

Returns

the active component run if it exists, else None.