snowflake-ml-python 1.8.2__py3-none-any.whl → 1.8.4__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/cortex/__init__.py +7 -1
- snowflake/cortex/_classify_text.py +3 -3
- snowflake/cortex/_complete.py +23 -24
- snowflake/cortex/_embed_text_1024.py +4 -4
- snowflake/cortex/_embed_text_768.py +4 -4
- snowflake/cortex/_finetune.py +8 -8
- snowflake/cortex/_util.py +8 -12
- snowflake/ml/_internal/env.py +4 -3
- snowflake/ml/_internal/env_utils.py +63 -34
- snowflake/ml/_internal/file_utils.py +10 -21
- snowflake/ml/_internal/human_readable_id/hrid_generator_base.py +5 -7
- snowflake/ml/_internal/init_utils.py +2 -3
- snowflake/ml/_internal/lineage/lineage_utils.py +6 -6
- snowflake/ml/_internal/platform_capabilities.py +18 -16
- snowflake/ml/_internal/telemetry.py +39 -52
- snowflake/ml/_internal/type_utils.py +3 -3
- snowflake/ml/_internal/utils/db_utils.py +2 -2
- snowflake/ml/_internal/utils/identifier.py +10 -10
- snowflake/ml/_internal/utils/import_utils.py +2 -2
- snowflake/ml/_internal/utils/parallelize.py +7 -7
- snowflake/ml/_internal/utils/pkg_version_utils.py +11 -11
- snowflake/ml/_internal/utils/query_result_checker.py +4 -4
- snowflake/ml/_internal/utils/snowflake_env.py +28 -6
- snowflake/ml/_internal/utils/snowpark_dataframe_utils.py +2 -2
- snowflake/ml/_internal/utils/sql_identifier.py +3 -3
- snowflake/ml/_internal/utils/table_manager.py +9 -9
- snowflake/ml/data/_internal/arrow_ingestor.py +7 -7
- snowflake/ml/data/data_connector.py +15 -36
- snowflake/ml/data/data_ingestor.py +4 -15
- snowflake/ml/data/data_source.py +2 -2
- snowflake/ml/data/ingestor_utils.py +3 -3
- snowflake/ml/data/torch_utils.py +5 -5
- snowflake/ml/dataset/dataset.py +11 -11
- snowflake/ml/dataset/dataset_metadata.py +8 -8
- snowflake/ml/dataset/dataset_reader.py +7 -7
- snowflake/ml/feature_store/__init__.py +1 -1
- snowflake/ml/feature_store/access_manager.py +7 -7
- snowflake/ml/feature_store/entity.py +6 -6
- snowflake/ml/feature_store/examples/airline_features/entities.py +1 -3
- snowflake/ml/feature_store/examples/airline_features/features/plane_features.py +1 -3
- snowflake/ml/feature_store/examples/airline_features/features/weather_features.py +1 -3
- snowflake/ml/feature_store/examples/citibike_trip_features/entities.py +1 -3
- snowflake/ml/feature_store/examples/citibike_trip_features/features/station_feature.py +1 -3
- snowflake/ml/feature_store/examples/citibike_trip_features/features/trip_feature.py +1 -3
- snowflake/ml/feature_store/examples/example_helper.py +16 -16
- snowflake/ml/feature_store/examples/new_york_taxi_features/entities.py +1 -3
- snowflake/ml/feature_store/examples/new_york_taxi_features/features/location_features.py +1 -3
- snowflake/ml/feature_store/examples/new_york_taxi_features/features/trip_features.py +1 -3
- snowflake/ml/feature_store/examples/wine_quality_features/entities.py +1 -3
- snowflake/ml/feature_store/examples/wine_quality_features/features/managed_wine_features.py +1 -3
- snowflake/ml/feature_store/examples/wine_quality_features/features/static_wine_features.py +1 -3
- snowflake/ml/feature_store/feature_store.py +52 -64
- snowflake/ml/feature_store/feature_view.py +24 -24
- snowflake/ml/fileset/embedded_stage_fs.py +5 -5
- snowflake/ml/fileset/fileset.py +5 -5
- snowflake/ml/fileset/sfcfs.py +13 -13
- snowflake/ml/fileset/stage_fs.py +15 -15
- snowflake/ml/jobs/_utils/constants.py +1 -1
- snowflake/ml/jobs/_utils/interop_utils.py +10 -10
- snowflake/ml/jobs/_utils/payload_utils.py +45 -46
- snowflake/ml/jobs/_utils/scripts/get_instance_ip.py +4 -4
- snowflake/ml/jobs/_utils/scripts/mljob_launcher.py +8 -5
- snowflake/ml/jobs/_utils/scripts/signal_workers.py +8 -8
- snowflake/ml/jobs/_utils/spec_utils.py +18 -29
- snowflake/ml/jobs/_utils/types.py +2 -2
- snowflake/ml/jobs/decorators.py +10 -5
- snowflake/ml/jobs/job.py +87 -30
- snowflake/ml/jobs/manager.py +86 -56
- snowflake/ml/lineage/lineage_node.py +5 -5
- snowflake/ml/model/_client/model/model_impl.py +3 -3
- snowflake/ml/model/_client/model/model_version_impl.py +103 -35
- snowflake/ml/model/_client/ops/metadata_ops.py +7 -7
- snowflake/ml/model/_client/ops/model_ops.py +41 -41
- snowflake/ml/model/_client/ops/service_ops.py +217 -32
- snowflake/ml/model/_client/service/model_deployment_spec.py +359 -65
- snowflake/ml/model/_client/service/model_deployment_spec_schema.py +69 -24
- snowflake/ml/model/_client/sql/model.py +8 -8
- snowflake/ml/model/_client/sql/model_version.py +26 -26
- snowflake/ml/model/_client/sql/service.py +17 -26
- snowflake/ml/model/_client/sql/stage.py +2 -2
- snowflake/ml/model/_client/sql/tag.py +6 -6
- snowflake/ml/model/_model_composer/model_composer.py +58 -32
- snowflake/ml/model/_model_composer/model_manifest/model_manifest.py +20 -16
- snowflake/ml/model/_model_composer/model_manifest/model_manifest_schema.py +14 -13
- snowflake/ml/model/_model_composer/model_method/model_method.py +3 -3
- snowflake/ml/model/_packager/model_env/model_env.py +28 -25
- snowflake/ml/model/_packager/model_handler.py +4 -4
- snowflake/ml/model/_packager/model_handlers/_base.py +2 -2
- snowflake/ml/model/_packager/model_handlers/_utils.py +47 -5
- snowflake/ml/model/_packager/model_handlers/catboost.py +5 -5
- snowflake/ml/model/_packager/model_handlers/custom.py +9 -5
- snowflake/ml/model/_packager/model_handlers/huggingface_pipeline.py +7 -21
- snowflake/ml/model/_packager/model_handlers/keras.py +4 -4
- snowflake/ml/model/_packager/model_handlers/lightgbm.py +4 -14
- snowflake/ml/model/_packager/model_handlers/mlflow.py +3 -3
- snowflake/ml/model/_packager/model_handlers/pytorch.py +5 -6
- snowflake/ml/model/_packager/model_handlers/sentence_transformers.py +5 -5
- snowflake/ml/model/_packager/model_handlers/sklearn.py +104 -46
- snowflake/ml/model/_packager/model_handlers/snowmlmodel.py +3 -3
- snowflake/ml/model/_packager/model_handlers/tensorflow.py +11 -8
- snowflake/ml/model/_packager/model_handlers/torchscript.py +6 -6
- snowflake/ml/model/_packager/model_handlers/xgboost.py +21 -22
- snowflake/ml/model/_packager/model_meta/model_blob_meta.py +2 -2
- snowflake/ml/model/_packager/model_meta/model_meta.py +39 -38
- snowflake/ml/model/_packager/model_meta/model_meta_schema.py +14 -11
- snowflake/ml/model/_packager/model_meta_migrator/base_migrator.py +3 -3
- snowflake/ml/model/_packager/model_meta_migrator/migrator_plans.py +3 -3
- snowflake/ml/model/_packager/model_meta_migrator/migrator_v1.py +4 -4
- snowflake/ml/model/_packager/model_packager.py +11 -9
- snowflake/ml/model/_packager/model_runtime/_snowml_inference_alternative_requirements.py +32 -1
- snowflake/ml/model/_packager/model_runtime/model_runtime.py +4 -2
- snowflake/ml/model/_signatures/core.py +16 -24
- snowflake/ml/model/_signatures/dmatrix_handler.py +17 -4
- snowflake/ml/model/_signatures/utils.py +6 -6
- snowflake/ml/model/custom_model.py +24 -11
- snowflake/ml/model/model_signature.py +12 -23
- snowflake/ml/model/models/huggingface_pipeline.py +7 -4
- snowflake/ml/model/type_hints.py +3 -3
- snowflake/ml/modeling/_internal/estimator_utils.py +7 -7
- snowflake/ml/modeling/_internal/local_implementations/pandas_handlers.py +6 -6
- snowflake/ml/modeling/_internal/local_implementations/pandas_trainer.py +7 -7
- snowflake/ml/modeling/_internal/model_specifications.py +8 -10
- snowflake/ml/modeling/_internal/model_trainer.py +5 -5
- snowflake/ml/modeling/_internal/model_trainer_builder.py +6 -6
- snowflake/ml/modeling/_internal/snowpark_implementations/distributed_hpo_trainer.py +30 -30
- snowflake/ml/modeling/_internal/snowpark_implementations/snowpark_handlers.py +13 -13
- snowflake/ml/modeling/_internal/snowpark_implementations/snowpark_trainer.py +31 -31
- snowflake/ml/modeling/_internal/snowpark_implementations/xgboost_external_memory_trainer.py +19 -19
- snowflake/ml/modeling/_internal/transformer_protocols.py +17 -17
- snowflake/ml/modeling/calibration/calibrated_classifier_cv.py +9 -1
- snowflake/ml/modeling/cluster/affinity_propagation.py +9 -1
- snowflake/ml/modeling/cluster/agglomerative_clustering.py +9 -1
- snowflake/ml/modeling/cluster/birch.py +9 -1
- snowflake/ml/modeling/cluster/bisecting_k_means.py +9 -1
- snowflake/ml/modeling/cluster/dbscan.py +9 -1
- snowflake/ml/modeling/cluster/feature_agglomeration.py +9 -1
- snowflake/ml/modeling/cluster/k_means.py +9 -1
- snowflake/ml/modeling/cluster/mean_shift.py +9 -1
- snowflake/ml/modeling/cluster/mini_batch_k_means.py +9 -1
- snowflake/ml/modeling/cluster/optics.py +9 -1
- snowflake/ml/modeling/cluster/spectral_biclustering.py +9 -1
- snowflake/ml/modeling/cluster/spectral_clustering.py +9 -1
- snowflake/ml/modeling/cluster/spectral_coclustering.py +9 -1
- snowflake/ml/modeling/compose/column_transformer.py +9 -1
- snowflake/ml/modeling/compose/transformed_target_regressor.py +9 -1
- snowflake/ml/modeling/covariance/elliptic_envelope.py +9 -1
- snowflake/ml/modeling/covariance/empirical_covariance.py +9 -1
- snowflake/ml/modeling/covariance/graphical_lasso.py +9 -1
- snowflake/ml/modeling/covariance/graphical_lasso_cv.py +9 -1
- snowflake/ml/modeling/covariance/ledoit_wolf.py +9 -1
- snowflake/ml/modeling/covariance/min_cov_det.py +9 -1
- snowflake/ml/modeling/covariance/oas.py +9 -1
- snowflake/ml/modeling/covariance/shrunk_covariance.py +9 -1
- snowflake/ml/modeling/decomposition/dictionary_learning.py +9 -1
- snowflake/ml/modeling/decomposition/factor_analysis.py +9 -1
- snowflake/ml/modeling/decomposition/fast_ica.py +9 -1
- snowflake/ml/modeling/decomposition/incremental_pca.py +9 -1
- snowflake/ml/modeling/decomposition/kernel_pca.py +9 -1
- snowflake/ml/modeling/decomposition/mini_batch_dictionary_learning.py +9 -1
- snowflake/ml/modeling/decomposition/mini_batch_sparse_pca.py +9 -1
- snowflake/ml/modeling/decomposition/pca.py +9 -1
- snowflake/ml/modeling/decomposition/sparse_pca.py +9 -1
- snowflake/ml/modeling/decomposition/truncated_svd.py +9 -1
- snowflake/ml/modeling/discriminant_analysis/linear_discriminant_analysis.py +9 -1
- snowflake/ml/modeling/discriminant_analysis/quadratic_discriminant_analysis.py +9 -1
- snowflake/ml/modeling/ensemble/ada_boost_classifier.py +9 -1
- snowflake/ml/modeling/ensemble/ada_boost_regressor.py +9 -1
- snowflake/ml/modeling/ensemble/bagging_classifier.py +9 -1
- snowflake/ml/modeling/ensemble/bagging_regressor.py +9 -1
- snowflake/ml/modeling/ensemble/extra_trees_classifier.py +9 -1
- snowflake/ml/modeling/ensemble/extra_trees_regressor.py +9 -1
- snowflake/ml/modeling/ensemble/gradient_boosting_classifier.py +9 -1
- snowflake/ml/modeling/ensemble/gradient_boosting_regressor.py +9 -1
- snowflake/ml/modeling/ensemble/hist_gradient_boosting_classifier.py +9 -1
- snowflake/ml/modeling/ensemble/hist_gradient_boosting_regressor.py +9 -1
- snowflake/ml/modeling/ensemble/isolation_forest.py +9 -1
- snowflake/ml/modeling/ensemble/random_forest_classifier.py +9 -1
- snowflake/ml/modeling/ensemble/random_forest_regressor.py +9 -1
- snowflake/ml/modeling/ensemble/stacking_regressor.py +9 -1
- snowflake/ml/modeling/ensemble/voting_classifier.py +9 -1
- snowflake/ml/modeling/ensemble/voting_regressor.py +9 -1
- snowflake/ml/modeling/feature_selection/generic_univariate_select.py +9 -1
- snowflake/ml/modeling/feature_selection/select_fdr.py +9 -1
- snowflake/ml/modeling/feature_selection/select_fpr.py +9 -1
- snowflake/ml/modeling/feature_selection/select_fwe.py +9 -1
- snowflake/ml/modeling/feature_selection/select_k_best.py +9 -1
- snowflake/ml/modeling/feature_selection/select_percentile.py +9 -1
- snowflake/ml/modeling/feature_selection/sequential_feature_selector.py +9 -1
- snowflake/ml/modeling/feature_selection/variance_threshold.py +9 -1
- snowflake/ml/modeling/framework/_utils.py +10 -10
- snowflake/ml/modeling/framework/base.py +32 -32
- snowflake/ml/modeling/gaussian_process/gaussian_process_classifier.py +9 -1
- snowflake/ml/modeling/gaussian_process/gaussian_process_regressor.py +9 -1
- snowflake/ml/modeling/impute/__init__.py +1 -1
- snowflake/ml/modeling/impute/iterative_imputer.py +9 -1
- snowflake/ml/modeling/impute/knn_imputer.py +9 -1
- snowflake/ml/modeling/impute/missing_indicator.py +9 -1
- snowflake/ml/modeling/impute/simple_imputer.py +5 -5
- snowflake/ml/modeling/kernel_approximation/additive_chi2_sampler.py +9 -1
- snowflake/ml/modeling/kernel_approximation/nystroem.py +9 -1
- snowflake/ml/modeling/kernel_approximation/polynomial_count_sketch.py +9 -1
- snowflake/ml/modeling/kernel_approximation/rbf_sampler.py +9 -1
- snowflake/ml/modeling/kernel_approximation/skewed_chi2_sampler.py +9 -1
- snowflake/ml/modeling/kernel_ridge/kernel_ridge.py +9 -1
- snowflake/ml/modeling/lightgbm/lgbm_classifier.py +9 -1
- snowflake/ml/modeling/lightgbm/lgbm_regressor.py +9 -1
- snowflake/ml/modeling/linear_model/ard_regression.py +9 -1
- snowflake/ml/modeling/linear_model/bayesian_ridge.py +9 -1
- snowflake/ml/modeling/linear_model/elastic_net.py +9 -1
- snowflake/ml/modeling/linear_model/elastic_net_cv.py +9 -1
- snowflake/ml/modeling/linear_model/gamma_regressor.py +9 -1
- snowflake/ml/modeling/linear_model/huber_regressor.py +9 -1
- snowflake/ml/modeling/linear_model/lars.py +9 -1
- snowflake/ml/modeling/linear_model/lars_cv.py +9 -1
- snowflake/ml/modeling/linear_model/lasso.py +9 -1
- snowflake/ml/modeling/linear_model/lasso_cv.py +9 -1
- snowflake/ml/modeling/linear_model/lasso_lars.py +9 -1
- snowflake/ml/modeling/linear_model/lasso_lars_cv.py +9 -1
- snowflake/ml/modeling/linear_model/lasso_lars_ic.py +9 -1
- snowflake/ml/modeling/linear_model/linear_regression.py +9 -1
- snowflake/ml/modeling/linear_model/logistic_regression.py +9 -1
- snowflake/ml/modeling/linear_model/logistic_regression_cv.py +9 -1
- snowflake/ml/modeling/linear_model/multi_task_elastic_net.py +9 -1
- snowflake/ml/modeling/linear_model/multi_task_elastic_net_cv.py +9 -1
- snowflake/ml/modeling/linear_model/multi_task_lasso.py +9 -1
- snowflake/ml/modeling/linear_model/multi_task_lasso_cv.py +9 -1
- snowflake/ml/modeling/linear_model/orthogonal_matching_pursuit.py +9 -1
- snowflake/ml/modeling/linear_model/passive_aggressive_classifier.py +9 -1
- snowflake/ml/modeling/linear_model/passive_aggressive_regressor.py +9 -1
- snowflake/ml/modeling/linear_model/perceptron.py +9 -1
- snowflake/ml/modeling/linear_model/poisson_regressor.py +9 -1
- snowflake/ml/modeling/linear_model/ransac_regressor.py +9 -1
- snowflake/ml/modeling/linear_model/ridge.py +9 -1
- snowflake/ml/modeling/linear_model/ridge_classifier.py +9 -1
- snowflake/ml/modeling/linear_model/ridge_classifier_cv.py +9 -1
- snowflake/ml/modeling/linear_model/ridge_cv.py +9 -1
- snowflake/ml/modeling/linear_model/sgd_classifier.py +9 -1
- snowflake/ml/modeling/linear_model/sgd_one_class_svm.py +9 -1
- snowflake/ml/modeling/linear_model/sgd_regressor.py +9 -1
- snowflake/ml/modeling/linear_model/theil_sen_regressor.py +9 -1
- snowflake/ml/modeling/linear_model/tweedie_regressor.py +9 -1
- snowflake/ml/modeling/manifold/isomap.py +9 -1
- snowflake/ml/modeling/manifold/mds.py +9 -1
- snowflake/ml/modeling/manifold/spectral_embedding.py +9 -1
- snowflake/ml/modeling/manifold/tsne.py +9 -1
- snowflake/ml/modeling/metrics/__init__.py +1 -1
- snowflake/ml/modeling/metrics/classification.py +39 -39
- snowflake/ml/modeling/metrics/metrics_utils.py +12 -12
- snowflake/ml/modeling/metrics/ranking.py +7 -7
- snowflake/ml/modeling/metrics/regression.py +13 -13
- snowflake/ml/modeling/mixture/bayesian_gaussian_mixture.py +9 -1
- snowflake/ml/modeling/mixture/gaussian_mixture.py +9 -1
- snowflake/ml/modeling/model_selection/__init__.py +1 -1
- snowflake/ml/modeling/model_selection/grid_search_cv.py +7 -7
- snowflake/ml/modeling/model_selection/randomized_search_cv.py +7 -7
- snowflake/ml/modeling/multiclass/one_vs_one_classifier.py +9 -1
- snowflake/ml/modeling/multiclass/one_vs_rest_classifier.py +9 -1
- snowflake/ml/modeling/multiclass/output_code_classifier.py +9 -1
- snowflake/ml/modeling/naive_bayes/bernoulli_nb.py +9 -1
- snowflake/ml/modeling/naive_bayes/categorical_nb.py +9 -1
- snowflake/ml/modeling/naive_bayes/complement_nb.py +9 -1
- snowflake/ml/modeling/naive_bayes/gaussian_nb.py +9 -1
- snowflake/ml/modeling/naive_bayes/multinomial_nb.py +9 -1
- snowflake/ml/modeling/neighbors/k_neighbors_classifier.py +9 -1
- snowflake/ml/modeling/neighbors/k_neighbors_regressor.py +9 -1
- snowflake/ml/modeling/neighbors/kernel_density.py +9 -1
- snowflake/ml/modeling/neighbors/local_outlier_factor.py +9 -1
- snowflake/ml/modeling/neighbors/nearest_centroid.py +9 -1
- snowflake/ml/modeling/neighbors/nearest_neighbors.py +9 -1
- snowflake/ml/modeling/neighbors/neighborhood_components_analysis.py +9 -1
- snowflake/ml/modeling/neighbors/radius_neighbors_classifier.py +9 -1
- snowflake/ml/modeling/neighbors/radius_neighbors_regressor.py +9 -1
- snowflake/ml/modeling/neural_network/bernoulli_rbm.py +9 -1
- snowflake/ml/modeling/neural_network/mlp_classifier.py +9 -1
- snowflake/ml/modeling/neural_network/mlp_regressor.py +9 -1
- snowflake/ml/modeling/pipeline/__init__.py +1 -1
- snowflake/ml/modeling/pipeline/pipeline.py +18 -18
- snowflake/ml/modeling/preprocessing/__init__.py +1 -1
- snowflake/ml/modeling/preprocessing/k_bins_discretizer.py +13 -13
- snowflake/ml/modeling/preprocessing/max_abs_scaler.py +4 -4
- snowflake/ml/modeling/preprocessing/min_max_scaler.py +8 -8
- snowflake/ml/modeling/preprocessing/normalizer.py +0 -1
- snowflake/ml/modeling/preprocessing/one_hot_encoder.py +28 -28
- snowflake/ml/modeling/preprocessing/ordinal_encoder.py +9 -9
- snowflake/ml/modeling/preprocessing/polynomial_features.py +9 -1
- snowflake/ml/modeling/preprocessing/robust_scaler.py +7 -7
- snowflake/ml/modeling/preprocessing/standard_scaler.py +5 -5
- snowflake/ml/modeling/semi_supervised/label_propagation.py +9 -1
- snowflake/ml/modeling/semi_supervised/label_spreading.py +9 -1
- snowflake/ml/modeling/svm/linear_svc.py +9 -1
- snowflake/ml/modeling/svm/linear_svr.py +9 -1
- snowflake/ml/modeling/svm/nu_svc.py +9 -1
- snowflake/ml/modeling/svm/nu_svr.py +9 -1
- snowflake/ml/modeling/svm/svc.py +9 -1
- snowflake/ml/modeling/svm/svr.py +9 -1
- snowflake/ml/modeling/tree/decision_tree_classifier.py +9 -1
- snowflake/ml/modeling/tree/decision_tree_regressor.py +9 -1
- snowflake/ml/modeling/tree/extra_tree_classifier.py +9 -1
- snowflake/ml/modeling/tree/extra_tree_regressor.py +9 -1
- snowflake/ml/modeling/xgboost/xgb_classifier.py +9 -1
- snowflake/ml/modeling/xgboost/xgb_regressor.py +9 -1
- snowflake/ml/modeling/xgboost/xgbrf_classifier.py +9 -1
- snowflake/ml/modeling/xgboost/xgbrf_regressor.py +9 -1
- snowflake/ml/monitoring/_client/model_monitor_sql_client.py +26 -26
- snowflake/ml/monitoring/_manager/model_monitor_manager.py +5 -5
- snowflake/ml/monitoring/entities/model_monitor_config.py +6 -6
- snowflake/ml/monitoring/explain_visualize.py +286 -0
- snowflake/ml/registry/_manager/model_manager.py +55 -32
- snowflake/ml/registry/registry.py +39 -31
- snowflake/ml/utils/authentication.py +2 -2
- snowflake/ml/utils/connection_params.py +5 -5
- snowflake/ml/utils/sparse.py +5 -4
- snowflake/ml/utils/sql_client.py +1 -2
- snowflake/ml/version.py +2 -1
- {snowflake_ml_python-1.8.2.dist-info → snowflake_ml_python-1.8.4.dist-info}/METADATA +55 -14
- snowflake_ml_python-1.8.4.dist-info/RECORD +419 -0
- {snowflake_ml_python-1.8.2.dist-info → snowflake_ml_python-1.8.4.dist-info}/WHEEL +1 -1
- snowflake/ml/model/_packager/model_meta/_packaging_requirements.py +0 -1
- snowflake/ml/modeling/_internal/constants.py +0 -2
- snowflake_ml_python-1.8.2.dist-info/RECORD +0 -420
- {snowflake_ml_python-1.8.2.dist-info → snowflake_ml_python-1.8.4.dist-info}/licenses/LICENSE.txt +0 -0
- {snowflake_ml_python-1.8.2.dist-info → snowflake_ml_python-1.8.4.dist-info}/top_level.txt +0 -0
@@ -1,5 +1,6 @@
|
|
1
|
+
import json
|
1
2
|
import pathlib
|
2
|
-
from typing import
|
3
|
+
from typing import Any, Optional, Union
|
3
4
|
|
4
5
|
import yaml
|
5
6
|
|
@@ -18,99 +19,392 @@ class ModelDeploymentSpec:
|
|
18
19
|
|
19
20
|
def __init__(self, workspace_path: Optional[pathlib.Path] = None) -> None:
|
20
21
|
self.workspace_path = workspace_path
|
22
|
+
self._models: list[model_deployment_spec_schema.Model] = []
|
23
|
+
self._image_build: Optional[model_deployment_spec_schema.ImageBuild] = None
|
24
|
+
self._service: Optional[model_deployment_spec_schema.Service] = None
|
25
|
+
self._job: Optional[model_deployment_spec_schema.Job] = None
|
26
|
+
self._model_loggings: Optional[list[model_deployment_spec_schema.ModelLogging]] = None
|
27
|
+
self._inference_spec: dict[str, Any] = {} # Common inference spec for service/job
|
21
28
|
|
22
|
-
|
29
|
+
self.database: Optional[sql_identifier.SqlIdentifier] = None
|
30
|
+
self.schema: Optional[sql_identifier.SqlIdentifier] = None
|
31
|
+
|
32
|
+
def add_model_spec(
|
23
33
|
self,
|
24
|
-
*,
|
25
34
|
database_name: sql_identifier.SqlIdentifier,
|
26
35
|
schema_name: sql_identifier.SqlIdentifier,
|
27
36
|
model_name: sql_identifier.SqlIdentifier,
|
28
37
|
version_name: sql_identifier.SqlIdentifier,
|
29
|
-
|
30
|
-
|
31
|
-
|
38
|
+
) -> "ModelDeploymentSpec":
|
39
|
+
"""Add model specification to the deployment spec.
|
40
|
+
|
41
|
+
Args:
|
42
|
+
database_name: Database name containing the model.
|
43
|
+
schema_name: Schema name containing the model.
|
44
|
+
model_name: Name of the model.
|
45
|
+
version_name: Version of the model.
|
46
|
+
|
47
|
+
Returns:
|
48
|
+
Self for chaining.
|
49
|
+
"""
|
50
|
+
fq_model_name = identifier.get_schema_level_object_identifier(
|
51
|
+
database_name.identifier(), schema_name.identifier(), model_name.identifier()
|
52
|
+
)
|
53
|
+
if not self.database:
|
54
|
+
self.database = database_name
|
55
|
+
if not self.schema:
|
56
|
+
self.schema = schema_name
|
57
|
+
model = model_deployment_spec_schema.Model(name=fq_model_name, version=version_name.identifier())
|
58
|
+
self._models.append(model)
|
59
|
+
return self
|
60
|
+
|
61
|
+
def add_image_build_spec(
|
62
|
+
self,
|
32
63
|
image_build_compute_pool_name: sql_identifier.SqlIdentifier,
|
33
|
-
service_compute_pool_name: sql_identifier.SqlIdentifier,
|
34
|
-
image_repo_database_name: Optional[sql_identifier.SqlIdentifier],
|
35
|
-
image_repo_schema_name: Optional[sql_identifier.SqlIdentifier],
|
36
64
|
image_repo_name: sql_identifier.SqlIdentifier,
|
37
|
-
|
38
|
-
|
65
|
+
image_repo_database_name: Optional[sql_identifier.SqlIdentifier] = None,
|
66
|
+
image_repo_schema_name: Optional[sql_identifier.SqlIdentifier] = None,
|
67
|
+
force_rebuild: bool = False,
|
68
|
+
external_access_integrations: Optional[list[sql_identifier.SqlIdentifier]] = None,
|
69
|
+
) -> "ModelDeploymentSpec":
|
70
|
+
"""Add image build specification to the deployment spec.
|
71
|
+
|
72
|
+
Args:
|
73
|
+
image_build_compute_pool_name: Compute pool for image building.
|
74
|
+
image_repo_name: Name of the image repository.
|
75
|
+
image_repo_database_name: Database name for the image repository.
|
76
|
+
image_repo_schema_name: Schema name for the image repository.
|
77
|
+
force_rebuild: Whether to force rebuilding the image.
|
78
|
+
external_access_integrations: List of external access integrations.
|
79
|
+
|
80
|
+
Returns:
|
81
|
+
Self for chaining.
|
82
|
+
"""
|
83
|
+
saved_image_repo_database = image_repo_database_name or self.database
|
84
|
+
saved_image_repo_schema = image_repo_schema_name or self.schema
|
85
|
+
assert saved_image_repo_database is not None
|
86
|
+
assert saved_image_repo_schema is not None
|
87
|
+
fq_image_repo_name = identifier.get_schema_level_object_identifier(
|
88
|
+
db=saved_image_repo_database.identifier(),
|
89
|
+
schema=saved_image_repo_schema.identifier(),
|
90
|
+
object_name=image_repo_name.identifier(),
|
91
|
+
)
|
92
|
+
|
93
|
+
self._image_build = model_deployment_spec_schema.ImageBuild(
|
94
|
+
compute_pool=image_build_compute_pool_name.identifier(),
|
95
|
+
image_repo=fq_image_repo_name,
|
96
|
+
force_rebuild=force_rebuild,
|
97
|
+
external_access_integrations=(
|
98
|
+
[eai.identifier() for eai in external_access_integrations] if external_access_integrations else None
|
99
|
+
),
|
100
|
+
)
|
101
|
+
return self
|
102
|
+
|
103
|
+
def _add_inference_spec(
|
104
|
+
self,
|
39
105
|
cpu: Optional[str],
|
40
106
|
memory: Optional[str],
|
41
107
|
gpu: Optional[Union[str, int]],
|
42
108
|
num_workers: Optional[int],
|
43
109
|
max_batch_rows: Optional[int],
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
110
|
+
) -> None:
|
111
|
+
"""Internal helper to store common inference specs."""
|
112
|
+
if cpu:
|
113
|
+
self._inference_spec["cpu"] = cpu
|
114
|
+
if memory:
|
115
|
+
self._inference_spec["memory"] = memory
|
116
|
+
if gpu:
|
117
|
+
if isinstance(gpu, int):
|
118
|
+
gpu_str = str(gpu)
|
119
|
+
else:
|
120
|
+
gpu_str = gpu
|
121
|
+
self._inference_spec["gpu"] = gpu_str
|
122
|
+
if num_workers:
|
123
|
+
self._inference_spec["num_workers"] = num_workers
|
124
|
+
if max_batch_rows:
|
125
|
+
self._inference_spec["max_batch_rows"] = max_batch_rows
|
53
126
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
127
|
+
def add_service_spec(
|
128
|
+
self,
|
129
|
+
service_name: sql_identifier.SqlIdentifier,
|
130
|
+
inference_compute_pool_name: sql_identifier.SqlIdentifier,
|
131
|
+
service_database_name: Optional[sql_identifier.SqlIdentifier] = None,
|
132
|
+
service_schema_name: Optional[sql_identifier.SqlIdentifier] = None,
|
133
|
+
ingress_enabled: bool = True,
|
134
|
+
max_instances: int = 1,
|
135
|
+
cpu: Optional[str] = None,
|
136
|
+
memory: Optional[str] = None,
|
137
|
+
gpu: Optional[Union[str, int]] = None,
|
138
|
+
num_workers: Optional[int] = None,
|
139
|
+
max_batch_rows: Optional[int] = None,
|
140
|
+
) -> "ModelDeploymentSpec":
|
141
|
+
"""Add service specification to the deployment spec.
|
142
|
+
|
143
|
+
Args:
|
144
|
+
service_name: Name of the service.
|
145
|
+
inference_compute_pool_name: Compute pool for inference.
|
146
|
+
service_database_name: Database name for the service.
|
147
|
+
service_schema_name: Schema name for the service.
|
148
|
+
ingress_enabled: Whether ingress is enabled.
|
149
|
+
max_instances: Maximum number of service instances.
|
150
|
+
cpu: CPU requirement.
|
151
|
+
memory: Memory requirement.
|
152
|
+
gpu: GPU requirement.
|
153
|
+
num_workers: Number of workers.
|
154
|
+
max_batch_rows: Maximum batch rows for inference.
|
155
|
+
|
156
|
+
Raises:
|
157
|
+
ValueError: If a job spec already exists.
|
158
|
+
|
159
|
+
Returns:
|
160
|
+
Self for chaining.
|
161
|
+
"""
|
162
|
+
if self._job:
|
163
|
+
raise ValueError("Cannot add a service spec when a job spec already exists.")
|
164
|
+
|
165
|
+
saved_service_database = service_database_name or self.database
|
166
|
+
saved_service_schema = service_schema_name or self.schema
|
167
|
+
assert saved_service_database is not None
|
168
|
+
assert saved_service_schema is not None
|
73
169
|
fq_service_name = identifier.get_schema_level_object_identifier(
|
74
170
|
saved_service_database.identifier(), saved_service_schema.identifier(), service_name.identifier()
|
75
171
|
)
|
76
|
-
|
172
|
+
|
173
|
+
self._add_inference_spec(cpu, memory, gpu, num_workers, max_batch_rows)
|
174
|
+
|
175
|
+
self._service = model_deployment_spec_schema.Service(
|
77
176
|
name=fq_service_name,
|
78
|
-
compute_pool=
|
177
|
+
compute_pool=inference_compute_pool_name.identifier(),
|
79
178
|
ingress_enabled=ingress_enabled,
|
80
179
|
max_instances=max_instances,
|
180
|
+
**self._inference_spec,
|
81
181
|
)
|
82
|
-
|
83
|
-
service_dict["cpu"] = cpu
|
182
|
+
return self
|
84
183
|
|
85
|
-
|
86
|
-
|
184
|
+
def add_job_spec(
|
185
|
+
self,
|
186
|
+
job_name: sql_identifier.SqlIdentifier,
|
187
|
+
inference_compute_pool_name: sql_identifier.SqlIdentifier,
|
188
|
+
warehouse: sql_identifier.SqlIdentifier,
|
189
|
+
target_method: str,
|
190
|
+
input_table_name: sql_identifier.SqlIdentifier,
|
191
|
+
output_table_name: sql_identifier.SqlIdentifier,
|
192
|
+
job_database_name: Optional[sql_identifier.SqlIdentifier] = None,
|
193
|
+
job_schema_name: Optional[sql_identifier.SqlIdentifier] = None,
|
194
|
+
input_table_database_name: Optional[sql_identifier.SqlIdentifier] = None,
|
195
|
+
input_table_schema_name: Optional[sql_identifier.SqlIdentifier] = None,
|
196
|
+
output_table_database_name: Optional[sql_identifier.SqlIdentifier] = None,
|
197
|
+
output_table_schema_name: Optional[sql_identifier.SqlIdentifier] = None,
|
198
|
+
cpu: Optional[str] = None,
|
199
|
+
memory: Optional[str] = None,
|
200
|
+
gpu: Optional[Union[str, int]] = None,
|
201
|
+
num_workers: Optional[int] = None,
|
202
|
+
max_batch_rows: Optional[int] = None,
|
203
|
+
) -> "ModelDeploymentSpec":
|
204
|
+
"""Add job specification to the deployment spec.
|
87
205
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
206
|
+
Args:
|
207
|
+
job_name: Name of the job.
|
208
|
+
inference_compute_pool_name: Compute pool for inference.
|
209
|
+
job_database_name: Database name for the job.
|
210
|
+
job_schema_name: Schema name for the job.
|
211
|
+
warehouse: Warehouse for the job.
|
212
|
+
target_method: Target method for inference.
|
213
|
+
input_table_name: Input table name.
|
214
|
+
output_table_name: Output table name.
|
215
|
+
input_table_database_name: Database for input table.
|
216
|
+
input_table_schema_name: Schema for input table.
|
217
|
+
output_table_database_name: Database for output table.
|
218
|
+
output_table_schema_name: Schema for output table.
|
219
|
+
cpu: CPU requirement.
|
220
|
+
memory: Memory requirement.
|
221
|
+
gpu: GPU requirement.
|
222
|
+
num_workers: Number of workers.
|
223
|
+
max_batch_rows: Maximum batch rows for inference.
|
94
224
|
|
95
|
-
|
96
|
-
|
225
|
+
Raises:
|
226
|
+
ValueError: If a service spec already exists.
|
97
227
|
|
98
|
-
|
99
|
-
|
228
|
+
Returns:
|
229
|
+
Self for chaining.
|
230
|
+
"""
|
231
|
+
if self._service:
|
232
|
+
raise ValueError("Cannot add a job spec when a service spec already exists.")
|
233
|
+
|
234
|
+
saved_job_database = job_database_name or self.database
|
235
|
+
saved_job_schema = job_schema_name or self.schema
|
236
|
+
input_table_database_name = input_table_database_name or self.database
|
237
|
+
input_table_schema_name = input_table_schema_name or self.schema
|
238
|
+
output_table_database_name = output_table_database_name or self.database
|
239
|
+
output_table_schema_name = output_table_schema_name or self.schema
|
100
240
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
241
|
+
assert saved_job_database is not None
|
242
|
+
assert saved_job_schema is not None
|
243
|
+
assert input_table_database_name is not None
|
244
|
+
assert input_table_schema_name is not None
|
245
|
+
assert output_table_database_name is not None
|
246
|
+
assert output_table_schema_name is not None
|
247
|
+
|
248
|
+
fq_job_name = identifier.get_schema_level_object_identifier(
|
249
|
+
saved_job_database.identifier(), saved_job_schema.identifier(), job_name.identifier()
|
250
|
+
)
|
251
|
+
fq_input_table_name = identifier.get_schema_level_object_identifier(
|
252
|
+
input_table_database_name.identifier(),
|
253
|
+
input_table_schema_name.identifier(),
|
254
|
+
input_table_name.identifier(),
|
106
255
|
)
|
256
|
+
fq_output_table_name = identifier.get_schema_level_object_identifier(
|
257
|
+
output_table_database_name.identifier(),
|
258
|
+
output_table_schema_name.identifier(),
|
259
|
+
output_table_name.identifier(),
|
260
|
+
)
|
261
|
+
|
262
|
+
self._add_inference_spec(cpu, memory, gpu, num_workers, max_batch_rows)
|
263
|
+
|
264
|
+
self._job = model_deployment_spec_schema.Job(
|
265
|
+
name=fq_job_name,
|
266
|
+
compute_pool=inference_compute_pool_name.identifier(),
|
267
|
+
warehouse=warehouse.identifier(),
|
268
|
+
target_method=target_method,
|
269
|
+
input_table_name=fq_input_table_name,
|
270
|
+
output_table_name=fq_output_table_name,
|
271
|
+
**self._inference_spec,
|
272
|
+
)
|
273
|
+
return self
|
274
|
+
|
275
|
+
def add_hf_logger_spec(
|
276
|
+
self,
|
277
|
+
hf_model_name: str,
|
278
|
+
hf_task: Optional[str] = None,
|
279
|
+
hf_token: Optional[str] = None,
|
280
|
+
hf_tokenizer: Optional[str] = None,
|
281
|
+
hf_revision: Optional[str] = None,
|
282
|
+
hf_trust_remote_code: Optional[bool] = False,
|
283
|
+
pip_requirements: Optional[list[str]] = None,
|
284
|
+
conda_dependencies: Optional[list[str]] = None,
|
285
|
+
target_platforms: Optional[list[str]] = None,
|
286
|
+
comment: Optional[str] = None,
|
287
|
+
warehouse: Optional[str] = None,
|
288
|
+
**kwargs: Any,
|
289
|
+
) -> "ModelDeploymentSpec":
|
290
|
+
"""Add Hugging Face logger specification.
|
291
|
+
|
292
|
+
Args:
|
293
|
+
hf_model_name: Hugging Face model name.
|
294
|
+
hf_task: Hugging Face task.
|
295
|
+
hf_token: Hugging Face token.
|
296
|
+
hf_tokenizer: Hugging Face tokenizer.
|
297
|
+
hf_revision: Hugging Face model revision.
|
298
|
+
hf_trust_remote_code: Whether to trust remote code.
|
299
|
+
pip_requirements: List of pip requirements.
|
300
|
+
conda_dependencies: List of conda dependencies.
|
301
|
+
target_platforms: List of target platforms.
|
302
|
+
comment: Comment for the model.
|
303
|
+
warehouse: Warehouse used to log the model.
|
304
|
+
**kwargs: Additional Hugging Face model arguments.
|
305
|
+
|
306
|
+
Raises:
|
307
|
+
ValueError: If Hugging Face model name is missing when other HF parameters are provided.
|
308
|
+
|
309
|
+
Returns:
|
310
|
+
Self for chaining.
|
311
|
+
"""
|
312
|
+
# Validation moved here from save
|
313
|
+
if (
|
314
|
+
any(
|
315
|
+
[
|
316
|
+
hf_task,
|
317
|
+
hf_token,
|
318
|
+
hf_tokenizer,
|
319
|
+
hf_revision,
|
320
|
+
hf_trust_remote_code,
|
321
|
+
pip_requirements,
|
322
|
+
]
|
323
|
+
)
|
324
|
+
and not hf_model_name
|
325
|
+
):
|
326
|
+
# This condition might be redundant now as hf_model_name is mandatory
|
327
|
+
raise ValueError("Hugging Face model name is required when using Hugging Face model deployment.")
|
328
|
+
|
329
|
+
log_model_args = model_deployment_spec_schema.LogModelArgs(
|
330
|
+
pip_requirements=pip_requirements,
|
331
|
+
conda_dependencies=conda_dependencies,
|
332
|
+
target_platforms=target_platforms,
|
333
|
+
comment=comment,
|
334
|
+
warehouse=warehouse,
|
335
|
+
)
|
336
|
+
hf_model = model_deployment_spec_schema.HuggingFaceModel(
|
337
|
+
hf_model_name=hf_model_name,
|
338
|
+
task=hf_task,
|
339
|
+
hf_token=hf_token,
|
340
|
+
tokenizer=hf_tokenizer,
|
341
|
+
trust_remote_code=hf_trust_remote_code,
|
342
|
+
revision=hf_revision,
|
343
|
+
hf_model_kwargs=json.dumps(kwargs),
|
344
|
+
)
|
345
|
+
model_logging = model_deployment_spec_schema.ModelLogging(
|
346
|
+
log_model_args=log_model_args,
|
347
|
+
hf_model=hf_model,
|
348
|
+
)
|
349
|
+
if self._model_loggings is None:
|
350
|
+
self._model_loggings = [model_logging]
|
351
|
+
else:
|
352
|
+
self._model_loggings.append(model_logging)
|
353
|
+
return self
|
354
|
+
|
355
|
+
def save(self) -> str:
|
356
|
+
"""Constructs the final deployment spec from added components and saves it.
|
357
|
+
|
358
|
+
Raises:
|
359
|
+
ValueError: If required components are missing or conflicting specs are added.
|
360
|
+
RuntimeError: If no service or job spec is found despite validation.
|
361
|
+
|
362
|
+
Returns:
|
363
|
+
The path to the saved YAML file as a string, or the YAML content as a string
|
364
|
+
if workspace_path was not provided.
|
365
|
+
"""
|
366
|
+
# Validations
|
367
|
+
if not self._models:
|
368
|
+
raise ValueError("Model specification is required. Call add_model_spec().")
|
369
|
+
if not self._image_build:
|
370
|
+
raise ValueError("Image build specification is required. Call add_image_build_spec().")
|
371
|
+
if not self._service and not self._job:
|
372
|
+
raise ValueError(
|
373
|
+
"Either service or job specification is required. Call add_service_spec() or add_job_spec()."
|
374
|
+
)
|
375
|
+
if self._service and self._job:
|
376
|
+
# This case should be prevented by checks in add_service_spec/add_job_spec, but double-check
|
377
|
+
raise ValueError("Cannot have both service and job specifications.")
|
378
|
+
|
379
|
+
# Construct the final spec object
|
380
|
+
if self._service:
|
381
|
+
model_deployment_spec: Union[
|
382
|
+
model_deployment_spec_schema.ModelServiceDeploymentSpec,
|
383
|
+
model_deployment_spec_schema.ModelJobDeploymentSpec,
|
384
|
+
] = model_deployment_spec_schema.ModelServiceDeploymentSpec(
|
385
|
+
models=self._models,
|
386
|
+
image_build=self._image_build,
|
387
|
+
service=self._service,
|
388
|
+
model_loggings=self._model_loggings,
|
389
|
+
)
|
390
|
+
elif self._job:
|
391
|
+
model_deployment_spec = model_deployment_spec_schema.ModelJobDeploymentSpec(
|
392
|
+
models=self._models,
|
393
|
+
image_build=self._image_build,
|
394
|
+
job=self._job,
|
395
|
+
model_loggings=self._model_loggings,
|
396
|
+
)
|
397
|
+
else:
|
398
|
+
# Should not happen due to earlier validation
|
399
|
+
raise RuntimeError("Internal error: No service or job spec found despite validation.")
|
400
|
+
|
401
|
+
# Serialize and save/return
|
402
|
+
yaml_content = model_deployment_spec.model_dump(exclude_none=True)
|
107
403
|
|
108
|
-
# Anchors are not supported in the server, avoid that.
|
109
|
-
yaml.SafeDumper.ignore_aliases = lambda *args: True # type: ignore[method-assign]
|
110
404
|
if self.workspace_path is None:
|
111
|
-
return yaml.safe_dump(
|
112
|
-
|
405
|
+
return yaml.safe_dump(yaml_content)
|
406
|
+
|
113
407
|
file_path = self.workspace_path / self.DEPLOY_SPEC_FILE_REL_PATH
|
114
408
|
with file_path.open("w", encoding="utf-8") as f:
|
115
|
-
yaml.safe_dump(
|
409
|
+
yaml.safe_dump(yaml_content, f)
|
116
410
|
return str(file_path.resolve())
|
@@ -1,33 +1,78 @@
|
|
1
|
-
from typing import
|
1
|
+
from typing import Optional
|
2
2
|
|
3
|
-
from
|
3
|
+
from pydantic import BaseModel
|
4
4
|
|
5
5
|
|
6
|
-
class
|
7
|
-
name:
|
8
|
-
version:
|
6
|
+
class Model(BaseModel):
|
7
|
+
name: str
|
8
|
+
version: str
|
9
9
|
|
10
10
|
|
11
|
-
class
|
12
|
-
compute_pool:
|
13
|
-
image_repo:
|
14
|
-
force_rebuild:
|
15
|
-
external_access_integrations:
|
11
|
+
class ImageBuild(BaseModel):
|
12
|
+
compute_pool: str
|
13
|
+
image_repo: str
|
14
|
+
force_rebuild: bool
|
15
|
+
external_access_integrations: Optional[list[str]] = None
|
16
16
|
|
17
17
|
|
18
|
-
class
|
19
|
-
name:
|
20
|
-
compute_pool:
|
21
|
-
ingress_enabled:
|
22
|
-
max_instances:
|
23
|
-
cpu:
|
24
|
-
memory:
|
25
|
-
gpu:
|
26
|
-
num_workers:
|
27
|
-
max_batch_rows:
|
18
|
+
class Service(BaseModel):
|
19
|
+
name: str
|
20
|
+
compute_pool: str
|
21
|
+
ingress_enabled: bool
|
22
|
+
max_instances: int
|
23
|
+
cpu: Optional[str] = None
|
24
|
+
memory: Optional[str] = None
|
25
|
+
gpu: Optional[str] = None
|
26
|
+
num_workers: Optional[int] = None
|
27
|
+
max_batch_rows: Optional[int] = None
|
28
28
|
|
29
29
|
|
30
|
-
class
|
31
|
-
|
32
|
-
|
33
|
-
|
30
|
+
class Job(BaseModel):
|
31
|
+
name: str
|
32
|
+
compute_pool: str
|
33
|
+
cpu: Optional[str] = None
|
34
|
+
memory: Optional[str] = None
|
35
|
+
gpu: Optional[str] = None
|
36
|
+
num_workers: Optional[int] = None
|
37
|
+
max_batch_rows: Optional[int] = None
|
38
|
+
warehouse: str
|
39
|
+
target_method: str
|
40
|
+
input_table_name: str
|
41
|
+
output_table_name: str
|
42
|
+
|
43
|
+
|
44
|
+
class LogModelArgs(BaseModel):
|
45
|
+
pip_requirements: Optional[list[str]] = None
|
46
|
+
conda_dependencies: Optional[list[str]] = None
|
47
|
+
target_platforms: Optional[list[str]] = None
|
48
|
+
comment: Optional[str] = None
|
49
|
+
warehouse: Optional[str] = None
|
50
|
+
|
51
|
+
|
52
|
+
class HuggingFaceModel(BaseModel):
|
53
|
+
hf_model_name: str
|
54
|
+
task: Optional[str] = None
|
55
|
+
tokenizer: Optional[str] = None
|
56
|
+
hf_token: Optional[str] = None
|
57
|
+
trust_remote_code: Optional[bool] = False
|
58
|
+
revision: Optional[str] = None
|
59
|
+
hf_model_kwargs: Optional[str] = "{}"
|
60
|
+
|
61
|
+
|
62
|
+
class ModelLogging(BaseModel):
|
63
|
+
log_model_args: Optional[LogModelArgs] = None
|
64
|
+
hf_model: Optional[HuggingFaceModel] = None
|
65
|
+
|
66
|
+
|
67
|
+
class ModelServiceDeploymentSpec(BaseModel):
|
68
|
+
models: list[Model]
|
69
|
+
image_build: ImageBuild
|
70
|
+
service: Service
|
71
|
+
model_loggings: Optional[list[ModelLogging]] = None
|
72
|
+
|
73
|
+
|
74
|
+
class ModelJobDeploymentSpec(BaseModel):
|
75
|
+
models: list[Model]
|
76
|
+
image_build: ImageBuild
|
77
|
+
job: Job
|
78
|
+
model_loggings: Optional[list[ModelLogging]] = None
|
@@ -1,4 +1,4 @@
|
|
1
|
-
from typing import Any,
|
1
|
+
from typing import Any, Optional
|
2
2
|
|
3
3
|
from snowflake.ml._internal.utils import query_result_checker, sql_identifier
|
4
4
|
from snowflake.ml.model._client.sql import _base
|
@@ -24,8 +24,8 @@ class ModelSQLClient(_base._BaseSQLClient):
|
|
24
24
|
schema_name: Optional[sql_identifier.SqlIdentifier],
|
25
25
|
model_name: Optional[sql_identifier.SqlIdentifier] = None,
|
26
26
|
validate_result: bool = True,
|
27
|
-
statement_params: Optional[
|
28
|
-
) ->
|
27
|
+
statement_params: Optional[dict[str, Any]] = None,
|
28
|
+
) -> list[row.Row]:
|
29
29
|
actual_database_name = database_name or self._database_name
|
30
30
|
actual_schema_name = schema_name or self._schema_name
|
31
31
|
fully_qualified_schema_name = ".".join([actual_database_name.identifier(), actual_schema_name.identifier()])
|
@@ -57,8 +57,8 @@ class ModelSQLClient(_base._BaseSQLClient):
|
|
57
57
|
version_name: Optional[sql_identifier.SqlIdentifier] = None,
|
58
58
|
validate_result: bool = True,
|
59
59
|
check_model_details: bool = False,
|
60
|
-
statement_params: Optional[
|
61
|
-
) ->
|
60
|
+
statement_params: Optional[dict[str, Any]] = None,
|
61
|
+
) -> list[row.Row]:
|
62
62
|
like_sql = ""
|
63
63
|
if version_name:
|
64
64
|
like_sql = f" LIKE '{version_name.resolved()}'"
|
@@ -90,7 +90,7 @@ class ModelSQLClient(_base._BaseSQLClient):
|
|
90
90
|
schema_name: Optional[sql_identifier.SqlIdentifier],
|
91
91
|
model_name: sql_identifier.SqlIdentifier,
|
92
92
|
comment: str,
|
93
|
-
statement_params: Optional[
|
93
|
+
statement_params: Optional[dict[str, Any]] = None,
|
94
94
|
) -> None:
|
95
95
|
query_result_checker.SqlResultValidator(
|
96
96
|
self._session,
|
@@ -107,7 +107,7 @@ class ModelSQLClient(_base._BaseSQLClient):
|
|
107
107
|
database_name: Optional[sql_identifier.SqlIdentifier],
|
108
108
|
schema_name: Optional[sql_identifier.SqlIdentifier],
|
109
109
|
model_name: sql_identifier.SqlIdentifier,
|
110
|
-
statement_params: Optional[
|
110
|
+
statement_params: Optional[dict[str, Any]] = None,
|
111
111
|
) -> None:
|
112
112
|
query_result_checker.SqlResultValidator(
|
113
113
|
self._session,
|
@@ -124,7 +124,7 @@ class ModelSQLClient(_base._BaseSQLClient):
|
|
124
124
|
new_model_db: Optional[sql_identifier.SqlIdentifier],
|
125
125
|
new_model_schema: Optional[sql_identifier.SqlIdentifier],
|
126
126
|
new_model_name: sql_identifier.SqlIdentifier,
|
127
|
-
statement_params: Optional[
|
127
|
+
statement_params: Optional[dict[str, Any]] = None,
|
128
128
|
) -> None:
|
129
129
|
# Use registry's database and schema if a non fully qualified new model name is provided.
|
130
130
|
new_fully_qualified_name = self.fully_qualified_object_name(new_model_db, new_model_schema, new_model_name)
|