snowflake-ml-python 1.4.0__py3-none-any.whl → 1.5.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- snowflake/ml/_internal/env_utils.py +77 -32
- snowflake/ml/_internal/exceptions/dataset_error_messages.py +5 -0
- snowflake/ml/_internal/exceptions/dataset_errors.py +24 -0
- snowflake/ml/_internal/exceptions/error_codes.py +3 -0
- snowflake/ml/_internal/lineage/data_source.py +10 -0
- snowflake/ml/_internal/lineage/dataset_dataframe.py +44 -0
- snowflake/ml/_internal/utils/identifier.py +3 -1
- snowflake/ml/_internal/utils/sql_identifier.py +2 -6
- snowflake/ml/dataset/__init__.py +10 -0
- snowflake/ml/dataset/dataset.py +454 -129
- snowflake/ml/dataset/dataset_factory.py +53 -0
- snowflake/ml/dataset/dataset_metadata.py +103 -0
- snowflake/ml/dataset/dataset_reader.py +202 -0
- snowflake/ml/feature_store/feature_store.py +531 -332
- snowflake/ml/feature_store/feature_view.py +40 -23
- snowflake/ml/fileset/embedded_stage_fs.py +146 -0
- snowflake/ml/fileset/sfcfs.py +56 -54
- snowflake/ml/fileset/snowfs.py +159 -0
- snowflake/ml/fileset/stage_fs.py +49 -17
- snowflake/ml/model/__init__.py +2 -2
- snowflake/ml/model/_api.py +16 -1
- snowflake/ml/model/_client/model/model_impl.py +27 -0
- snowflake/ml/model/_client/model/model_version_impl.py +137 -50
- snowflake/ml/model/_client/ops/model_ops.py +159 -40
- snowflake/ml/model/_client/sql/model.py +25 -2
- snowflake/ml/model/_client/sql/model_version.py +131 -2
- snowflake/ml/model/_deploy_client/image_builds/server_image_builder.py +5 -1
- snowflake/ml/model/_deploy_client/image_builds/templates/dockerfile_template +1 -0
- snowflake/ml/model/_deploy_client/snowservice/deploy.py +2 -0
- snowflake/ml/model/_deploy_client/utils/constants.py +0 -5
- snowflake/ml/model/_deploy_client/utils/snowservice_client.py +21 -50
- snowflake/ml/model/_model_composer/model_composer.py +22 -1
- snowflake/ml/model/_model_composer/model_manifest/model_manifest.py +38 -51
- snowflake/ml/model/_model_composer/model_manifest/model_manifest_schema.py +19 -1
- snowflake/ml/model/_model_composer/model_method/model_method.py +6 -10
- snowflake/ml/model/_packager/model_env/model_env.py +41 -0
- snowflake/ml/model/_packager/model_handlers/catboost.py +206 -0
- snowflake/ml/model/_packager/model_handlers/lightgbm.py +218 -0
- snowflake/ml/model/_packager/model_handlers/sklearn.py +3 -0
- snowflake/ml/model/_packager/model_meta/_core_requirements.py +1 -1
- snowflake/ml/model/_packager/model_meta/model_meta.py +37 -11
- snowflake/ml/model/_packager/model_meta/model_meta_schema.py +20 -1
- snowflake/ml/model/_packager/model_meta_migrator/migrator_plans.py +3 -1
- snowflake/ml/model/_packager/model_packager.py +2 -5
- snowflake/ml/model/{_model_composer/model_runtime/_runtime_requirements.py → _packager/model_runtime/_snowml_inference_alternative_requirements.py} +1 -1
- snowflake/ml/model/_packager/model_runtime/model_runtime.py +137 -0
- snowflake/ml/model/type_hints.py +21 -2
- snowflake/ml/modeling/_internal/estimator_utils.py +16 -11
- snowflake/ml/modeling/_internal/local_implementations/pandas_handlers.py +4 -1
- snowflake/ml/modeling/_internal/local_implementations/pandas_trainer.py +55 -3
- snowflake/ml/modeling/_internal/ml_runtime_implementations/ml_runtime_handlers.py +34 -18
- snowflake/ml/modeling/_internal/model_trainer.py +7 -0
- snowflake/ml/modeling/_internal/model_trainer_builder.py +42 -9
- snowflake/ml/modeling/_internal/snowpark_implementations/distributed_hpo_trainer.py +13 -14
- snowflake/ml/modeling/_internal/snowpark_implementations/snowpark_handlers.py +29 -7
- snowflake/ml/modeling/_internal/snowpark_implementations/snowpark_trainer.py +261 -16
- snowflake/ml/modeling/calibration/calibrated_classifier_cv.py +246 -175
- snowflake/ml/modeling/cluster/affinity_propagation.py +246 -175
- snowflake/ml/modeling/cluster/agglomerative_clustering.py +246 -175
- snowflake/ml/modeling/cluster/birch.py +248 -175
- snowflake/ml/modeling/cluster/bisecting_k_means.py +248 -175
- snowflake/ml/modeling/cluster/dbscan.py +246 -175
- snowflake/ml/modeling/cluster/feature_agglomeration.py +248 -175
- snowflake/ml/modeling/cluster/k_means.py +248 -175
- snowflake/ml/modeling/cluster/mean_shift.py +246 -175
- snowflake/ml/modeling/cluster/mini_batch_k_means.py +248 -175
- snowflake/ml/modeling/cluster/optics.py +246 -175
- snowflake/ml/modeling/cluster/spectral_biclustering.py +246 -175
- snowflake/ml/modeling/cluster/spectral_clustering.py +246 -175
- snowflake/ml/modeling/cluster/spectral_coclustering.py +246 -175
- snowflake/ml/modeling/compose/column_transformer.py +248 -175
- snowflake/ml/modeling/compose/transformed_target_regressor.py +246 -175
- snowflake/ml/modeling/covariance/elliptic_envelope.py +246 -175
- snowflake/ml/modeling/covariance/empirical_covariance.py +246 -175
- snowflake/ml/modeling/covariance/graphical_lasso.py +246 -175
- snowflake/ml/modeling/covariance/graphical_lasso_cv.py +246 -175
- snowflake/ml/modeling/covariance/ledoit_wolf.py +246 -175
- snowflake/ml/modeling/covariance/min_cov_det.py +246 -175
- snowflake/ml/modeling/covariance/oas.py +246 -175
- snowflake/ml/modeling/covariance/shrunk_covariance.py +246 -175
- snowflake/ml/modeling/decomposition/dictionary_learning.py +248 -175
- snowflake/ml/modeling/decomposition/factor_analysis.py +248 -175
- snowflake/ml/modeling/decomposition/fast_ica.py +248 -175
- snowflake/ml/modeling/decomposition/incremental_pca.py +248 -175
- snowflake/ml/modeling/decomposition/kernel_pca.py +248 -175
- snowflake/ml/modeling/decomposition/mini_batch_dictionary_learning.py +248 -175
- snowflake/ml/modeling/decomposition/mini_batch_sparse_pca.py +248 -175
- snowflake/ml/modeling/decomposition/pca.py +248 -175
- snowflake/ml/modeling/decomposition/sparse_pca.py +248 -175
- snowflake/ml/modeling/decomposition/truncated_svd.py +248 -175
- snowflake/ml/modeling/discriminant_analysis/linear_discriminant_analysis.py +248 -175
- snowflake/ml/modeling/discriminant_analysis/quadratic_discriminant_analysis.py +246 -175
- snowflake/ml/modeling/ensemble/ada_boost_classifier.py +246 -175
- snowflake/ml/modeling/ensemble/ada_boost_regressor.py +246 -175
- snowflake/ml/modeling/ensemble/bagging_classifier.py +246 -175
- snowflake/ml/modeling/ensemble/bagging_regressor.py +246 -175
- snowflake/ml/modeling/ensemble/extra_trees_classifier.py +246 -175
- snowflake/ml/modeling/ensemble/extra_trees_regressor.py +246 -175
- snowflake/ml/modeling/ensemble/gradient_boosting_classifier.py +246 -175
- snowflake/ml/modeling/ensemble/gradient_boosting_regressor.py +246 -175
- snowflake/ml/modeling/ensemble/hist_gradient_boosting_classifier.py +246 -175
- snowflake/ml/modeling/ensemble/hist_gradient_boosting_regressor.py +246 -175
- snowflake/ml/modeling/ensemble/isolation_forest.py +246 -175
- snowflake/ml/modeling/ensemble/random_forest_classifier.py +246 -175
- snowflake/ml/modeling/ensemble/random_forest_regressor.py +246 -175
- snowflake/ml/modeling/ensemble/stacking_regressor.py +248 -175
- snowflake/ml/modeling/ensemble/voting_classifier.py +248 -175
- snowflake/ml/modeling/ensemble/voting_regressor.py +248 -175
- snowflake/ml/modeling/feature_selection/generic_univariate_select.py +248 -175
- snowflake/ml/modeling/feature_selection/select_fdr.py +248 -175
- snowflake/ml/modeling/feature_selection/select_fpr.py +248 -175
- snowflake/ml/modeling/feature_selection/select_fwe.py +248 -175
- snowflake/ml/modeling/feature_selection/select_k_best.py +248 -175
- snowflake/ml/modeling/feature_selection/select_percentile.py +248 -175
- snowflake/ml/modeling/feature_selection/sequential_feature_selector.py +248 -175
- snowflake/ml/modeling/feature_selection/variance_threshold.py +248 -175
- snowflake/ml/modeling/framework/_utils.py +8 -1
- snowflake/ml/modeling/framework/base.py +72 -37
- snowflake/ml/modeling/gaussian_process/gaussian_process_classifier.py +246 -175
- snowflake/ml/modeling/gaussian_process/gaussian_process_regressor.py +246 -175
- snowflake/ml/modeling/impute/iterative_imputer.py +248 -175
- snowflake/ml/modeling/impute/knn_imputer.py +248 -175
- snowflake/ml/modeling/impute/missing_indicator.py +248 -175
- snowflake/ml/modeling/kernel_approximation/additive_chi2_sampler.py +248 -175
- snowflake/ml/modeling/kernel_approximation/nystroem.py +248 -175
- snowflake/ml/modeling/kernel_approximation/polynomial_count_sketch.py +248 -175
- snowflake/ml/modeling/kernel_approximation/rbf_sampler.py +248 -175
- snowflake/ml/modeling/kernel_approximation/skewed_chi2_sampler.py +248 -175
- snowflake/ml/modeling/kernel_ridge/kernel_ridge.py +246 -175
- snowflake/ml/modeling/lightgbm/lgbm_classifier.py +246 -175
- snowflake/ml/modeling/lightgbm/lgbm_regressor.py +246 -175
- snowflake/ml/modeling/linear_model/ard_regression.py +246 -175
- snowflake/ml/modeling/linear_model/bayesian_ridge.py +246 -175
- snowflake/ml/modeling/linear_model/elastic_net.py +246 -175
- snowflake/ml/modeling/linear_model/elastic_net_cv.py +246 -175
- snowflake/ml/modeling/linear_model/gamma_regressor.py +246 -175
- snowflake/ml/modeling/linear_model/huber_regressor.py +246 -175
- snowflake/ml/modeling/linear_model/lars.py +246 -175
- snowflake/ml/modeling/linear_model/lars_cv.py +246 -175
- snowflake/ml/modeling/linear_model/lasso.py +246 -175
- snowflake/ml/modeling/linear_model/lasso_cv.py +246 -175
- snowflake/ml/modeling/linear_model/lasso_lars.py +246 -175
- snowflake/ml/modeling/linear_model/lasso_lars_cv.py +246 -175
- snowflake/ml/modeling/linear_model/lasso_lars_ic.py +246 -175
- snowflake/ml/modeling/linear_model/linear_regression.py +246 -175
- snowflake/ml/modeling/linear_model/logistic_regression.py +246 -175
- snowflake/ml/modeling/linear_model/logistic_regression_cv.py +246 -175
- snowflake/ml/modeling/linear_model/multi_task_elastic_net.py +246 -175
- snowflake/ml/modeling/linear_model/multi_task_elastic_net_cv.py +246 -175
- snowflake/ml/modeling/linear_model/multi_task_lasso.py +246 -175
- snowflake/ml/modeling/linear_model/multi_task_lasso_cv.py +246 -175
- snowflake/ml/modeling/linear_model/orthogonal_matching_pursuit.py +246 -175
- snowflake/ml/modeling/linear_model/passive_aggressive_classifier.py +246 -175
- snowflake/ml/modeling/linear_model/passive_aggressive_regressor.py +246 -175
- snowflake/ml/modeling/linear_model/perceptron.py +246 -175
- snowflake/ml/modeling/linear_model/poisson_regressor.py +246 -175
- snowflake/ml/modeling/linear_model/ransac_regressor.py +246 -175
- snowflake/ml/modeling/linear_model/ridge.py +246 -175
- snowflake/ml/modeling/linear_model/ridge_classifier.py +246 -175
- snowflake/ml/modeling/linear_model/ridge_classifier_cv.py +246 -175
- snowflake/ml/modeling/linear_model/ridge_cv.py +246 -175
- snowflake/ml/modeling/linear_model/sgd_classifier.py +246 -175
- snowflake/ml/modeling/linear_model/sgd_one_class_svm.py +246 -175
- snowflake/ml/modeling/linear_model/sgd_regressor.py +246 -175
- snowflake/ml/modeling/linear_model/theil_sen_regressor.py +246 -175
- snowflake/ml/modeling/linear_model/tweedie_regressor.py +246 -175
- snowflake/ml/modeling/manifold/isomap.py +248 -175
- snowflake/ml/modeling/manifold/mds.py +248 -175
- snowflake/ml/modeling/manifold/spectral_embedding.py +248 -175
- snowflake/ml/modeling/manifold/tsne.py +248 -175
- snowflake/ml/modeling/mixture/bayesian_gaussian_mixture.py +246 -175
- snowflake/ml/modeling/mixture/gaussian_mixture.py +246 -175
- snowflake/ml/modeling/model_selection/grid_search_cv.py +63 -41
- snowflake/ml/modeling/model_selection/randomized_search_cv.py +80 -38
- snowflake/ml/modeling/multiclass/one_vs_one_classifier.py +246 -175
- snowflake/ml/modeling/multiclass/one_vs_rest_classifier.py +246 -175
- snowflake/ml/modeling/multiclass/output_code_classifier.py +246 -175
- snowflake/ml/modeling/naive_bayes/bernoulli_nb.py +246 -175
- snowflake/ml/modeling/naive_bayes/categorical_nb.py +246 -175
- snowflake/ml/modeling/naive_bayes/complement_nb.py +246 -175
- snowflake/ml/modeling/naive_bayes/gaussian_nb.py +246 -175
- snowflake/ml/modeling/naive_bayes/multinomial_nb.py +246 -175
- snowflake/ml/modeling/neighbors/k_neighbors_classifier.py +246 -175
- snowflake/ml/modeling/neighbors/k_neighbors_regressor.py +246 -175
- snowflake/ml/modeling/neighbors/kernel_density.py +246 -175
- snowflake/ml/modeling/neighbors/local_outlier_factor.py +246 -175
- snowflake/ml/modeling/neighbors/nearest_centroid.py +246 -175
- snowflake/ml/modeling/neighbors/nearest_neighbors.py +246 -175
- snowflake/ml/modeling/neighbors/neighborhood_components_analysis.py +248 -175
- snowflake/ml/modeling/neighbors/radius_neighbors_classifier.py +246 -175
- snowflake/ml/modeling/neighbors/radius_neighbors_regressor.py +246 -175
- snowflake/ml/modeling/neural_network/bernoulli_rbm.py +248 -175
- snowflake/ml/modeling/neural_network/mlp_classifier.py +246 -175
- snowflake/ml/modeling/neural_network/mlp_regressor.py +246 -175
- snowflake/ml/modeling/pipeline/pipeline.py +517 -35
- snowflake/ml/modeling/preprocessing/binarizer.py +1 -5
- snowflake/ml/modeling/preprocessing/k_bins_discretizer.py +1 -5
- snowflake/ml/modeling/preprocessing/label_encoder.py +1 -5
- snowflake/ml/modeling/preprocessing/max_abs_scaler.py +1 -5
- snowflake/ml/modeling/preprocessing/min_max_scaler.py +10 -12
- snowflake/ml/modeling/preprocessing/normalizer.py +1 -5
- snowflake/ml/modeling/preprocessing/one_hot_encoder.py +13 -5
- snowflake/ml/modeling/preprocessing/ordinal_encoder.py +1 -5
- snowflake/ml/modeling/preprocessing/polynomial_features.py +248 -175
- snowflake/ml/modeling/preprocessing/robust_scaler.py +1 -5
- snowflake/ml/modeling/preprocessing/standard_scaler.py +11 -11
- snowflake/ml/modeling/semi_supervised/label_propagation.py +246 -175
- snowflake/ml/modeling/semi_supervised/label_spreading.py +246 -175
- snowflake/ml/modeling/svm/linear_svc.py +246 -175
- snowflake/ml/modeling/svm/linear_svr.py +246 -175
- snowflake/ml/modeling/svm/nu_svc.py +246 -175
- snowflake/ml/modeling/svm/nu_svr.py +246 -175
- snowflake/ml/modeling/svm/svc.py +246 -175
- snowflake/ml/modeling/svm/svr.py +246 -175
- snowflake/ml/modeling/tree/decision_tree_classifier.py +246 -175
- snowflake/ml/modeling/tree/decision_tree_regressor.py +246 -175
- snowflake/ml/modeling/tree/extra_tree_classifier.py +246 -175
- snowflake/ml/modeling/tree/extra_tree_regressor.py +246 -175
- snowflake/ml/modeling/xgboost/xgb_classifier.py +246 -175
- snowflake/ml/modeling/xgboost/xgb_regressor.py +246 -175
- snowflake/ml/modeling/xgboost/xgbrf_classifier.py +246 -175
- snowflake/ml/modeling/xgboost/xgbrf_regressor.py +246 -175
- snowflake/ml/registry/model_registry.py +3 -149
- snowflake/ml/registry/registry.py +1 -1
- snowflake/ml/version.py +1 -1
- {snowflake_ml_python-1.4.0.dist-info → snowflake_ml_python-1.5.0.dist-info}/METADATA +129 -57
- snowflake_ml_python-1.5.0.dist-info/RECORD +380 -0
- snowflake/ml/model/_model_composer/model_runtime/model_runtime.py +0 -97
- snowflake/ml/registry/_artifact_manager.py +0 -156
- snowflake/ml/registry/artifact.py +0 -46
- snowflake_ml_python-1.4.0.dist-info/RECORD +0 -370
- {snowflake_ml_python-1.4.0.dist-info → snowflake_ml_python-1.5.0.dist-info}/LICENSE.txt +0 -0
- {snowflake_ml_python-1.4.0.dist-info → snowflake_ml_python-1.5.0.dist-info}/WHEEL +0 -0
- {snowflake_ml_python-1.4.0.dist-info → snowflake_ml_python-1.5.0.dist-info}/top_level.txt +0 -0
@@ -29,19 +29,13 @@ from snowflake.ml._internal.utils import (
|
|
29
29
|
table_manager,
|
30
30
|
uri,
|
31
31
|
)
|
32
|
-
from snowflake.ml.dataset import dataset
|
33
32
|
from snowflake.ml.model import (
|
34
33
|
_api as model_api,
|
35
34
|
deploy_platforms,
|
36
35
|
model_signature,
|
37
36
|
type_hints as model_types,
|
38
37
|
)
|
39
|
-
from snowflake.ml.registry import
|
40
|
-
_artifact_manager,
|
41
|
-
_initial_schema,
|
42
|
-
_schema_version_manager,
|
43
|
-
artifact,
|
44
|
-
)
|
38
|
+
from snowflake.ml.registry import _initial_schema, _schema_version_manager
|
45
39
|
from snowflake.snowpark._internal import utils as snowpark_utils
|
46
40
|
|
47
41
|
if TYPE_CHECKING:
|
@@ -142,7 +136,6 @@ def _create_registry_views(
|
|
142
136
|
registry_table_name: str,
|
143
137
|
metadata_table_name: str,
|
144
138
|
deployment_table_name: str,
|
145
|
-
artifact_table_name: str,
|
146
139
|
statement_params: Dict[str, Any],
|
147
140
|
) -> None:
|
148
141
|
"""Create views on underlying ModelRegistry tables.
|
@@ -154,7 +147,6 @@ def _create_registry_views(
|
|
154
147
|
registry_table_name: Name for the main model registry table.
|
155
148
|
metadata_table_name: Name for the metadata table used by the model registry.
|
156
149
|
deployment_table_name: Name for the deployment event table.
|
157
|
-
artifact_table_name: Name for the artifact table.
|
158
150
|
statement_params: Function usage statement parameters used in sql query executions.
|
159
151
|
"""
|
160
152
|
fully_qualified_schema_name = table_manager.get_fully_qualified_schema_name(database_name, schema_name)
|
@@ -235,23 +227,6 @@ def _create_registry_views(
|
|
235
227
|
FROM {registry_table_name} {metadata_views_join}"""
|
236
228
|
).collect(statement_params=statement_params)
|
237
229
|
|
238
|
-
# Create artifact view. it joins artifact tables with registry table on model id.
|
239
|
-
artifact_view_name = identifier.concat_names([artifact_table_name, "_VIEW"])
|
240
|
-
session.sql(
|
241
|
-
f"""CREATE OR REPLACE TEMPORARY VIEW {fully_qualified_schema_name}.{artifact_view_name} COPY GRANTS AS
|
242
|
-
SELECT
|
243
|
-
{registry_table_name}.NAME AS MODEL_NAME,
|
244
|
-
{registry_table_name}.VERSION AS MODEL_VERSION,
|
245
|
-
{artifact_table_name}.*
|
246
|
-
FROM {registry_table_name}
|
247
|
-
LEFT JOIN {artifact_table_name}
|
248
|
-
ON (ARRAY_CONTAINS(
|
249
|
-
{artifact_table_name}.ID::VARIANT,
|
250
|
-
{registry_table_name}.ARTIFACT_IDS)
|
251
|
-
)
|
252
|
-
"""
|
253
|
-
).collect(statement_params=statement_params)
|
254
|
-
|
255
230
|
|
256
231
|
def _create_active_permanent_deployment_view(
|
257
232
|
session: snowpark.Session,
|
@@ -337,11 +312,8 @@ fully integrated into the new registry.
|
|
337
312
|
self._deployment_table = identifier.get_inferred_name(_DEPLOYMENT_TABLE_NAME)
|
338
313
|
self._permanent_deployment_view = identifier.concat_names([self._deployment_table, "_VIEW"])
|
339
314
|
self._permanent_deployment_stage = identifier.concat_names([self._deployment_table, "_STAGE"])
|
340
|
-
self._artifact_table = identifier.get_inferred_name(_initial_schema._ARTIFACT_TABLE_NAME)
|
341
|
-
self._artifact_view = identifier.concat_names([self._artifact_table, "_VIEW"])
|
342
315
|
self._session = session
|
343
316
|
self._svm = _schema_version_manager.SchemaVersionManager(self._session, self._name, self._schema)
|
344
|
-
self._artifact_manager = _artifact_manager.ArtifactManager(self._session, self._name, self._schema)
|
345
317
|
|
346
318
|
# A in-memory deployment info cache to store information of temporary deployments
|
347
319
|
# TODO(zhe): Use a temporary table to replace the in-memory cache.
|
@@ -359,7 +331,6 @@ fully integrated into the new registry.
|
|
359
331
|
self._registry_table,
|
360
332
|
self._metadata_table,
|
361
333
|
self._deployment_table,
|
362
|
-
self._artifact_table,
|
363
334
|
statement_params,
|
364
335
|
)
|
365
336
|
|
@@ -399,9 +370,6 @@ fully integrated into the new registry.
|
|
399
370
|
"""Get the fully qualified name to the permanent deployment view."""
|
400
371
|
return table_manager.get_fully_qualified_table_name(self._name, self._schema, self._permanent_deployment_view)
|
401
372
|
|
402
|
-
def _fully_qualified_artifact_view_name(self) -> str:
|
403
|
-
return table_manager.get_fully_qualified_table_name(self._name, self._schema, self._artifact_view)
|
404
|
-
|
405
373
|
def _fully_qualified_schema_name(self) -> str:
|
406
374
|
"""Get the fully qualified name to the current registry schema."""
|
407
375
|
return table_manager.get_fully_qualified_schema_name(self._name, self._schema)
|
@@ -858,7 +826,6 @@ fully integrated into the new registry.
|
|
858
826
|
output_spec: Optional[Dict[str, str]] = None,
|
859
827
|
description: Optional[str] = None,
|
860
828
|
tags: Optional[Dict[str, str]] = None,
|
861
|
-
artifacts: Optional[List[artifact.Artifact]] = None,
|
862
829
|
) -> None:
|
863
830
|
"""Helper function to register model metadata.
|
864
831
|
|
@@ -878,10 +845,8 @@ fully integrated into the new registry.
|
|
878
845
|
description: A description for the model. The description can be changed later.
|
879
846
|
tags: Key-value pairs of tags to be set for this model. Tags can be modified
|
880
847
|
after model registration.
|
881
|
-
artifacts: A list of artifact references.
|
882
848
|
|
883
849
|
Raises:
|
884
|
-
ValueError: Artifact ids not found in model registry.
|
885
850
|
DataError: The given model already exists.
|
886
851
|
DatabaseError: Unable to register the model properties into table.
|
887
852
|
"""
|
@@ -897,12 +862,6 @@ fully integrated into the new registry.
|
|
897
862
|
new_model["CREATION_ROLE"] = self._session.get_current_role()
|
898
863
|
new_model["CREATION_ENVIRONMENT_SPEC"] = {"python": ".".join(map(str, sys.version_info[:3]))}
|
899
864
|
|
900
|
-
if artifacts is not None:
|
901
|
-
for atf in artifacts:
|
902
|
-
if not self._artifact_manager.exists(atf.name if atf.name is not None else "", atf.version):
|
903
|
-
raise ValueError(f"Artifact {atf.name}/{atf.version} not found in model registry.")
|
904
|
-
new_model["ARTIFACT_IDS"] = [art._id for art in artifacts]
|
905
|
-
|
906
865
|
existing_model_nums = self._list_selected_models(model_name=model_name, model_version=model_version).count()
|
907
866
|
if existing_model_nums:
|
908
867
|
raise connector.DataError(
|
@@ -1356,42 +1315,6 @@ fully integrated into the new registry.
|
|
1356
1315
|
else:
|
1357
1316
|
return dict()
|
1358
1317
|
|
1359
|
-
@telemetry.send_api_usage_telemetry(
|
1360
|
-
project=_TELEMETRY_PROJECT,
|
1361
|
-
subproject=_TELEMETRY_SUBPROJECT,
|
1362
|
-
)
|
1363
|
-
@snowpark._internal.utils.private_preview(version="1.0.10")
|
1364
|
-
def log_artifact(
|
1365
|
-
self,
|
1366
|
-
artifact: artifact.Artifact,
|
1367
|
-
name: str,
|
1368
|
-
version: Optional[str] = None,
|
1369
|
-
) -> artifact.Artifact:
|
1370
|
-
"""Upload and register an artifact to the Model Registry.
|
1371
|
-
|
1372
|
-
Args:
|
1373
|
-
artifact: artifact object.
|
1374
|
-
name: name of artifact.
|
1375
|
-
version: version of artifact.
|
1376
|
-
|
1377
|
-
Raises:
|
1378
|
-
DataError: Artifact with same name and version already exists.
|
1379
|
-
|
1380
|
-
Returns:
|
1381
|
-
Return a reference to the artifact.
|
1382
|
-
"""
|
1383
|
-
|
1384
|
-
if self._artifact_manager.exists(name, version):
|
1385
|
-
raise connector.DataError(f"Artifact {name}/{version} already exists.")
|
1386
|
-
|
1387
|
-
artifact_id = self._get_new_unique_identifier()
|
1388
|
-
return self._artifact_manager.add(
|
1389
|
-
artifact=artifact,
|
1390
|
-
artifact_id=artifact_id,
|
1391
|
-
artifact_name=name,
|
1392
|
-
artifact_version=version,
|
1393
|
-
)
|
1394
|
-
|
1395
1318
|
# Combined Registry and Repository operations.
|
1396
1319
|
@telemetry.send_api_usage_telemetry(
|
1397
1320
|
project=_TELEMETRY_PROJECT,
|
@@ -1410,7 +1333,6 @@ fully integrated into the new registry.
|
|
1410
1333
|
pip_requirements: Optional[List[str]] = None,
|
1411
1334
|
signatures: Optional[Dict[str, model_signature.ModelSignature]] = None,
|
1412
1335
|
sample_input_data: Optional[Any] = None,
|
1413
|
-
artifacts: Optional[List[artifact.Artifact]] = None,
|
1414
1336
|
code_paths: Optional[List[str]] = None,
|
1415
1337
|
options: Optional[model_types.BaseModelSaveOption] = None,
|
1416
1338
|
) -> Optional["ModelReference"]:
|
@@ -1431,19 +1353,15 @@ fully integrated into the new registry.
|
|
1431
1353
|
pip requirements.
|
1432
1354
|
signatures: Signatures of the model, which is a mapping from target method name to signatures of input and
|
1433
1355
|
output, which could be inferred by calling `infer_signature` method with sample input data.
|
1434
|
-
sample_input_data: Sample of the input data for the model.
|
1435
|
-
generated dataset, then sample_input_data is not needed. If both sample_input_data and dataset provided
|
1436
|
-
, then sample_input_data will be used to infer model signature.
|
1437
|
-
artifacts: A list of artifact ids, which are generated from log_artifact().
|
1356
|
+
sample_input_data: Sample of the input data for the model.
|
1438
1357
|
code_paths: Directory of code to import when loading and deploying the model.
|
1439
1358
|
options: Additional options when saving the model.
|
1440
1359
|
|
1441
1360
|
Raises:
|
1442
1361
|
DataError: Raised when:
|
1443
1362
|
1) the given model already exists;
|
1444
|
-
2) given artifacts does not exists in this registry.
|
1445
1363
|
ValueError: Raised when: # noqa: DAR402
|
1446
|
-
1) Signatures
|
1364
|
+
1) Signatures and sample_input_data are both not provided and model is not a
|
1447
1365
|
snowflake estimator.
|
1448
1366
|
Exception: Raised when there is any error raised when saving the model.
|
1449
1367
|
|
@@ -1458,18 +1376,6 @@ fully integrated into the new registry.
|
|
1458
1376
|
|
1459
1377
|
self._model_identifier_is_nonempty_or_raise(model_name, model_version)
|
1460
1378
|
|
1461
|
-
if artifacts is not None:
|
1462
|
-
for atf in artifacts:
|
1463
|
-
if not self._artifact_manager.exists(atf.name if atf.name is not None else "", atf.version):
|
1464
|
-
raise connector.DataError(f"Artifact {atf.name}/{atf.version} does not exists.")
|
1465
|
-
|
1466
|
-
if sample_input_data is None and artifacts is not None:
|
1467
|
-
for atf in artifacts:
|
1468
|
-
if atf.type == artifact.ArtifactType.DATASET:
|
1469
|
-
ds = self.get_artifact(atf.name if atf.name is not None else "", atf.version)
|
1470
|
-
sample_input_data = ds.features_df()
|
1471
|
-
break
|
1472
|
-
|
1473
1379
|
existing_model_nums = self._list_selected_models(model_name=model_name, model_version=model_version).count()
|
1474
1380
|
if existing_model_nums:
|
1475
1381
|
raise connector.DataError(f"Model {model_name}/{model_version} already exists. Unable to log the model.")
|
@@ -1508,7 +1414,6 @@ fully integrated into the new registry.
|
|
1508
1414
|
uri=uri.get_uri_from_snowflake_stage_path(stage_path),
|
1509
1415
|
description=description,
|
1510
1416
|
tags=tags,
|
1511
|
-
artifacts=artifacts,
|
1512
1417
|
)
|
1513
1418
|
|
1514
1419
|
return ModelReference(registry=self, model_name=model_name, model_version=model_version)
|
@@ -1733,25 +1638,6 @@ fully integrated into the new registry.
|
|
1733
1638
|
)
|
1734
1639
|
return cast(snowpark.DataFrame, res)
|
1735
1640
|
|
1736
|
-
@snowpark._internal.utils.private_preview(version="1.0.1")
|
1737
|
-
def list_artifacts(self, model_name: str, model_version: Optional[str] = None) -> snowpark.DataFrame:
|
1738
|
-
"""List all artifacts that associated with given model name and version.
|
1739
|
-
|
1740
|
-
Args:
|
1741
|
-
model_name: Name of model.
|
1742
|
-
model_version: Version of model. If version is none then only filter on name.
|
1743
|
-
Defaults to none.
|
1744
|
-
|
1745
|
-
Returns:
|
1746
|
-
A snowpark dataframe that contains all artifacts that associated with the given model.
|
1747
|
-
"""
|
1748
|
-
artifacts = self._session.sql(f"SELECT * FROM {self._fully_qualified_artifact_view_name()}").filter(
|
1749
|
-
snowpark.Column("MODEL_NAME") == model_name
|
1750
|
-
)
|
1751
|
-
if model_version is not None:
|
1752
|
-
artifacts = artifacts.filter(snowpark.Column("MODEL_VERSION") == model_version)
|
1753
|
-
return cast(snowpark.DataFrame, artifacts)
|
1754
|
-
|
1755
1641
|
@telemetry.send_api_usage_telemetry(
|
1756
1642
|
project=_TELEMETRY_PROJECT,
|
1757
1643
|
subproject=_TELEMETRY_SUBPROJECT,
|
@@ -1782,38 +1668,6 @@ fully integrated into the new registry.
|
|
1782
1668
|
)
|
1783
1669
|
return cast(snowpark.DataFrame, deployment)
|
1784
1670
|
|
1785
|
-
@telemetry.send_api_usage_telemetry(
|
1786
|
-
project=_TELEMETRY_PROJECT,
|
1787
|
-
subproject=_TELEMETRY_SUBPROJECT,
|
1788
|
-
)
|
1789
|
-
@snowpark._internal.utils.private_preview(version="1.0.11")
|
1790
|
-
def get_artifact(self, name: str, version: Optional[str] = None) -> Optional[artifact.Artifact]:
|
1791
|
-
"""Get artifact with the given (name, version).
|
1792
|
-
|
1793
|
-
Args:
|
1794
|
-
name: Name of artifact.
|
1795
|
-
version: Version of artifact.
|
1796
|
-
|
1797
|
-
Returns:
|
1798
|
-
A reference to artifact if found, otherwise none.
|
1799
|
-
"""
|
1800
|
-
artifacts = self._artifact_manager.get(
|
1801
|
-
name,
|
1802
|
-
version,
|
1803
|
-
).collect()
|
1804
|
-
|
1805
|
-
if len(artifacts) == 0:
|
1806
|
-
return None
|
1807
|
-
|
1808
|
-
atf = artifacts[0]
|
1809
|
-
if atf["TYPE"] == artifact.ArtifactType.DATASET.value:
|
1810
|
-
ds = dataset.Dataset.from_json(atf["ARTIFACT_SPEC"], self._session)
|
1811
|
-
ds._log(name=atf["NAME"], version=atf["VERSION"], id=atf["ID"])
|
1812
|
-
return ds
|
1813
|
-
|
1814
|
-
assert f"Unrecognized artifact type: {atf['TYPE']}"
|
1815
|
-
return None
|
1816
|
-
|
1817
1671
|
@telemetry.send_api_usage_telemetry(
|
1818
1672
|
project=_TELEMETRY_PROJECT,
|
1819
1673
|
subproject=_TELEMETRY_SUBPROJECT,
|
@@ -93,7 +93,7 @@ class Registry:
|
|
93
93
|
Log a model with various parameters and metadata.
|
94
94
|
|
95
95
|
Args:
|
96
|
-
model: Model object of supported types such as Scikit-learn, XGBoost, Snowpark ML,
|
96
|
+
model: Model object of supported types such as Scikit-learn, XGBoost, LightGBM, Snowpark ML,
|
97
97
|
PyTorch, TorchScript, Tensorflow, Tensorflow Keras, MLFlow, HuggingFace Pipeline,
|
98
98
|
Sentence Transformers, Peft-finetuned LLM, or Custom Model.
|
99
99
|
model_name: Name to identify the model.
|
snowflake/ml/version.py
CHANGED
@@ -1 +1 @@
|
|
1
|
-
VERSION="1.
|
1
|
+
VERSION="1.5.0"
|