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.
Files changed (322) hide show
  1. snowflake/cortex/__init__.py +7 -1
  2. snowflake/cortex/_classify_text.py +3 -3
  3. snowflake/cortex/_complete.py +23 -24
  4. snowflake/cortex/_embed_text_1024.py +4 -4
  5. snowflake/cortex/_embed_text_768.py +4 -4
  6. snowflake/cortex/_finetune.py +8 -8
  7. snowflake/cortex/_util.py +8 -12
  8. snowflake/ml/_internal/env.py +4 -3
  9. snowflake/ml/_internal/env_utils.py +63 -34
  10. snowflake/ml/_internal/file_utils.py +10 -21
  11. snowflake/ml/_internal/human_readable_id/hrid_generator_base.py +5 -7
  12. snowflake/ml/_internal/init_utils.py +2 -3
  13. snowflake/ml/_internal/lineage/lineage_utils.py +6 -6
  14. snowflake/ml/_internal/platform_capabilities.py +18 -16
  15. snowflake/ml/_internal/telemetry.py +39 -52
  16. snowflake/ml/_internal/type_utils.py +3 -3
  17. snowflake/ml/_internal/utils/db_utils.py +2 -2
  18. snowflake/ml/_internal/utils/identifier.py +10 -10
  19. snowflake/ml/_internal/utils/import_utils.py +2 -2
  20. snowflake/ml/_internal/utils/parallelize.py +7 -7
  21. snowflake/ml/_internal/utils/pkg_version_utils.py +11 -11
  22. snowflake/ml/_internal/utils/query_result_checker.py +4 -4
  23. snowflake/ml/_internal/utils/snowflake_env.py +28 -6
  24. snowflake/ml/_internal/utils/snowpark_dataframe_utils.py +2 -2
  25. snowflake/ml/_internal/utils/sql_identifier.py +3 -3
  26. snowflake/ml/_internal/utils/table_manager.py +9 -9
  27. snowflake/ml/data/_internal/arrow_ingestor.py +7 -7
  28. snowflake/ml/data/data_connector.py +15 -36
  29. snowflake/ml/data/data_ingestor.py +4 -15
  30. snowflake/ml/data/data_source.py +2 -2
  31. snowflake/ml/data/ingestor_utils.py +3 -3
  32. snowflake/ml/data/torch_utils.py +5 -5
  33. snowflake/ml/dataset/dataset.py +11 -11
  34. snowflake/ml/dataset/dataset_metadata.py +8 -8
  35. snowflake/ml/dataset/dataset_reader.py +7 -7
  36. snowflake/ml/feature_store/__init__.py +1 -1
  37. snowflake/ml/feature_store/access_manager.py +7 -7
  38. snowflake/ml/feature_store/entity.py +6 -6
  39. snowflake/ml/feature_store/examples/airline_features/entities.py +1 -3
  40. snowflake/ml/feature_store/examples/airline_features/features/plane_features.py +1 -3
  41. snowflake/ml/feature_store/examples/airline_features/features/weather_features.py +1 -3
  42. snowflake/ml/feature_store/examples/citibike_trip_features/entities.py +1 -3
  43. snowflake/ml/feature_store/examples/citibike_trip_features/features/station_feature.py +1 -3
  44. snowflake/ml/feature_store/examples/citibike_trip_features/features/trip_feature.py +1 -3
  45. snowflake/ml/feature_store/examples/example_helper.py +16 -16
  46. snowflake/ml/feature_store/examples/new_york_taxi_features/entities.py +1 -3
  47. snowflake/ml/feature_store/examples/new_york_taxi_features/features/location_features.py +1 -3
  48. snowflake/ml/feature_store/examples/new_york_taxi_features/features/trip_features.py +1 -3
  49. snowflake/ml/feature_store/examples/wine_quality_features/entities.py +1 -3
  50. snowflake/ml/feature_store/examples/wine_quality_features/features/managed_wine_features.py +1 -3
  51. snowflake/ml/feature_store/examples/wine_quality_features/features/static_wine_features.py +1 -3
  52. snowflake/ml/feature_store/feature_store.py +52 -64
  53. snowflake/ml/feature_store/feature_view.py +24 -24
  54. snowflake/ml/fileset/embedded_stage_fs.py +5 -5
  55. snowflake/ml/fileset/fileset.py +5 -5
  56. snowflake/ml/fileset/sfcfs.py +13 -13
  57. snowflake/ml/fileset/stage_fs.py +15 -15
  58. snowflake/ml/jobs/_utils/constants.py +1 -1
  59. snowflake/ml/jobs/_utils/interop_utils.py +10 -10
  60. snowflake/ml/jobs/_utils/payload_utils.py +45 -46
  61. snowflake/ml/jobs/_utils/scripts/get_instance_ip.py +4 -4
  62. snowflake/ml/jobs/_utils/scripts/mljob_launcher.py +8 -5
  63. snowflake/ml/jobs/_utils/scripts/signal_workers.py +8 -8
  64. snowflake/ml/jobs/_utils/spec_utils.py +18 -29
  65. snowflake/ml/jobs/_utils/types.py +2 -2
  66. snowflake/ml/jobs/decorators.py +10 -5
  67. snowflake/ml/jobs/job.py +87 -30
  68. snowflake/ml/jobs/manager.py +86 -56
  69. snowflake/ml/lineage/lineage_node.py +5 -5
  70. snowflake/ml/model/_client/model/model_impl.py +3 -3
  71. snowflake/ml/model/_client/model/model_version_impl.py +103 -35
  72. snowflake/ml/model/_client/ops/metadata_ops.py +7 -7
  73. snowflake/ml/model/_client/ops/model_ops.py +41 -41
  74. snowflake/ml/model/_client/ops/service_ops.py +217 -32
  75. snowflake/ml/model/_client/service/model_deployment_spec.py +359 -65
  76. snowflake/ml/model/_client/service/model_deployment_spec_schema.py +69 -24
  77. snowflake/ml/model/_client/sql/model.py +8 -8
  78. snowflake/ml/model/_client/sql/model_version.py +26 -26
  79. snowflake/ml/model/_client/sql/service.py +17 -26
  80. snowflake/ml/model/_client/sql/stage.py +2 -2
  81. snowflake/ml/model/_client/sql/tag.py +6 -6
  82. snowflake/ml/model/_model_composer/model_composer.py +58 -32
  83. snowflake/ml/model/_model_composer/model_manifest/model_manifest.py +20 -16
  84. snowflake/ml/model/_model_composer/model_manifest/model_manifest_schema.py +14 -13
  85. snowflake/ml/model/_model_composer/model_method/model_method.py +3 -3
  86. snowflake/ml/model/_packager/model_env/model_env.py +28 -25
  87. snowflake/ml/model/_packager/model_handler.py +4 -4
  88. snowflake/ml/model/_packager/model_handlers/_base.py +2 -2
  89. snowflake/ml/model/_packager/model_handlers/_utils.py +47 -5
  90. snowflake/ml/model/_packager/model_handlers/catboost.py +5 -5
  91. snowflake/ml/model/_packager/model_handlers/custom.py +9 -5
  92. snowflake/ml/model/_packager/model_handlers/huggingface_pipeline.py +7 -21
  93. snowflake/ml/model/_packager/model_handlers/keras.py +4 -4
  94. snowflake/ml/model/_packager/model_handlers/lightgbm.py +4 -14
  95. snowflake/ml/model/_packager/model_handlers/mlflow.py +3 -3
  96. snowflake/ml/model/_packager/model_handlers/pytorch.py +5 -6
  97. snowflake/ml/model/_packager/model_handlers/sentence_transformers.py +5 -5
  98. snowflake/ml/model/_packager/model_handlers/sklearn.py +104 -46
  99. snowflake/ml/model/_packager/model_handlers/snowmlmodel.py +3 -3
  100. snowflake/ml/model/_packager/model_handlers/tensorflow.py +11 -8
  101. snowflake/ml/model/_packager/model_handlers/torchscript.py +6 -6
  102. snowflake/ml/model/_packager/model_handlers/xgboost.py +21 -22
  103. snowflake/ml/model/_packager/model_meta/model_blob_meta.py +2 -2
  104. snowflake/ml/model/_packager/model_meta/model_meta.py +39 -38
  105. snowflake/ml/model/_packager/model_meta/model_meta_schema.py +14 -11
  106. snowflake/ml/model/_packager/model_meta_migrator/base_migrator.py +3 -3
  107. snowflake/ml/model/_packager/model_meta_migrator/migrator_plans.py +3 -3
  108. snowflake/ml/model/_packager/model_meta_migrator/migrator_v1.py +4 -4
  109. snowflake/ml/model/_packager/model_packager.py +11 -9
  110. snowflake/ml/model/_packager/model_runtime/_snowml_inference_alternative_requirements.py +32 -1
  111. snowflake/ml/model/_packager/model_runtime/model_runtime.py +4 -2
  112. snowflake/ml/model/_signatures/core.py +16 -24
  113. snowflake/ml/model/_signatures/dmatrix_handler.py +17 -4
  114. snowflake/ml/model/_signatures/utils.py +6 -6
  115. snowflake/ml/model/custom_model.py +24 -11
  116. snowflake/ml/model/model_signature.py +12 -23
  117. snowflake/ml/model/models/huggingface_pipeline.py +7 -4
  118. snowflake/ml/model/type_hints.py +3 -3
  119. snowflake/ml/modeling/_internal/estimator_utils.py +7 -7
  120. snowflake/ml/modeling/_internal/local_implementations/pandas_handlers.py +6 -6
  121. snowflake/ml/modeling/_internal/local_implementations/pandas_trainer.py +7 -7
  122. snowflake/ml/modeling/_internal/model_specifications.py +8 -10
  123. snowflake/ml/modeling/_internal/model_trainer.py +5 -5
  124. snowflake/ml/modeling/_internal/model_trainer_builder.py +6 -6
  125. snowflake/ml/modeling/_internal/snowpark_implementations/distributed_hpo_trainer.py +30 -30
  126. snowflake/ml/modeling/_internal/snowpark_implementations/snowpark_handlers.py +13 -13
  127. snowflake/ml/modeling/_internal/snowpark_implementations/snowpark_trainer.py +31 -31
  128. snowflake/ml/modeling/_internal/snowpark_implementations/xgboost_external_memory_trainer.py +19 -19
  129. snowflake/ml/modeling/_internal/transformer_protocols.py +17 -17
  130. snowflake/ml/modeling/calibration/calibrated_classifier_cv.py +9 -1
  131. snowflake/ml/modeling/cluster/affinity_propagation.py +9 -1
  132. snowflake/ml/modeling/cluster/agglomerative_clustering.py +9 -1
  133. snowflake/ml/modeling/cluster/birch.py +9 -1
  134. snowflake/ml/modeling/cluster/bisecting_k_means.py +9 -1
  135. snowflake/ml/modeling/cluster/dbscan.py +9 -1
  136. snowflake/ml/modeling/cluster/feature_agglomeration.py +9 -1
  137. snowflake/ml/modeling/cluster/k_means.py +9 -1
  138. snowflake/ml/modeling/cluster/mean_shift.py +9 -1
  139. snowflake/ml/modeling/cluster/mini_batch_k_means.py +9 -1
  140. snowflake/ml/modeling/cluster/optics.py +9 -1
  141. snowflake/ml/modeling/cluster/spectral_biclustering.py +9 -1
  142. snowflake/ml/modeling/cluster/spectral_clustering.py +9 -1
  143. snowflake/ml/modeling/cluster/spectral_coclustering.py +9 -1
  144. snowflake/ml/modeling/compose/column_transformer.py +9 -1
  145. snowflake/ml/modeling/compose/transformed_target_regressor.py +9 -1
  146. snowflake/ml/modeling/covariance/elliptic_envelope.py +9 -1
  147. snowflake/ml/modeling/covariance/empirical_covariance.py +9 -1
  148. snowflake/ml/modeling/covariance/graphical_lasso.py +9 -1
  149. snowflake/ml/modeling/covariance/graphical_lasso_cv.py +9 -1
  150. snowflake/ml/modeling/covariance/ledoit_wolf.py +9 -1
  151. snowflake/ml/modeling/covariance/min_cov_det.py +9 -1
  152. snowflake/ml/modeling/covariance/oas.py +9 -1
  153. snowflake/ml/modeling/covariance/shrunk_covariance.py +9 -1
  154. snowflake/ml/modeling/decomposition/dictionary_learning.py +9 -1
  155. snowflake/ml/modeling/decomposition/factor_analysis.py +9 -1
  156. snowflake/ml/modeling/decomposition/fast_ica.py +9 -1
  157. snowflake/ml/modeling/decomposition/incremental_pca.py +9 -1
  158. snowflake/ml/modeling/decomposition/kernel_pca.py +9 -1
  159. snowflake/ml/modeling/decomposition/mini_batch_dictionary_learning.py +9 -1
  160. snowflake/ml/modeling/decomposition/mini_batch_sparse_pca.py +9 -1
  161. snowflake/ml/modeling/decomposition/pca.py +9 -1
  162. snowflake/ml/modeling/decomposition/sparse_pca.py +9 -1
  163. snowflake/ml/modeling/decomposition/truncated_svd.py +9 -1
  164. snowflake/ml/modeling/discriminant_analysis/linear_discriminant_analysis.py +9 -1
  165. snowflake/ml/modeling/discriminant_analysis/quadratic_discriminant_analysis.py +9 -1
  166. snowflake/ml/modeling/ensemble/ada_boost_classifier.py +9 -1
  167. snowflake/ml/modeling/ensemble/ada_boost_regressor.py +9 -1
  168. snowflake/ml/modeling/ensemble/bagging_classifier.py +9 -1
  169. snowflake/ml/modeling/ensemble/bagging_regressor.py +9 -1
  170. snowflake/ml/modeling/ensemble/extra_trees_classifier.py +9 -1
  171. snowflake/ml/modeling/ensemble/extra_trees_regressor.py +9 -1
  172. snowflake/ml/modeling/ensemble/gradient_boosting_classifier.py +9 -1
  173. snowflake/ml/modeling/ensemble/gradient_boosting_regressor.py +9 -1
  174. snowflake/ml/modeling/ensemble/hist_gradient_boosting_classifier.py +9 -1
  175. snowflake/ml/modeling/ensemble/hist_gradient_boosting_regressor.py +9 -1
  176. snowflake/ml/modeling/ensemble/isolation_forest.py +9 -1
  177. snowflake/ml/modeling/ensemble/random_forest_classifier.py +9 -1
  178. snowflake/ml/modeling/ensemble/random_forest_regressor.py +9 -1
  179. snowflake/ml/modeling/ensemble/stacking_regressor.py +9 -1
  180. snowflake/ml/modeling/ensemble/voting_classifier.py +9 -1
  181. snowflake/ml/modeling/ensemble/voting_regressor.py +9 -1
  182. snowflake/ml/modeling/feature_selection/generic_univariate_select.py +9 -1
  183. snowflake/ml/modeling/feature_selection/select_fdr.py +9 -1
  184. snowflake/ml/modeling/feature_selection/select_fpr.py +9 -1
  185. snowflake/ml/modeling/feature_selection/select_fwe.py +9 -1
  186. snowflake/ml/modeling/feature_selection/select_k_best.py +9 -1
  187. snowflake/ml/modeling/feature_selection/select_percentile.py +9 -1
  188. snowflake/ml/modeling/feature_selection/sequential_feature_selector.py +9 -1
  189. snowflake/ml/modeling/feature_selection/variance_threshold.py +9 -1
  190. snowflake/ml/modeling/framework/_utils.py +10 -10
  191. snowflake/ml/modeling/framework/base.py +32 -32
  192. snowflake/ml/modeling/gaussian_process/gaussian_process_classifier.py +9 -1
  193. snowflake/ml/modeling/gaussian_process/gaussian_process_regressor.py +9 -1
  194. snowflake/ml/modeling/impute/__init__.py +1 -1
  195. snowflake/ml/modeling/impute/iterative_imputer.py +9 -1
  196. snowflake/ml/modeling/impute/knn_imputer.py +9 -1
  197. snowflake/ml/modeling/impute/missing_indicator.py +9 -1
  198. snowflake/ml/modeling/impute/simple_imputer.py +5 -5
  199. snowflake/ml/modeling/kernel_approximation/additive_chi2_sampler.py +9 -1
  200. snowflake/ml/modeling/kernel_approximation/nystroem.py +9 -1
  201. snowflake/ml/modeling/kernel_approximation/polynomial_count_sketch.py +9 -1
  202. snowflake/ml/modeling/kernel_approximation/rbf_sampler.py +9 -1
  203. snowflake/ml/modeling/kernel_approximation/skewed_chi2_sampler.py +9 -1
  204. snowflake/ml/modeling/kernel_ridge/kernel_ridge.py +9 -1
  205. snowflake/ml/modeling/lightgbm/lgbm_classifier.py +9 -1
  206. snowflake/ml/modeling/lightgbm/lgbm_regressor.py +9 -1
  207. snowflake/ml/modeling/linear_model/ard_regression.py +9 -1
  208. snowflake/ml/modeling/linear_model/bayesian_ridge.py +9 -1
  209. snowflake/ml/modeling/linear_model/elastic_net.py +9 -1
  210. snowflake/ml/modeling/linear_model/elastic_net_cv.py +9 -1
  211. snowflake/ml/modeling/linear_model/gamma_regressor.py +9 -1
  212. snowflake/ml/modeling/linear_model/huber_regressor.py +9 -1
  213. snowflake/ml/modeling/linear_model/lars.py +9 -1
  214. snowflake/ml/modeling/linear_model/lars_cv.py +9 -1
  215. snowflake/ml/modeling/linear_model/lasso.py +9 -1
  216. snowflake/ml/modeling/linear_model/lasso_cv.py +9 -1
  217. snowflake/ml/modeling/linear_model/lasso_lars.py +9 -1
  218. snowflake/ml/modeling/linear_model/lasso_lars_cv.py +9 -1
  219. snowflake/ml/modeling/linear_model/lasso_lars_ic.py +9 -1
  220. snowflake/ml/modeling/linear_model/linear_regression.py +9 -1
  221. snowflake/ml/modeling/linear_model/logistic_regression.py +9 -1
  222. snowflake/ml/modeling/linear_model/logistic_regression_cv.py +9 -1
  223. snowflake/ml/modeling/linear_model/multi_task_elastic_net.py +9 -1
  224. snowflake/ml/modeling/linear_model/multi_task_elastic_net_cv.py +9 -1
  225. snowflake/ml/modeling/linear_model/multi_task_lasso.py +9 -1
  226. snowflake/ml/modeling/linear_model/multi_task_lasso_cv.py +9 -1
  227. snowflake/ml/modeling/linear_model/orthogonal_matching_pursuit.py +9 -1
  228. snowflake/ml/modeling/linear_model/passive_aggressive_classifier.py +9 -1
  229. snowflake/ml/modeling/linear_model/passive_aggressive_regressor.py +9 -1
  230. snowflake/ml/modeling/linear_model/perceptron.py +9 -1
  231. snowflake/ml/modeling/linear_model/poisson_regressor.py +9 -1
  232. snowflake/ml/modeling/linear_model/ransac_regressor.py +9 -1
  233. snowflake/ml/modeling/linear_model/ridge.py +9 -1
  234. snowflake/ml/modeling/linear_model/ridge_classifier.py +9 -1
  235. snowflake/ml/modeling/linear_model/ridge_classifier_cv.py +9 -1
  236. snowflake/ml/modeling/linear_model/ridge_cv.py +9 -1
  237. snowflake/ml/modeling/linear_model/sgd_classifier.py +9 -1
  238. snowflake/ml/modeling/linear_model/sgd_one_class_svm.py +9 -1
  239. snowflake/ml/modeling/linear_model/sgd_regressor.py +9 -1
  240. snowflake/ml/modeling/linear_model/theil_sen_regressor.py +9 -1
  241. snowflake/ml/modeling/linear_model/tweedie_regressor.py +9 -1
  242. snowflake/ml/modeling/manifold/isomap.py +9 -1
  243. snowflake/ml/modeling/manifold/mds.py +9 -1
  244. snowflake/ml/modeling/manifold/spectral_embedding.py +9 -1
  245. snowflake/ml/modeling/manifold/tsne.py +9 -1
  246. snowflake/ml/modeling/metrics/__init__.py +1 -1
  247. snowflake/ml/modeling/metrics/classification.py +39 -39
  248. snowflake/ml/modeling/metrics/metrics_utils.py +12 -12
  249. snowflake/ml/modeling/metrics/ranking.py +7 -7
  250. snowflake/ml/modeling/metrics/regression.py +13 -13
  251. snowflake/ml/modeling/mixture/bayesian_gaussian_mixture.py +9 -1
  252. snowflake/ml/modeling/mixture/gaussian_mixture.py +9 -1
  253. snowflake/ml/modeling/model_selection/__init__.py +1 -1
  254. snowflake/ml/modeling/model_selection/grid_search_cv.py +7 -7
  255. snowflake/ml/modeling/model_selection/randomized_search_cv.py +7 -7
  256. snowflake/ml/modeling/multiclass/one_vs_one_classifier.py +9 -1
  257. snowflake/ml/modeling/multiclass/one_vs_rest_classifier.py +9 -1
  258. snowflake/ml/modeling/multiclass/output_code_classifier.py +9 -1
  259. snowflake/ml/modeling/naive_bayes/bernoulli_nb.py +9 -1
  260. snowflake/ml/modeling/naive_bayes/categorical_nb.py +9 -1
  261. snowflake/ml/modeling/naive_bayes/complement_nb.py +9 -1
  262. snowflake/ml/modeling/naive_bayes/gaussian_nb.py +9 -1
  263. snowflake/ml/modeling/naive_bayes/multinomial_nb.py +9 -1
  264. snowflake/ml/modeling/neighbors/k_neighbors_classifier.py +9 -1
  265. snowflake/ml/modeling/neighbors/k_neighbors_regressor.py +9 -1
  266. snowflake/ml/modeling/neighbors/kernel_density.py +9 -1
  267. snowflake/ml/modeling/neighbors/local_outlier_factor.py +9 -1
  268. snowflake/ml/modeling/neighbors/nearest_centroid.py +9 -1
  269. snowflake/ml/modeling/neighbors/nearest_neighbors.py +9 -1
  270. snowflake/ml/modeling/neighbors/neighborhood_components_analysis.py +9 -1
  271. snowflake/ml/modeling/neighbors/radius_neighbors_classifier.py +9 -1
  272. snowflake/ml/modeling/neighbors/radius_neighbors_regressor.py +9 -1
  273. snowflake/ml/modeling/neural_network/bernoulli_rbm.py +9 -1
  274. snowflake/ml/modeling/neural_network/mlp_classifier.py +9 -1
  275. snowflake/ml/modeling/neural_network/mlp_regressor.py +9 -1
  276. snowflake/ml/modeling/pipeline/__init__.py +1 -1
  277. snowflake/ml/modeling/pipeline/pipeline.py +18 -18
  278. snowflake/ml/modeling/preprocessing/__init__.py +1 -1
  279. snowflake/ml/modeling/preprocessing/k_bins_discretizer.py +13 -13
  280. snowflake/ml/modeling/preprocessing/max_abs_scaler.py +4 -4
  281. snowflake/ml/modeling/preprocessing/min_max_scaler.py +8 -8
  282. snowflake/ml/modeling/preprocessing/normalizer.py +0 -1
  283. snowflake/ml/modeling/preprocessing/one_hot_encoder.py +28 -28
  284. snowflake/ml/modeling/preprocessing/ordinal_encoder.py +9 -9
  285. snowflake/ml/modeling/preprocessing/polynomial_features.py +9 -1
  286. snowflake/ml/modeling/preprocessing/robust_scaler.py +7 -7
  287. snowflake/ml/modeling/preprocessing/standard_scaler.py +5 -5
  288. snowflake/ml/modeling/semi_supervised/label_propagation.py +9 -1
  289. snowflake/ml/modeling/semi_supervised/label_spreading.py +9 -1
  290. snowflake/ml/modeling/svm/linear_svc.py +9 -1
  291. snowflake/ml/modeling/svm/linear_svr.py +9 -1
  292. snowflake/ml/modeling/svm/nu_svc.py +9 -1
  293. snowflake/ml/modeling/svm/nu_svr.py +9 -1
  294. snowflake/ml/modeling/svm/svc.py +9 -1
  295. snowflake/ml/modeling/svm/svr.py +9 -1
  296. snowflake/ml/modeling/tree/decision_tree_classifier.py +9 -1
  297. snowflake/ml/modeling/tree/decision_tree_regressor.py +9 -1
  298. snowflake/ml/modeling/tree/extra_tree_classifier.py +9 -1
  299. snowflake/ml/modeling/tree/extra_tree_regressor.py +9 -1
  300. snowflake/ml/modeling/xgboost/xgb_classifier.py +9 -1
  301. snowflake/ml/modeling/xgboost/xgb_regressor.py +9 -1
  302. snowflake/ml/modeling/xgboost/xgbrf_classifier.py +9 -1
  303. snowflake/ml/modeling/xgboost/xgbrf_regressor.py +9 -1
  304. snowflake/ml/monitoring/_client/model_monitor_sql_client.py +26 -26
  305. snowflake/ml/monitoring/_manager/model_monitor_manager.py +5 -5
  306. snowflake/ml/monitoring/entities/model_monitor_config.py +6 -6
  307. snowflake/ml/monitoring/explain_visualize.py +286 -0
  308. snowflake/ml/registry/_manager/model_manager.py +55 -32
  309. snowflake/ml/registry/registry.py +39 -31
  310. snowflake/ml/utils/authentication.py +2 -2
  311. snowflake/ml/utils/connection_params.py +5 -5
  312. snowflake/ml/utils/sparse.py +5 -4
  313. snowflake/ml/utils/sql_client.py +1 -2
  314. snowflake/ml/version.py +2 -1
  315. {snowflake_ml_python-1.8.2.dist-info → snowflake_ml_python-1.8.4.dist-info}/METADATA +55 -14
  316. snowflake_ml_python-1.8.4.dist-info/RECORD +419 -0
  317. {snowflake_ml_python-1.8.2.dist-info → snowflake_ml_python-1.8.4.dist-info}/WHEEL +1 -1
  318. snowflake/ml/model/_packager/model_meta/_packaging_requirements.py +0 -1
  319. snowflake/ml/modeling/_internal/constants.py +0 -2
  320. snowflake_ml_python-1.8.2.dist-info/RECORD +0 -420
  321. {snowflake_ml_python-1.8.2.dist-info → snowflake_ml_python-1.8.4.dist-info}/licenses/LICENSE.txt +0 -0
  322. {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 List, Optional, Union
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
- def save(
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
- service_database_name: Optional[sql_identifier.SqlIdentifier],
30
- service_schema_name: Optional[sql_identifier.SqlIdentifier],
31
- service_name: sql_identifier.SqlIdentifier,
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
- ingress_enabled: bool,
38
- max_instances: int,
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
- force_rebuild: bool,
45
- external_access_integrations: Optional[List[sql_identifier.SqlIdentifier]],
46
- ) -> str:
47
- # create the deployment spec
48
- # models spec
49
- fq_model_name = identifier.get_schema_level_object_identifier(
50
- database_name.identifier(), schema_name.identifier(), model_name.identifier()
51
- )
52
- model_dict = model_deployment_spec_schema.ModelDict(name=fq_model_name, version=version_name.identifier())
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
- # image_build spec
55
- saved_image_repo_database = image_repo_database_name or database_name
56
- saved_image_repo_schema = image_repo_schema_name or schema_name
57
- fq_image_repo_name = identifier.get_schema_level_object_identifier(
58
- saved_image_repo_database.identifier(), saved_image_repo_schema.identifier(), image_repo_name.identifier()
59
- )
60
- image_build_dict: model_deployment_spec_schema.ImageBuildDict = {
61
- "compute_pool": image_build_compute_pool_name.identifier(),
62
- "image_repo": fq_image_repo_name,
63
- "force_rebuild": force_rebuild,
64
- }
65
- if external_access_integrations is not None:
66
- image_build_dict["external_access_integrations"] = [
67
- eai.identifier() for eai in external_access_integrations
68
- ]
69
-
70
- # service spec
71
- saved_service_database = service_database_name or database_name
72
- saved_service_schema = service_schema_name or schema_name
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
- service_dict = model_deployment_spec_schema.ServiceDict(
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=service_compute_pool_name.identifier(),
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
- if cpu:
83
- service_dict["cpu"] = cpu
182
+ return self
84
183
 
85
- if memory:
86
- service_dict["memory"] = memory
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
- if gpu:
89
- if isinstance(gpu, int):
90
- gpu_str = str(gpu)
91
- else:
92
- gpu_str = gpu
93
- service_dict["gpu"] = gpu_str
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
- if num_workers:
96
- service_dict["num_workers"] = num_workers
225
+ Raises:
226
+ ValueError: If a service spec already exists.
97
227
 
98
- if max_batch_rows:
99
- service_dict["max_batch_rows"] = max_batch_rows
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
- # model deployment spec
102
- model_deployment_spec_dict = model_deployment_spec_schema.ModelDeploymentSpecDict(
103
- models=[model_dict],
104
- image_build=image_build_dict,
105
- service=service_dict,
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(model_deployment_spec_dict)
112
- # save the yaml
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(model_deployment_spec_dict, f)
409
+ yaml.safe_dump(yaml_content, f)
116
410
  return str(file_path.resolve())
@@ -1,33 +1,78 @@
1
- from typing import List, TypedDict
1
+ from typing import Optional
2
2
 
3
- from typing_extensions import NotRequired, Required
3
+ from pydantic import BaseModel
4
4
 
5
5
 
6
- class ModelDict(TypedDict):
7
- name: Required[str]
8
- version: Required[str]
6
+ class Model(BaseModel):
7
+ name: str
8
+ version: str
9
9
 
10
10
 
11
- class ImageBuildDict(TypedDict):
12
- compute_pool: Required[str]
13
- image_repo: Required[str]
14
- force_rebuild: Required[bool]
15
- external_access_integrations: NotRequired[List[str]]
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 ServiceDict(TypedDict):
19
- name: Required[str]
20
- compute_pool: Required[str]
21
- ingress_enabled: Required[bool]
22
- max_instances: Required[int]
23
- cpu: NotRequired[str]
24
- memory: NotRequired[str]
25
- gpu: NotRequired[str]
26
- num_workers: NotRequired[int]
27
- max_batch_rows: NotRequired[int]
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 ModelDeploymentSpecDict(TypedDict):
31
- models: Required[List[ModelDict]]
32
- image_build: Required[ImageBuildDict]
33
- service: Required[ServiceDict]
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, Dict, List, Optional
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[Dict[str, Any]] = None,
28
- ) -> List[row.Row]:
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[Dict[str, Any]] = None,
61
- ) -> List[row.Row]:
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[Dict[str, Any]] = None,
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[Dict[str, Any]] = None,
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[Dict[str, Any]] = None,
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)