mlrun.package.log_hint.LogHint#
- class mlrun.package.log_hint.LogHint(*, key: str, tag: str = '', itemized: Any = False, artifact_type: str | None = None, packing_kwargs: dict | None = None, labels: dict[str, str] | None = None, artifact_path: str | None = None, extra_data: dict = None, metrics: dict = None)[source]#
Bases:
BaseModelA log hint is a configuration to log an object returned from an MLRun function. Log hints are passed to the function's run() method via the returns argument.
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
Attributes
The artifact key to log the object under.
The artifact tag to log the object under.
Determines if collections (lists or dicts) should be unbundled and logged as individual items.
The artifact type to log the object as.
Additional keyword arguments to pass to the packager's
packwhen packing the object for logging.Labels to add to the logged artifact.
The artifact path to log the object to.
Extra data to log alongside the artifact.
Metrics to log alongside the model artifact (only for model artifacts).
- key: str#
The artifact key to log the object under.
- tag: str#
The artifact tag to log the object under. Default is an empty string.
- itemized: Any#
Determines if collections (lists or dicts) should be unbundled and logged as individual items.
When itemized is enabled, the packager performs an unbundling process: instead of logging a collection as a single unit, it breaks it down into separate artifacts. Each item is logged under the primary key using either an index suffix (for sequences) or a sub-key suffix (for maps), inheriting the original log hint configuration.
Accepts the following types:
bool-Truerecursively unbundles the object all the way down.False(default) logs the collection as a single, opaque artifact.int- Specifies the maximum depth of unbundling. For example,1itemizes the top-level collection but logs nested collections as single units.
- artifact_type: str | None#
The artifact type to log the object as. If None is given, the default artifact type for the object's type will be used. Default is None.
Common artifact types are listed in
mlrun.package.ArtifactType.
- packing_kwargs: dict | None#
Additional keyword arguments to pass to the packager's
packwhen packing the object for logging. To know which keyword arguments are supported, check the relevant packager (according to the returned object type) pack method (according to the given artifact type) documentation.
- labels: dict[str, str] | None#
Labels to add to the logged artifact.
- artifact_path: str | None#
The artifact path to log the object to. If None, the default artifact path will be used. Default is None.
- extra_data: dict#
Extra data to log alongside the artifact. To link to another package, write the key and a '...' as the value. For more information, see the 'Linking artifacts' section at the
PackagerorDefaultPackagerdocumentation.
- metrics: dict#
Metrics to log alongside the model artifact (only for model artifacts). To link to another package, write the key and a '...' as the value. For more information, see the 'Linking artifacts' section at the
PackagerorDefaultPackagerdocumentation.
Methods
__init__(**data)Create a new model by parsing and validating input data from keyword arguments.
construct([_fields_set])Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data.
copy(*[, include, exclude, update, deep])Duplicate a model, optionally choose which fields to include, exclude and change.
dict(*[, include, exclude, by_alias, ...])Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
from_orm(obj)json(*[, include, exclude, by_alias, ...])Generate a JSON representation of the model, include and exclude arguments as per dict().
parse_file(path, *[, content_type, ...])parse_obj(obj)Override the default model_validate method to add support for parsing log hints from the old dictionary format.
parse_raw(b, *[, content_type, encoding, ...])schema([by_alias, ref_template])schema_json(*[, by_alias, ref_template])update_forward_refs(**localns)Try to update ForwardRefs on fields based on this Model, globalns and localns.
validate(value)- __init__(**data: Any) None#
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
- classmethod construct(_fields_set: 'SetStr' | None = None, **values: Any) Model#
Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = 'allow' was set since it adds all passed values
- copy(*, include: 'AbstractSetIntStr' | 'MappingIntStrAny' | None = None, exclude: 'AbstractSetIntStr' | 'MappingIntStrAny' | None = None, update: 'DictStrAny' | None = None, deep: bool = False) Model#
Duplicate a model, optionally choose which fields to include, exclude and change.
- Parameters:
include -- fields to include in new model
exclude -- fields to exclude from new model, as with values this takes precedence over include
update -- values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data
deep -- set to True to make a deep copy of the model
- Returns:
new model instance
- dict(*, include: 'AbstractSetIntStr' | 'MappingIntStrAny' | None = None, exclude: 'AbstractSetIntStr' | 'MappingIntStrAny' | None = None, by_alias: bool = False, skip_defaults: bool | None = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) DictStrAny#
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
- json(*, include: 'AbstractSetIntStr' | 'MappingIntStrAny' | None = None, exclude: 'AbstractSetIntStr' | 'MappingIntStrAny' | None = None, by_alias: bool = False, skip_defaults: bool | None = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Callable[[Any], Any] | None = None, models_as_dict: bool = True, **dumps_kwargs: Any) str#
Generate a JSON representation of the model, include and exclude arguments as per dict().
encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().
- classmethod parse_file(path: str | Path, *, content_type: str = None, encoding: str = 'utf8', proto: Protocol = None, allow_pickle: bool = False) Model#
- classmethod parse_obj(obj: Any) Self[source]#
Override the default model_validate method to add support for parsing log hints from the old dictionary format.
Note: This override is temporary and will be removed in MLRun 1.13.0, at which point only the new
LogHintformat will be supported for parsing.- Parameters:
obj -- The object to validate and parse into a LogHint instance. This can be in the old dictionary format or the new LogHint format.
- Returns:
An instance of
LogHintcreated from the input object.
- classmethod parse_raw(b: StrBytes, *, content_type: str = None, encoding: str = 'utf8', proto: Protocol = None, allow_pickle: bool = False) Model#
- classmethod schema(by_alias: bool = True, ref_template: str = '#/definitions/{model}') DictStrAny#
- classmethod schema_json(*, by_alias: bool = True, ref_template: str = '#/definitions/{model}', **dumps_kwargs: Any) str#
- classmethod update_forward_refs(**localns: Any) None#
Try to update ForwardRefs on fields based on this Model, globalns and localns.