Helpers
Utility functions for working with artifact schemas.
- mlopus.artschema.get_schemas(subject)[source]
Parse artifact schema tags from
subject.See also:
mlopus.artschema.Tags.parse_subject()- Parameters:
subject¶ (
Experiment|Run|Model|ModelVersion) –Experiment, run, model or model version.- Return type:
- mlopus.artschema.get_schema(subject, alias=None)[source]
Get artifact schema class specification from
subject.- Parameters:
subject¶ (
Experiment|Run|Model|ModelVersion) –Experiment, run, model or model version.- Alias of a previously registered schema for this
subject.Defaults to default.
- Return type:
- mlopus.artschema.load_artifact(subject, path_in_run=None, schema=None, loader_conf=None, skip_reqs_check=False, dry_run=False)[source]
Load artifact of run or model version using schema.
- Parameters:
subject¶ (
RunApi|ModelVersionApi) –Run or model version with API handle.path_in_run¶ (
Optional[str]) –Ifsubjectis a model version, defaults to model name.schema¶ (
Union[Schema,Type[Schema],str,None]) –Type or instance of
SchemaFully qualified name of a
Schemaclass (e.g.: package.module:Class)Alias of a schema previously registered for this run/model version or its parent experiment/model (see
mlopus.artschema.Tags).
loader_conf¶ (
Union[TypeVar(L, bound=Loader),dict,None]) –skip_reqs_check¶ (
bool) –Ifschemais specified by alias, ignore the registered package requirement.- See
dry_run
- Return type:
Union[TypeVar(A, bound=object),Path]- Returns:
- mlopus.artschema.log_run_artifact(artifact, run, path_in_run=None, schema=None, dumper_conf=None, skip_reqs_check=False, auto_register=False, keep_the_source=None, allow_duplication=None, use_cache=None)[source]
Publish run artifact using schema.
- Parameters:
- Run API object.
path_in_run¶ (
Optional[str]) –schema¶ (
Union[Schema,Type[Schema],str,None]) –Type or instance of
SchemaFully qualified name of a
Schemaclass (e.g.: package.module:Class)Alias of a schema previously registered for this run or its parent experiment (see
mlopus.artschema.Tags).
dumper_conf¶ (
Union[TypeVar(D, bound=Dumper),dict,None]) –skip_reqs_check¶ (
bool) –Ifschemais specified by alias, ignore the registered package requirement.auto_register¶ (
bool|dict) –If a non-empty dict is passed, it is used as keyword arguments forTags.using().If theschemawas specified by alias, that alias is used by default.keep_the_source¶ (
Optional[bool]) –Seekeep_the_source(the source in this case is a callback, unless
artifactis a Path)allow_duplication¶ (
Optional[bool]) –- See
use_cache
- Return type:
None
- mlopus.artschema.log_model_version(artifact, model, run, path_in_run=None, schema=None, dumper_conf=None, skip_reqs_check=False, auto_register=False, keep_the_source=None, allow_duplication=None, use_cache=None, version=None, tags=None)[source]
Log artifact as model version using schema.
Example:
mlflow = mlopus.mlflow.get_api() version = mlopus.artschema.log_model_version( my_artifact, schema=MySchema, run=mlflow.start_run(...), model=mlflow.get_or_create_model(...), auto_register={"aliased_as": "foobar"} # register `MySchema` as `foobar` ) mlopus.artschema.load_artifact(version, schema="foobar")
- Parameters:
- Model API object.
- Run API object.
path_in_run¶ (
Optional[str]) –schema¶ (
Union[Schema,Type[Schema],str,None]) –Type or instance of
SchemaFully qualified name of a
Schemaclass (e.g.: package.module:Class)Alias of a schema previously registered for this run or its parent experiment (see
mlopus.artschema.Tags).
dumper_conf¶ (
Union[TypeVar(D, bound=Dumper),dict,None]) –skip_reqs_check¶ (
bool) –Ifschemais specified by alias, ignore the registered package requirement.auto_register¶ (
bool|dict) –See alsolog_run_artifact.auto_registerkeep_the_source¶ (
Optional[bool]) –Seekeep_the_source(the source in this case is a callback, unless
artifactis a Path)allow_duplication¶ (
Optional[bool]) –- See
use_cache
- Return type: