Bases: LineageNode

Model Version Object representing a specific version of the model that could be run.

Initializes a LineageNode instance.

  • session – The Snowflake session object.

  • name – Fully qualified name of the lineage node, which is in the format ‘<db>.<schema>.<object_name>’.

  • domain – The domain of the lineage node.

  • version – The version of the lineage node, if applies.

  • status – The status of the lineage node. Possible values are: - ‘MASKED’: The user does not have the privilege to view the node. - ‘DELETED’: The node has been deleted. - ‘ACTIVE’: The node is currently active.

  • created_on – The creation time of the lineage node.


ValueError – If the name is not fully qualified.


delete_metric(metric_name: str) None

Delete a metric from metric storage.


metric_name – The name of the metric to be deleted.


KeyError – When the requested metric name does not exist.

export(target_path: str, *, export_mode: ExportMode = ExportMode.MODEL) None

Export model files to a local directory.

  • target_path – Path to a local directory to export files to. A directory will be created if does not exist.

  • export_mode – The mode to export the model. Defaults to ExportMode.MODEL. ExportMode.MODEL: All model files including environment to load the model and model weights. ExportMode.FULL: Additional files to run the model in Warehouse, besides all files in MODEL mode,


ValueError – Raised when the target path is a file or an non-empty folder.

get_metric(metric_name: str) Any

Get the value of a specific metric.


metric_name – The name of the metric.


KeyError – When the requested metric name does not exist.


The value of the metric.

lineage(direction: Literal['upstream', 'downstream'] = 'downstream', domain_filter: Optional[Set[Literal['feature_view', 'dataset', 'model', 'table', 'view']]] = None) List[Union[FeatureView, Dataset, ModelVersion, LineageNode]]

Retrieves the lineage nodes connected to this node.

  • direction – The direction to trace lineage. Defaults to “downstream”.

  • domain_filter – Set of domains to filter nodes. Defaults to None.


A list of connected lineage nodes.

Return type:


This function or method is in private preview since 1.5.3.

load(*, force: bool = False, options: Optional[Union[BaseModelLoadOption, CatBoostModelLoadOptions, CustomModelLoadOption, LGBMModelLoadOptions, SKLModelLoadOptions, XGBModelLoadOptions, SNOWModelLoadOptions, PyTorchLoadOptions, TorchScriptLoadOptions, TensorflowLoadOptions, MLFlowLoadOptions, HuggingFaceLoadOptions, SentenceTransformersLoadOptions, LLMLoadOptions]] = None) Union[catboost.CatBoost, lightgbm.LGBMModel, lightgbm.Booster, CustomModel, sklearn.base.BaseEstimator, sklearn.pipeline.Pipeline, xgboost.XGBModel, xgboost.Booster, torch.nn.Module, torch.jit.ScriptModule, tensorflow.Module, base.BaseEstimator, mlflow.pyfunc.PyFuncModel, transformers.Pipeline, sentence_transformers.SentenceTransformer, HuggingFacePipelineModel,]
Load the underlying original Python object back from a model.

This operation requires to have the exact the same environment as the one when logging the model, otherwise, the model might be not functional or some other problems might occur.

  • force – Bypass the best-effort environment validation. Defaults to False.

  • options – Options to specify when loading the model, check for available options. Defaults to None.


ValueError – Raised when the best-effort environment validation fails.


The original Python object loaded from the model object.

run(X: Union[DataFrame, DataFrame], *, function_name: Optional[str] = None, partition_column: Optional[str] = None, strict_input_validation: bool = False) Union[DataFrame, DataFrame]

Invoke a method in a model version object.

  • X – The input data, which could be a pandas DataFrame or Snowpark DataFrame.

  • function_name – The function name to run. It is the name used to call a function in SQL. Defaults to None. It can only be None if there is only 1 method.

  • partition_column – The partition column name to partition by.

  • strict_input_validation – Enable stricter validation for the input data. This will result value range based type validation to make sure your input data won’t overflow when providing to the model.

  • ValueError – When no method with the corresponding name is available.

  • ValueError – When there are more than 1 target methods available in the model but no function name specified.

  • ValueError – When the partition column is not a valid Snowflake identifier.


The prediction data. It would be the same type dataframe as your input.

set_alias(alias_name: str) None

Set alias to a model version.


alias_name – Alias to the model version.

set_metric(metric_name: str, value: Any) None

Set the value of a specific metric.

  • metric_name – The name of the metric.

  • value – The value of the metric.

show_functions() List[ModelFunctionInfo]

Show all functions information in a model version that is callable.


  • name: The name of the function to be called (both in SQL and in Python SDK).

  • target_method: The original method name in the logged Python object.

  • signature: Python signature of the original method.

Return type:

A list of ModelFunctionInfo objects containing the following information

show_metrics() Dict[str, Any]

Show all metrics logged with the model version.


A dictionary showing the metrics.

unset_alias(version_or_alias: str) None

unset alias to a model version.


version_or_alias – The name of the version or alias to a version.



The comment to the model version.


The description for the model version. This is an alias of comment.


Return the fully qualified name of the model to which the model version belongs.


Return the name of the model to which the model version belongs, usable as a reference in SQL.


Return the name of the version to which the model version belongs, usable as a reference in SQL.