Share via


Model Class

Model for training and scoring.

Constructor

Model(*, name: str | None = None, version: str | None = None, type: str | None = None, path: str | PathLike | None = None, utc_time_created: str | None = None, flavors: Dict[str, Dict[str, Any]] | None = None, description: str | None = None, tags: Dict | None = None, properties: Dict | None = None, stage: str | None = None, **kwargs: Any)

Parameters

Name Description
name
Required

The name of the model. Defaults to a random GUID.

version
Required

The version of the model. Defaults to "1" if either no name or an unregistered name is provided. Otherwise, defaults to autoincrement from the last registered version of the model with that name.

type
Required

The storage format for this entity, used for NCD (Novel Class Discovery). Accepted values are "custom_model", "mlflow_model", or "triton_model". Defaults to "custom_model".

utc_time_created
Required

The date and time when the model was created, in UTC ISO 8601 format. (e.g. '2020-10-19 17:44:02.096572').

flavors
Required

The flavors in which the model can be interpreted. Defaults to None.

path
Required

A remote uri or a local path pointing to a model. Defaults to None.

description
Required

The description of the resource. Defaults to None

tags
Required

Tag dictionary. Tags can be added, removed, and updated. Defaults to None.

properties
Required

The asset property dictionary. Defaults to None.

stage
Required

The stage of the resource. Defaults to None.

kwargs
Required

A dictionary of additional configuration parameters.

Keyword-Only Parameters

Name Description
name
Default value: None
version
Default value: None
type
Default value: None
path
Default value: None
utc_time_created
Default value: None
flavors
Default value: None
description
Default value: None
tags
Default value: None
properties
Default value: None
stage
Default value: None

Examples

Creating a Model object.


   from azure.ai.ml.entities import Model

   model = Model(
       name="model1",
       version="5",
       description="my first model in prod",
       path="models/very_important_model.pkl",
       properties={"prop1": "value1", "prop2": "value2"},
       type="mlflow_model",
       flavors={
           "sklearn": {"sklearn_version": "0.23.2"},
           "python_function": {"loader_module": "office.plrmodel", "python_version": 3.6},
       },
       stage="Production",
   )
   ml_client.models.create_or_update(model)

Methods

dump

Dump the asset content into a file in YAML format.

dump

Dump the asset content into a file in YAML format.

dump(dest: str | PathLike | IO, **kwargs: Any) -> None

Parameters

Name Description
dest
Required
Union[<xref:PathLike>, str, IO[AnyStr]]

The local path or file stream to write the YAML content to. If dest is a file path, a new file will be created. If dest is an open file, the file will be written to directly.

Exceptions

Type Description

Raised if dest is a file path and the file already exists.

Raised if dest is an open file and the file is not writable.

Attributes

base_path

The base path of the resource.

Returns

Type Description
str

The base path of the resource.

creation_context

The creation context of the resource.

Returns

Type Description

The creation metadata for the resource.

id

The resource ID.

Returns

Type Description

The global ID of the resource, an Azure Resource Manager (ARM) ID.

path

version

The asset version.

Returns

Type Description
str

The asset version.