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
@@ -6,31 +6,26 @@ import zipfile
6
6
  from contextlib import contextmanager
7
7
  from datetime import datetime
8
8
  from types import ModuleType
9
- from typing import Any, Dict, Generator, List, Optional, TypedDict
9
+ from typing import Any, Generator, Optional, TypedDict
10
10
 
11
11
  import cloudpickle
12
12
  import yaml
13
13
  from packaging import requirements, version
14
14
  from typing_extensions import Required
15
15
 
16
- from snowflake.ml._internal import env as snowml_env, env_utils, file_utils
16
+ from snowflake.ml import version as snowml_version
17
+ from snowflake.ml._internal import env_utils, file_utils
17
18
  from snowflake.ml.model import model_signature, type_hints as model_types
18
19
  from snowflake.ml.model._packager.model_env import model_env
19
- from snowflake.ml.model._packager.model_meta import (
20
- _packaging_requirements,
21
- model_blob_meta,
22
- model_meta_schema,
23
- )
20
+ from snowflake.ml.model._packager.model_meta import model_blob_meta, model_meta_schema
24
21
  from snowflake.ml.model._packager.model_meta_migrator import migrator_plans
25
22
  from snowflake.ml.model._packager.model_runtime import model_runtime
26
23
 
27
24
  MODEL_METADATA_FILE = "model.yaml"
28
25
  MODEL_CODE_DIR = "code"
29
26
 
30
- _PACKAGING_REQUIREMENTS = [
31
- str(env_utils.get_package_spec_with_supported_ops_only(requirements.Requirement(r)))
32
- for r in _packaging_requirements.REQUIREMENTS
33
- ]
27
+ _PACKAGING_REQUIREMENTS = ["cloudpickle"]
28
+
34
29
  _SNOWFLAKE_PKG_NAME = "snowflake"
35
30
  _SNOWFLAKE_ML_PKG_NAME = f"{_SNOWFLAKE_PKG_NAME}.ml"
36
31
 
