Artifact Specs

Pydantic models for specifying the save/load rules of an artifact, like where it comes from, which schema is to be used, etc.

Mostly meant for applications that are based on configuration files, so the logic for loading/saving a run artifact or model version can be fully encoded in the configuration and there’s no need to change the code when an artifact specification is changed.

pydantic model mlopus.artschema.RunArtifact[source]

Bases: ArtifactSubject[RunApi, _RunLineageArg]

Specification of a run artifact.

field optional: bool = False

Skip silently if run artifact is missing at load time.

New in version 1.3.0.

field path_in_run: str = None
field run_id: str = None
pydantic model mlopus.artschema.ModelVersionArtifact[source]

Bases: ArtifactSubject[ModelVersionApi, _ModelLineageArg]

Specification of a model version artifact.

field model_name: str [Required]

Parent model name.

field model_version: Optional[str] = None

Required when loading, optional when publishing.

field path_in_run: Optional[str] = None

Only used when publishing. See path_in_run.

field run_id: str = None

Parent run ID. Required when publishing.

field tags: Optional[Mapping] = None

Optional, only used when publishing. See mlopus.mlflow.schema.ModelVersion.tags.

pydantic model mlopus.artschema.LogArtifactSpec[source]

Bases: MlflowApiMixin, Generic[T, LA]

Specification for logging an artifact.

field allow_duplication: Optional[bool] = None

See allow_duplication

field auto_register: Union[bool, Dict[str, Any]] = False

See mlopus.artschema.log_run_artifact.auto_register and mlopus.artschema.log_model_version.auto_register

field dumper_conf: Optional[Dict[str, Any]] = None

See dumper

field keep_the_source: Optional[bool] = None

See keep_the_source

field schema_: Union[Schema, Type[Schema], str, None] [Optional] (alias 'schema')

See schema

field skip_reqs_check: bool = False

See skip_reqs_check

field subject: ArtifactSubject [Required]

Instance (or dict to be parsed into instance) of RunArtifact or ModelVersionArtifact. See also: subject.

field use_cache: Optional[bool] = None

See use_cache

log(artifact, schema=None)[source]

Log artifact.

Parameters:
Return type:

TypeVar(T, bound= EntityApi)

pydantic model mlopus.artschema.LoadArtifactSpec[source]

Bases: MlflowApiMixin, Generic[T, LA]

Specification for loading an artifact.

field export_opts: ExportOptions [Optional]

Options for exporting artifact cache.

New in version 1.4.

field loader_conf: Optional[Dict[str, Any]] = None

See loader

field schema_: Union[Schema, Type[Schema], str, None] [Optional] (alias 'schema')

See schema

field skip_reqs_check: bool = False

See skip_reqs_check

field subject: ArtifactSubject [Required]

Instance (or dict to be parsed into instance) of RunArtifact or ModelVersionArtifact. See also: subject.

download()[source]

Cache subject metadata and artifact.

Return type:

Path

Returns:

A Path to the cached artifact.

export(target)[source]

Export subject metadata and artifact cache.

Parameters:

target (Path) – Target cache export Path.

Return type:

Optional[Path]

load(schema=None, dry_run=False)[source]

Load artifact.

Parameters:
Return type:

TypeVar(A, bound= object)

Returns:

place(target, **kwargs)[source]

Place artifact on target path.

New in version 1.3.

property entity_api: T

Entity metadata with MLFlow API handle.

property run: Run

Get source run metadata.

New in version 1.4.

pydantic model mlopus.artschema.specs.ExportOptions[source]

Bases: BaseModel

Options for exporting artifact cache.

New in version 1.4.

field ignore_globs: List[str] [Optional]

Export only the artifact files that do not match these glob patterns.

field metadata_only: bool = False

Export metadata only, not the actual artifact file(s).