@@ -41,15 +36,16 @@ def create_model_metadata(
41
36
  model_dir_path: str,
42
37
  name: str,
43
38
  model_type: model_types.SupportedModelHandlerType,
44
- signatures: Optional[Dict[str, model_signature.ModelSignature]] = None,
45
- function_properties: Optional[Dict[str, Dict[str, Any]]] = None,
46
- metadata: Optional[Dict[str, str]] = None,
47
- code_paths: Optional[List[str]] = None,
48
- ext_modules: Optional[List[ModuleType]] = None,
49
- conda_dependencies: Optional[List[str]] = None,
50
- pip_requirements: Optional[List[str]] = None,
51
- artifact_repository_map: Optional[Dict[str, str]] = None,
52
- target_platforms: Optional[List[model_types.TargetPlatform]] = None,
39
+ signatures: Optional[dict[str, model_signature.ModelSignature]] = None,
40
+ function_properties: Optional[dict[str, dict[str, Any]]] = None,
41
+ metadata: Optional[dict[str, str]] = None,
42
+ code_paths: Optional[list[str]] = None,
43
+ ext_modules: Optional[list[ModuleType]] = None,
44
+ conda_dependencies: Optional[list[str]] = None,
45
+ pip_requirements: Optional[list[str]] = None,
46
+ artifact_repository_map: Optional[dict[str, str]] = None,
47
+ resource_constraint: Optional[dict[str, str]] = None,
48
+ target_platforms: Optional[list[model_types.TargetPlatform]] = None,
53
49
  python_version: Optional[str] = None,
54
50
  task: model_types.Task = model_types.Task.UNKNOWN,
55
51
  **kwargs: Any,
@@ -69,7 +65,9 @@ def create_model_metadata(
69
65
  ext_modules: List of names of modules that need to be pickled with the model. Defaults to None.
70
66
  conda_dependencies: List of conda requirements for running the model. Defaults to None.
71
67
  pip_requirements: List of pip Python packages requirements for running the model. Defaults to None.
72
- artifact_repository_map: A dict mapping from package channel to artifact repository name.
68
+ artifact_repository_map: A dict mapping from package channel to artifact repository name (e.g.
69
+ {'pip': 'snowflake.snowpark.pypi_shared_repository'}).
70
+ resource_constraint: Mapping of resource constraint keys and values, e.g. {"architecture": "x86"}.
73
71
  target_platforms: List of target platforms to run the model.
74
72
  python_version: A string of python version where model is run. Used for user override. If specified as None,
75
73
  current version would be captured. Defaults to None.
@@ -108,13 +106,14 @@ def create_model_metadata(
108
106
  conda_dependencies=conda_dependencies,
109
107
  pip_requirements=pip_requirements,
110
108
  artifact_repository_map=artifact_repository_map,
109
+ resource_constraint=resource_constraint,
111
110
  python_version=python_version,
112
111
  embed_local_ml_library=embed_local_ml_library,
113
112
  prefer_pip=prefer_pip,
114
113
  )
115
114
 
116
115
  if embed_local_ml_library:
117
- env.snowpark_ml_version = f"{snowml_env.VERSION}+{file_utils.hash_directory(path_to_copy)}"
116
+ env.snowpark_ml_version = f"{snowml_version.VERSION}+{file_utils.hash_directory(path_to_copy)}"
118
117
 
119
118
  model_meta = ModelMetadata(
120
119
  name=name,
@@ -156,9 +155,10 @@ def create_model_metadata(
156
155
 
157
156
  def _create_env_for_model_metadata(
158
157
  *,
159
- conda_dependencies: Optional[List[str]] = None,
160
- pip_requirements: Optional[List[str]] = None,
161
- artifact_repository_map: Optional[Dict[str, str]] = None,
158
+ conda_dependencies: Optional[list[str]] = None,
159
+ pip_requirements: Optional[list[str]] = None,
160
+ artifact_repository_map: Optional[dict[str, str]] = None,
161
+ resource_constraint: Optional[dict[str, str]] = None,
162
162
  python_version: Optional[str] = None,
163
163
  embed_local_ml_library: bool = False,
164
164
  prefer_pip: bool = False,
@@ -169,8 +169,9 @@ def _create_env_for_model_metadata(
169
169
  env.conda_dependencies = conda_dependencies # type: ignore[assignment]
170
170
  env.pip_requirements = pip_requirements # type: ignore[assignment]
171
171
  env.artifact_repository_map = artifact_repository_map
172
+ env.resource_constraint = resource_constraint
172
173
  env.python_version = python_version # type: ignore[assignment]
173
- env.snowpark_ml_version = snowml_env.VERSION
174
+ env.snowpark_ml_version = snowml_version.VERSION
174
175
 
175
176
  requirements_to_add = _PACKAGING_REQUIREMENTS
176
177
 
@@ -242,20 +243,20 @@ class ModelMetadata:
242
243
  name: str,
243
244
  env: model_env.ModelEnv,
244
245
  model_type: model_types.SupportedModelHandlerType,
245
- runtimes: Optional[Dict[str, model_runtime.ModelRuntime]] = None,
246
- signatures: Optional[Dict[str, model_signature.ModelSignature]] = None,
247
- function_properties: Optional[Dict[str, Dict[str, Any]]] = None,
248
- user_files: Optional[Dict[str, List[str]]] = None,
249
- metadata: Optional[Dict[str, str]] = None,
246
+ runtimes: Optional[dict[str, model_runtime.ModelRuntime]] = None,
247
+ signatures: Optional[dict[str, model_signature.ModelSignature]] = None,
248
+ function_properties: Optional[dict[str, dict[str, Any]]] = None,
249
+ user_files: Optional[dict[str, list[str]]] = None,
250
+ metadata: Optional[dict[str, str]] = None,
250
251
  creation_timestamp: Optional[str] = None,
251
252
  min_snowpark_ml_version: Optional[str] = None,
252
- models: Optional[Dict[str, model_blob_meta.ModelBlobMeta]] = None,
253
+ models: Optional[dict[str, model_blob_meta.ModelBlobMeta]] = None,
253
254
  original_metadata_version: Optional[str] = model_meta_schema.MODEL_METADATA_VERSION,
254
255
  task: model_types.Task = model_types.Task.UNKNOWN,
255
256
  explain_algorithm: Optional[model_meta_schema.ModelExplainAlgorithm] = None,
256
257
  ) -> None:
257
258
  self.name = name
258
- self.signatures: Dict[str, model_signature.ModelSignature] = dict()
259
+ self.signatures: dict[str, model_signature.ModelSignature] = dict()
259
260
  if signatures:
260
261
  self.signatures = signatures
261
262
  self.function_properties = function_properties or {}
@@ -270,7 +271,7 @@ class ModelMetadata:
270
271
  else model_meta_schema.MODEL_METADATA_MIN_SNOWPARK_ML_VERSION
271
272
  )
272
273
 
273
- self.models: Dict[str, model_blob_meta.ModelBlobMeta] = dict()
274
+ self.models: dict[str, model_blob_meta.ModelBlobMeta] = dict()
274
275
  if models:
275
276
  self.models = models
276
277
 
@@ -291,7 +292,7 @@ class ModelMetadata:
291
292
  self._min_snowpark_ml_version = max(self._min_snowpark_ml_version, parsed_min_snowpark_ml_version)
292
293
 
293
294
  @property
294
- def runtimes(self) -> Dict[str, model_runtime.ModelRuntime]:
295
+ def runtimes(self) -> dict[str, model_runtime.ModelRuntime]:
295
296
  if self._runtimes and "cpu" in self._runtimes:
296
297
  return self._runtimes
297
298
  runtimes = {
@@ -358,11 +359,11 @@ class ModelMetadata:
358
359
 
359
360
  loaded_meta_min_snowpark_ml_version = loaded_meta.get("min_snowpark_ml_version", None)
360
361
  if not loaded_meta_min_snowpark_ml_version or (
361
- version.parse(loaded_meta_min_snowpark_ml_version) > version.parse(snowml_env.VERSION)
362
+ version.parse(loaded_meta_min_snowpark_ml_version) > version.parse(snowml_version.VERSION)
362
363
  ):
363
364
  raise RuntimeError(
364
365
  f"The minimal version required to load the model is {loaded_meta_min_snowpark_ml_version}, "
365
- f"while current version of Snowpark ML library is {snowml_env.VERSION}."
366
+ f"while current version of Snowpark ML library is {snowml_version.VERSION}."
366
367
  )
367
368
  return model_meta_schema.ModelMetadataDict(
368
369
  creation_timestamp=loaded_meta["creation_timestamp"],
@@ -405,7 +406,7 @@ class ModelMetadata:
405
406
  env = model_env.ModelEnv()
406
407
  env.load_from_dict(pathlib.Path(model_dir_path), model_dict["env"])
407
408
 
408
- runtimes: Optional[Dict[str, model_runtime.ModelRuntime]]
409
+ runtimes: Optional[dict[str, model_runtime.ModelRuntime]]
409
410
  if model_dict.get("runtimes", None):
410
411
  runtimes = {
411
412
  name: model_runtime.ModelRuntime.load(pathlib.Path(model_dir_path), name, env, runtime_dict)
@@ -1,7 +1,7 @@
1
1
  # This files contains schema definition of what will be written into model.yml
2
2
  # Changing this file should lead to a change of the schema version.
3
3
  from enum import Enum
4
- from typing import Any, Dict, List, Optional, TypedDict, Union
4
+ from typing import Any, Optional, TypedDict, Union
5
5
 
6
6
  from typing_extensions import NotRequired, Required
7
7
 
@@ -18,18 +18,20 @@ class FunctionProperties(Enum):
18
18
  class ModelRuntimeDependenciesDict(TypedDict):
19
19
  conda: Required[str]
20
20
  pip: Required[str]
21
- artifact_repository_map: NotRequired[Optional[Dict[str, str]]]
21
+ artifact_repository_map: NotRequired[Optional[dict[str, str]]]
22
22
 
23
23
 
24
24
  class ModelRuntimeDict(TypedDict):
25
- imports: Required[List[str]]
25
+ imports: Required[list[str]]
26
26
  dependencies: Required[ModelRuntimeDependenciesDict]
27
+ resource_constraint: NotRequired[Optional[dict[str, str]]]
27
28
 
28
29
 
29
30
  class ModelEnvDict(TypedDict):
30
31
  conda: Required[str]
31
32
  pip: Required[str]
32
- artifact_repository_map: NotRequired[Optional[Dict[str, str]]]
33
+ artifact_repository_map: NotRequired[Optional[dict[str, str]]]
34
+ resource_constraint: NotRequired[Optional[dict[str, str]]]
33
35
  python_version: Required[str]
34
36
  cuda_version: NotRequired[Optional[str]]
35
37
  snowpark_ml_version: Required[str]
@@ -61,6 +63,7 @@ class MLFlowModelBlobOptions(BaseModelBlobOptions):
61
63
 
62
64
  class XgboostModelBlobOptions(BaseModelBlobOptions):
63
65
  xgb_estimator_type: Required[str]
66
+ enable_categorical: NotRequired[bool]
64
67
 
65
68
 
66
69
  class PyTorchModelBlobOptions(BaseModelBlobOptions):
@@ -102,25 +105,25 @@ class ModelBlobMetadataDict(TypedDict):
102
105
  model_type: Required[type_hints.SupportedModelHandlerType]
103
106
  path: Required[str]
104
107
  handler_version: Required[str]
105
- function_properties: NotRequired[Dict[str, Dict[str, Any]]]
106
- artifacts: NotRequired[Dict[str, str]]
108
+ function_properties: NotRequired[dict[str, dict[str, Any]]]
109
+ artifacts: NotRequired[dict[str, str]]
107
110
  options: NotRequired[ModelBlobOptions]
108
111
 
109
112
 
110
113
  class ModelMetadataDict(TypedDict):
111
114
  creation_timestamp: Required[str]
112
115
  env: Required[ModelEnvDict]
113
- runtimes: NotRequired[Dict[str, ModelRuntimeDict]]
114
- metadata: NotRequired[Optional[Dict[str, str]]]
116
+ runtimes: NotRequired[dict[str, ModelRuntimeDict]]
117
+ metadata: NotRequired[Optional[dict[str, str]]]
115
118
  model_type: Required[type_hints.SupportedModelHandlerType]
116
- models: Required[Dict[str, ModelBlobMetadataDict]]
119
+ models: Required[dict[str, ModelBlobMetadataDict]]
117
120
  name: Required[str]
118
- signatures: Required[Dict[str, Dict[str, Any]]]
121
+ signatures: Required[dict[str, dict[str, Any]]]
119
122
  version: Required[str]
120
123
  min_snowpark_ml_version: Required[str]
121
124
  task: Required[str]
122
125
  explainability: NotRequired[Optional[ExplainabilityMetadataDict]]
123
- function_properties: NotRequired[Dict[str, Dict[str, Any]]]
126
+ function_properties: NotRequired[dict[str, dict[str, Any]]]
124
127
 
125
128
 
126
129
  class ModelExplainAlgorithm(Enum):
@@ -1,6 +1,6 @@
1
1
  import copy
2
2
  from abc import abstractmethod
3
- from typing import Any, Dict, Protocol, final
3
+ from typing import Any, Protocol, final
4
4
 
5
5
  from snowflake.ml._internal import migrator_utils
6
6
 
@@ -11,13 +11,13 @@ class _BaseModelMetaMigratorProtocol(Protocol):
11
11
 
12
12
  @staticmethod
13
13
  @abstractmethod
14
- def upgrade(original_meta_dict: Dict[str, Any]) -> Dict[str, Any]:
14
+ def upgrade(original_meta_dict: dict[str, Any]) -> dict[str, Any]:
15
15
  raise NotImplementedError
16
16
 
17
17
 
18
18
  class BaseModelMetaMigrator(_BaseModelMetaMigratorProtocol):
19
19
  @final
20
- def try_upgrade(self, original_meta_dict: Dict[str, Any]) -> Dict[str, Any]:
20
+ def try_upgrade(self, original_meta_dict: dict[str, Any]) -> dict[str, Any]:
21
21
  loaded_meta_version = original_meta_dict.get("version", None)
22
22
  if not loaded_meta_version or str(loaded_meta_version) != self.source_version:
23
23
  raise NotImplementedError(
@@ -1,14 +1,14 @@
1
- from typing import Any, Dict, Type
1
+ from typing import Any
2
2
 
3
3
  from snowflake.ml.model._packager.model_meta import model_meta_schema
4
4
  from snowflake.ml.model._packager.model_meta_migrator import base_migrator, migrator_v1
5
5
 
6
- MODEL_META_MIGRATOR_PLANS: Dict[str, Type[base_migrator.BaseModelMetaMigrator]] = {
6
+ MODEL_META_MIGRATOR_PLANS: dict[str, type[base_migrator.BaseModelMetaMigrator]] = {
7
7
  "1": migrator_v1.MetaMigrator_v1,
8
8
  }
9
9
 
10
10
 
11
- def migrate_metadata(loaded_meta: Dict[str, Any]) -> Dict[str, Any]:
11
+ def migrate_metadata(loaded_meta: dict[str, Any]) -> dict[str, Any]:
12
12
  loaded_meta_version = str(loaded_meta.get("version", None))
13
13
  while loaded_meta_version != model_meta_schema.MODEL_METADATA_VERSION:
14
14
  if loaded_meta_version not in MODEL_META_MIGRATOR_PLANS.keys():
@@ -1,8 +1,8 @@
1
- from typing import Any, Dict
1
+ from typing import Any
2
2
 
3
3
  from packaging import requirements, version
4
4
 
5
- from snowflake.ml._internal import env as snowml_env
5
+ from snowflake.ml import version as snowml_version
6
6
  from snowflake.ml.model._packager.model_meta_migrator import base_migrator
7
7
 
8
8
 
@@ -11,7 +11,7 @@ class MetaMigrator_v1(base_migrator.BaseModelMetaMigrator):
11
11
  target_version = "2023-12-01"
12
12
 
13
13
  @staticmethod
14
- def upgrade(original_meta_dict: Dict[str, Any]) -> Dict[str, Any]:
14
+ def upgrade(original_meta_dict: dict[str, Any]) -> dict[str, Any]:
15
15
  loaded_python_version = version.parse(original_meta_dict["python_version"])
16
16
  if original_meta_dict.get("local_ml_library_version", None):
17
17
  loaded_lib_version = str(version.parse(original_meta_dict["local_ml_library_version"]))
@@ -24,7 +24,7 @@ class MetaMigrator_v1(base_migrator.BaseModelMetaMigrator):
24
24
  None,
25
25
  )
26
26
  if lib_spec_str is None:
27
- loaded_lib_version = snowml_env.VERSION
27
+ loaded_lib_version = snowml_version.VERSION
28
28
  loaded_lib_version = list(requirements.Requirement(str(lib_spec_str)).specifier)[0].version
29
29
 
30
30
  return dict(
@@ -1,6 +1,6 @@
1
1
  import os
2
2
  from types import ModuleType
3
- from typing import Dict, List, Optional
3
+ from typing import Optional
4
4
 
5
5
  from absl import logging
6
6
 
@@ -38,16 +38,17 @@ class ModelPackager:
38
38
  *,
39
39
  name: str,
40
40
  model: model_types.SupportedModelType,
41
- signatures: Optional[Dict[str, model_signature.ModelSignature]] = None,
41
+ signatures: Optional[dict[str, model_signature.ModelSignature]] = None,
42
42
  sample_input_data: Optional[model_types.SupportedDataType] = None,
43
- metadata: Optional[Dict[str, str]] = None,
44
- conda_dependencies: Optional[List[str]] = None,
45
- pip_requirements: Optional[List[str]] = None,
46
- artifact_repository_map: Optional[Dict[str, str]] = None,
47
- target_platforms: Optional[List[model_types.TargetPlatform]] = None,
43
+ metadata: Optional[dict[str, str]] = None,
44
+ conda_dependencies: Optional[list[str]] = None,
45
+ pip_requirements: Optional[list[str]] = None,
46
+ artifact_repository_map: Optional[dict[str, str]] = None,
47
+ resource_constraint: Optional[dict[str, str]] = None,
48
+ target_platforms: Optional[list[model_types.TargetPlatform]] = None,
48
49
  python_version: Optional[str] = None,
49
- ext_modules: Optional[List[ModuleType]] = None,
50
- code_paths: Optional[List[str]] = None,
50
+ ext_modules: Optional[list[ModuleType]] = None,
51
+ code_paths: Optional[list[str]] = None,
51
52
  options: model_types.ModelSaveOption,
52
53
  task: model_types.Task = model_types.Task.UNKNOWN,
53
54
  ) -> model_meta.ModelMetadata:
@@ -76,6 +77,7 @@ class ModelPackager:
76
77
  conda_dependencies=conda_dependencies,
77
78
  pip_requirements=pip_requirements,
78
79
  artifact_repository_map=artifact_repository_map,
80
+ resource_constraint=resource_constraint,
79
81
  python_version=python_version,
80
82
  task=task,
81
83
  target_platforms=target_platforms,
@@ -1 +1,32 @@
1
- REQUIREMENTS = ['absl-py>=0.15,<2', 'aiohttp!=4.0.0a0, !=4.0.0a1', 'anyio>=3.5.0,<5', 'cachetools>=3.1.1,<6', 'cloudpickle>=2.0.0,<3', 'cryptography', 'fsspec>=2024.6.1,<2026', 'importlib_resources>=6.1.1, <7', 'numpy>=1.23,<2', 'packaging>=20.9,<25', 'pandas>=1.0.0,<3', 'pyarrow', 'pyjwt>=2.0.0, <3', 'pytimeparse>=1.1.8,<2', 'pyyaml>=6.0,<7', 'requests', 'retrying>=1.3.3,<2', 's3fs>=2024.6.1,<2026', 'scikit-learn>=1.4,<1.6', 'scipy>=1.9,<2', 'snowflake-connector-python>=3.12.0,<4', 'snowflake-snowpark-python>=1.17.0,<2,!=1.26.0', 'snowflake.core>=1.0.2,<2', 'sqlparse>=0.4,<1', 'typing-extensions>=4.1.0,<5', 'xgboost>=1.7.3,<3']
1
+ # DO NOT EDIT!
2
+ # Generate by running 'bazel run --config=pre_build //bazel/requirements:sync_requirements'
3
+
4
+ REQUIREMENTS = [
5
+ "absl-py>=0.15,<2",
6
+ "aiohttp!=4.0.0a0, !=4.0.0a1",
7
+ "anyio>=3.5.0,<5",
8
+ "cachetools>=3.1.1,<6",
9
+ "cloudpickle>=2.0.0",
10
+ "cryptography",
11
+ "fsspec>=2024.6.1,<2026",
12
+ "importlib_resources>=6.1.1, <7",
13
+ "numpy>=1.23,<2",
14
+ "packaging>=20.9,<25",
15
+ "pandas>=1.0.0,<3",
16
+ "pyarrow",
17
+ "pydantic>=2.8.2, <3",
18
+ "pyjwt>=2.0.0, <3",
19
+ "pytimeparse>=1.1.8,<2",
20
+ "pyyaml>=6.0,<7",
21
+ "requests",
22
+ "retrying>=1.3.3,<2",
23
+ "s3fs>=2024.6.1,<2026",
24
+ "scikit-learn<1.6",
25
+ "scipy>=1.9,<2",
26
+ "shap>=0.46.0,<1",
27
+ "snowflake-connector-python>=3.14.0,<4",
28
+ "snowflake-snowpark-python>=1.17.0,<2,!=1.26.0",
29
+ "snowflake.core>=1.0.2,<2",
30
+ "sqlparse>=0.4,<1",
31
+ "typing-extensions>=4.1.0,<5",
32
+ ]
@@ -1,7 +1,7 @@
1
1
  import copy
2
2
  import pathlib
3
3
  import warnings
4
- from typing import List, Optional
4
+ from typing import Optional
5
5
 
6
6
  from packaging import requirements
7
7
 
@@ -37,7 +37,7 @@ class ModelRuntime:
37
37
  self,
38
38
  name: str,
39
39
  env: model_env.ModelEnv,
40
- imports: Optional[List[str]] = None,
40
+ imports: Optional[list[str]] = None,
41
41
  is_warehouse: bool = False,
42
42
  is_gpu: bool = False,
43
43
  loading_from_file: bool = False,
@@ -102,6 +102,7 @@ class ModelRuntime:
102
102
  if env_dict.get("artifact_repository_map") is not None
103
103
  else {},
104
104
  ),
105
+ resource_constraint=env_dict["resource_constraint"],
105
106
  )
106
107
 
107
108
  @staticmethod
@@ -116,6 +117,7 @@ class ModelRuntime:
116
117
  env.cuda_version = meta_env.cuda_version
117
118
  env.snowpark_ml_version = meta_env.snowpark_ml_version
118
119
  env.artifact_repository_map = meta_env.artifact_repository_map
120
+ env.resource_constraint = meta_env.resource_constraint
119
121
 
120
122
  conda_env_rel_path = pathlib.PurePosixPath(loaded_dict["dependencies"]["conda"])
121
123
  pip_requirements_rel_path = pathlib.PurePosixPath(loaded_dict["dependencies"]["pip"])
@@ -6,12 +6,8 @@ from typing import (
6
6
  TYPE_CHECKING,
7
7
  Any,
8
8
  Callable,
9
- Dict,
10
- List,
11
9
  Optional,
12
10
  Sequence,
13
- Tuple,
14
- Type,
15
11
  Union,
16
12
  final,
17
13
  get_args,
@@ -48,7 +44,7 @@ PandasExtensionTypes = Union[
48
44
 
49
45
 
50
46
  class DataType(Enum):
51
- def __init__(self, value: str, snowpark_type: Type[spt.DataType], numpy_type: npt.DTypeLike) -> None:
47
+ def __init__(self, value: str, snowpark_type: type[spt.DataType], numpy_type: npt.DTypeLike) -> None:
52
48
  self._value = value
53
49
  self._snowpark_type = snowpark_type
54
50
  self._numpy_type = numpy_type
@@ -159,7 +155,7 @@ class DataType(Enum):
159
155
  else:
160
156
  actual_sp_type = snowpark_type
161
157
 
162
- snowpark_to_snowml_type_mapping: Dict[Type[spt.DataType], DataType] = {
158
+ snowpark_to_snowml_type_mapping: dict[type[spt.DataType], DataType] = {
163
159
  i._snowpark_type: i
164
160
  for i in DataType
165
161
  # We by default infer as signed integer.
@@ -199,7 +195,7 @@ class DataType(Enum):
199
195
  class BaseFeatureSpec(ABC):
200
196
  """Abstract Class for specification of a feature."""
201
197
 
202
- def __init__(self, name: str, shape: Optional[Tuple[int, ...]]) -> None:
198
+ def __init__(self, name: str, shape: Optional[tuple[int, ...]]) -> None:
203
199
  self._name = name
204
200
 
205
201
  if shape and not isinstance(shape, tuple):
@@ -218,23 +214,19 @@ class BaseFeatureSpec(ABC):
218
214
  @abstractmethod
219
215
  def as_snowpark_type(self) -> spt.DataType:
220
216
  """Convert to corresponding Snowpark Type."""
221
- pass
222
217
 
223
218
  @abstractmethod
224
219
  def as_dtype(self, force_numpy_dtype: bool = False) -> Union[npt.DTypeLike, str, PandasExtensionTypes]:
225
220
  """Convert to corresponding local Type."""
226
- pass
227
221
 
228
222
  @abstractmethod
229
- def to_dict(self) -> Dict[str, Any]:
223
+ def to_dict(self) -> dict[str, Any]:
230
224
  """Serialization"""
231
- pass
232
225
 
233
226
  @classmethod
234
227
  @abstractmethod
235
- def from_dict(self, input_dict: Dict[str, Any]) -> "BaseFeatureSpec":
228
+ def from_dict(self, input_dict: dict[str, Any]) -> "BaseFeatureSpec":
236
229
  """Deserialization"""
237
- pass
238
230
 
239
231
 
240
232
  class FeatureSpec(BaseFeatureSpec):
@@ -244,7 +236,7 @@ class FeatureSpec(BaseFeatureSpec):
244
236
  self,
245
237
  name: str,
246
238
  dtype: DataType,
247
- shape: Optional[Tuple[int, ...]] = None,
239
+ shape: Optional[tuple[int, ...]] = None,
248
240
  nullable: bool = True,
249
241
  ) -> None:
250
242
  """
@@ -330,19 +322,19 @@ class FeatureSpec(BaseFeatureSpec):
330
322
  f"name={repr(self._name)}{shape_str}, nullable={repr(self._nullable)})"
331
323
  )
332
324
 
333
- def to_dict(self) -> Dict[str, Any]:
325
+ def to_dict(self) -> dict[str, Any]:
334
326
  """Serialize the feature group into a dict.
335
327
 
336
328
  Returns:
337
329
  A dict that serializes the feature group.
338
330
  """
339
- base_dict: Dict[str, Any] = {"type": self._dtype.name, "name": self._name, "nullable": self._nullable}
331
+ base_dict: dict[str, Any] = {"type": self._dtype.name, "name": self._name, "nullable": self._nullable}
340
332
  if self._shape is not None:
341
333
  base_dict["shape"] = self._shape
342
334
  return base_dict
343
335
 
344
336
  @classmethod
345
- def from_dict(cls, input_dict: Dict[str, Any]) -> "FeatureSpec":
337
+ def from_dict(cls, input_dict: dict[str, Any]) -> "FeatureSpec":
346
338
  """Deserialize the feature specification from a dict.
347
339
 
348
340
  Args:
@@ -391,7 +383,7 @@ class FeatureSpec(BaseFeatureSpec):
391
383
  class FeatureGroupSpec(BaseFeatureSpec):
392
384
  """Specification of a group of features in Snowflake native model packaging."""
393
385
 
394
- def __init__(self, name: str, specs: List[BaseFeatureSpec], shape: Optional[Tuple[int, ...]] = None) -> None:
386
+ def __init__(self, name: str, specs: list[BaseFeatureSpec], shape: Optional[tuple[int, ...]] = None) -> None:
395
387
  """Initialize a feature group.
396
388
 
397
389
  Args:
@@ -458,19 +450,19 @@ class FeatureGroupSpec(BaseFeatureSpec):
458
450
  def as_dtype(self, force_numpy_dtype: bool = False) -> Union[npt.DTypeLike, str, PandasExtensionTypes]:
459
451
  return np.object_
460
452
 
461
- def to_dict(self) -> Dict[str, Any]:
453
+ def to_dict(self) -> dict[str, Any]:
462
454
  """Serialize the feature group into a dict.
463
455
 
464
456
  Returns:
465
457
  A dict that serializes the feature group.
466
458
  """
467
- base_dict: Dict[str, Any] = {"name": self._name, "specs": [s.to_dict() for s in self._specs]}
459
+ base_dict: dict[str, Any] = {"name": self._name, "specs": [s.to_dict() for s in self._specs]}
468
460
  if self._shape is not None:
469
461
  base_dict["shape"] = self._shape
470
462
  return base_dict
471
463
 
472
464
  @classmethod
473
- def from_dict(cls, input_dict: Dict[str, Any]) -> "FeatureGroupSpec":
465
+ def from_dict(cls, input_dict: dict[str, Any]) -> "FeatureGroupSpec":
474
466
  """Deserialize the feature group from a dict.
475
467
 
476
468
  Args:
@@ -520,7 +512,7 @@ class ModelSignature:
520
512
  else:
521
513
  return False
522
514
 
523
- def to_dict(self) -> Dict[str, Any]:
515
+ def to_dict(self) -> dict[str, Any]:
524
516
  """Generate a dict to represent the whole signature.
525
517
 
526
518
  Returns:
@@ -533,7 +525,7 @@ class ModelSignature:
533
525
  }
534
526
 
535
527
  @classmethod
536
- def from_dict(cls, loaded: Dict[str, Any]) -> "ModelSignature":
528
+ def from_dict(cls, loaded: dict[str, Any]) -> "ModelSignature":
537
529
  """Create a signature given the dict containing specifications of children features and feature groups.
538
530
 
539
531
  Args:
@@ -545,7 +537,7 @@ class ModelSignature:
545
537
  sig_outs = loaded["outputs"]
546
538
  sig_inputs = loaded["inputs"]
547
539
 
548
- deserialize_spec: Callable[[Dict[str, Any]], BaseFeatureSpec] = lambda sig_spec: (
540
+ deserialize_spec: Callable[[dict[str, Any]], BaseFeatureSpec] = lambda sig_spec: (
549
541
  FeatureGroupSpec.from_dict(sig_spec) if "specs" in sig_spec else FeatureSpec.from_dict(sig_spec)
550
542
  )
551
543
 
@@ -1,4 +1,4 @@
1
- from typing import TYPE_CHECKING, List, Literal, Optional, Sequence
1
+ from typing import TYPE_CHECKING, Literal, Optional, Sequence
2
2
 
3
3
  import numpy as np
4
4
  import pandas as pd
@@ -45,7 +45,7 @@ class XGBoostDMatrixHandler(base_handler.BaseDataHandler["xgboost.DMatrix"]):
45
45
  @staticmethod
46
46
  def infer_signature(data: "xgboost.DMatrix", role: Literal["input", "output"]) -> Sequence[core.BaseFeatureSpec]:
47
47
  feature_prefix = f"{XGBoostDMatrixHandler.FEATURE_PREFIX}_"
48
- features: List[core.BaseFeatureSpec] = []
48
+ features: list[core.BaseFeatureSpec] = []
49
49
  role_prefix = (
50
50
  XGBoostDMatrixHandler.INPUT_PREFIX if role == "input" else XGBoostDMatrixHandler.OUTPUT_PREFIX
51
51
  ) + "_"
@@ -81,8 +81,16 @@ class XGBoostDMatrixHandler(base_handler.BaseDataHandler["xgboost.DMatrix"]):
81
81
  ) -> "xgboost.DMatrix":
82
82
  import xgboost as xgb
83
83
 
84
+ enable_categorical = False
85
+ for col, d_type in df.dtypes.items():
86
+ if pd.api.extensions.ExtensionDtype.is_dtype(d_type):
87
+ continue
88
+ if not np.issubdtype(d_type, np.number):
89
+ df[col] = df[col].astype("category")
90
+ enable_categorical = True
91
+
84
92
  if not features:
85
- return xgb.DMatrix(df)
93
+ return xgb.DMatrix(df, enable_categorical=enable_categorical)
86
94
  else:
87
95
  feature_names = []
88
96
  feature_types = []
@@ -95,4 +103,9 @@ class XGBoostDMatrixHandler(base_handler.BaseDataHandler["xgboost.DMatrix"]):
95
103
  assert isinstance(feature, core.FeatureSpec), "Invalid feature kind."
96
104
  feature_names.append(feature.name)
97
105
  feature_types.append(feature._dtype._numpy_type)
98
- return xgb.DMatrix(df, feature_names=feature_names, feature_types=feature_types)
106
+ return xgb.DMatrix(
107
+ df,
108
+ feature_names=feature_names,
109
+ feature_types=feature_types,
110
+ enable_categorical=enable_categorical,
111
+ )