snowflake-ml-python 1.3.0__py3-none-any.whl → 1.4.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (211) hide show
  1. snowflake/ml/_internal/file_utils.py +3 -3
  2. snowflake/ml/_internal/human_readable_id/adjectives.txt +128 -0
  3. snowflake/ml/_internal/human_readable_id/animals.txt +128 -0
  4. snowflake/ml/_internal/human_readable_id/hrid_generator.py +40 -0
  5. snowflake/ml/_internal/human_readable_id/hrid_generator_base.py +135 -0
  6. snowflake/ml/_internal/telemetry.py +11 -2
  7. snowflake/ml/_internal/utils/formatting.py +1 -1
  8. snowflake/ml/feature_store/feature_store.py +15 -106
  9. snowflake/ml/fileset/sfcfs.py +4 -3
  10. snowflake/ml/fileset/stage_fs.py +18 -0
  11. snowflake/ml/model/_api.py +9 -9
  12. snowflake/ml/model/_client/model/model_version_impl.py +20 -15
  13. snowflake/ml/model/_deploy_client/image_builds/docker_context.py +3 -9
  14. snowflake/ml/model/_deploy_client/image_builds/server_image_builder.py +3 -5
  15. snowflake/ml/model/_deploy_client/snowservice/deploy.py +7 -6
  16. snowflake/ml/model/_model_composer/model_composer.py +10 -8
  17. snowflake/ml/model/_model_composer/model_method/function_generator.py +1 -1
  18. snowflake/ml/model/_model_composer/model_method/infer_table_function.py_template +2 -1
  19. snowflake/ml/model/_model_composer/model_method/model_method.py +2 -2
  20. snowflake/ml/model/_model_composer/model_runtime/_runtime_requirements.py +1 -1
  21. snowflake/ml/model/_packager/model_handlers/_base.py +2 -2
  22. snowflake/ml/model/_packager/model_handlers/_utils.py +5 -5
  23. snowflake/ml/model/_packager/model_handlers/custom.py +7 -7
  24. snowflake/ml/model/_packager/model_handlers/huggingface_pipeline.py +2 -2
  25. snowflake/ml/model/_packager/model_handlers/llm.py +1 -1
  26. snowflake/ml/model/_packager/model_handlers/mlflow.py +1 -1
  27. snowflake/ml/model/_packager/model_handlers/pytorch.py +13 -10
  28. snowflake/ml/model/_packager/model_handlers/sentence_transformers.py +214 -0
  29. snowflake/ml/model/_packager/model_handlers/sklearn.py +6 -6
  30. snowflake/ml/model/_packager/model_handlers/snowmlmodel.py +15 -3
  31. snowflake/ml/model/_packager/model_handlers/tensorflow.py +8 -8
  32. snowflake/ml/model/_packager/model_handlers/torchscript.py +7 -7
  33. snowflake/ml/model/_packager/model_handlers/xgboost.py +8 -8
  34. snowflake/ml/model/_packager/model_meta/_core_requirements.py +1 -1
  35. snowflake/ml/model/_packager/model_packager.py +8 -6
  36. snowflake/ml/model/custom_model.py +3 -1
  37. snowflake/ml/model/type_hints.py +13 -0
  38. snowflake/ml/modeling/_internal/estimator_utils.py +61 -1
  39. snowflake/ml/modeling/_internal/local_implementations/pandas_handlers.py +4 -43
  40. snowflake/ml/modeling/_internal/local_implementations/pandas_trainer.py +4 -4
  41. snowflake/ml/modeling/_internal/ml_runtime_implementations/ml_runtime_handlers.py +21 -17
  42. snowflake/ml/modeling/_internal/model_specifications.py +3 -1
  43. snowflake/ml/modeling/_internal/model_trainer.py +2 -2
  44. snowflake/ml/modeling/_internal/snowpark_implementations/distributed_hpo_trainer.py +547 -1
  45. snowflake/ml/modeling/_internal/snowpark_implementations/snowpark_handlers.py +67 -114
  46. snowflake/ml/modeling/_internal/snowpark_implementations/snowpark_trainer.py +9 -9
  47. snowflake/ml/modeling/_internal/transformer_protocols.py +2 -3
  48. snowflake/ml/modeling/calibration/calibrated_classifier_cv.py +33 -61
  49. snowflake/ml/modeling/cluster/affinity_propagation.py +33 -61
  50. snowflake/ml/modeling/cluster/agglomerative_clustering.py +33 -61
  51. snowflake/ml/modeling/cluster/birch.py +33 -61
  52. snowflake/ml/modeling/cluster/bisecting_k_means.py +33 -61
  53. snowflake/ml/modeling/cluster/dbscan.py +33 -61
  54. snowflake/ml/modeling/cluster/feature_agglomeration.py +33 -61
  55. snowflake/ml/modeling/cluster/k_means.py +33 -61
  56. snowflake/ml/modeling/cluster/mean_shift.py +33 -61
  57. snowflake/ml/modeling/cluster/mini_batch_k_means.py +33 -61
  58. snowflake/ml/modeling/cluster/optics.py +33 -61
  59. snowflake/ml/modeling/cluster/spectral_biclustering.py +33 -61
  60. snowflake/ml/modeling/cluster/spectral_clustering.py +33 -61
  61. snowflake/ml/modeling/cluster/spectral_coclustering.py +33 -61
  62. snowflake/ml/modeling/compose/column_transformer.py +33 -61
  63. snowflake/ml/modeling/compose/transformed_target_regressor.py +33 -61
  64. snowflake/ml/modeling/covariance/elliptic_envelope.py +33 -61
  65. snowflake/ml/modeling/covariance/empirical_covariance.py +33 -61
  66. snowflake/ml/modeling/covariance/graphical_lasso.py +33 -61
  67. snowflake/ml/modeling/covariance/graphical_lasso_cv.py +33 -61
  68. snowflake/ml/modeling/covariance/ledoit_wolf.py +33 -61
  69. snowflake/ml/modeling/covariance/min_cov_det.py +33 -61
  70. snowflake/ml/modeling/covariance/oas.py +33 -61
  71. snowflake/ml/modeling/covariance/shrunk_covariance.py +33 -61
  72. snowflake/ml/modeling/decomposition/dictionary_learning.py +33 -61
  73. snowflake/ml/modeling/decomposition/factor_analysis.py +33 -61
  74. snowflake/ml/modeling/decomposition/fast_ica.py +33 -61
  75. snowflake/ml/modeling/decomposition/incremental_pca.py +33 -61
  76. snowflake/ml/modeling/decomposition/kernel_pca.py +33 -61
  77. snowflake/ml/modeling/decomposition/mini_batch_dictionary_learning.py +33 -61
  78. snowflake/ml/modeling/decomposition/mini_batch_sparse_pca.py +33 -61
  79. snowflake/ml/modeling/decomposition/pca.py +33 -61
  80. snowflake/ml/modeling/decomposition/sparse_pca.py +33 -61
  81. snowflake/ml/modeling/decomposition/truncated_svd.py +33 -61
  82. snowflake/ml/modeling/discriminant_analysis/linear_discriminant_analysis.py +33 -61
  83. snowflake/ml/modeling/discriminant_analysis/quadratic_discriminant_analysis.py +33 -61
  84. snowflake/ml/modeling/ensemble/ada_boost_classifier.py +33 -61
  85. snowflake/ml/modeling/ensemble/ada_boost_regressor.py +33 -61
  86. snowflake/ml/modeling/ensemble/bagging_classifier.py +33 -61
  87. snowflake/ml/modeling/ensemble/bagging_regressor.py +33 -61
  88. snowflake/ml/modeling/ensemble/extra_trees_classifier.py +33 -61
  89. snowflake/ml/modeling/ensemble/extra_trees_regressor.py +33 -61
  90. snowflake/ml/modeling/ensemble/gradient_boosting_classifier.py +33 -61
  91. snowflake/ml/modeling/ensemble/gradient_boosting_regressor.py +33 -61
  92. snowflake/ml/modeling/ensemble/hist_gradient_boosting_classifier.py +33 -61
  93. snowflake/ml/modeling/ensemble/hist_gradient_boosting_regressor.py +33 -61
  94. snowflake/ml/modeling/ensemble/isolation_forest.py +33 -61
  95. snowflake/ml/modeling/ensemble/random_forest_classifier.py +33 -61
  96. snowflake/ml/modeling/ensemble/random_forest_regressor.py +33 -61
  97. snowflake/ml/modeling/ensemble/stacking_regressor.py +33 -61
  98. snowflake/ml/modeling/ensemble/voting_classifier.py +33 -61
  99. snowflake/ml/modeling/ensemble/voting_regressor.py +33 -61
  100. snowflake/ml/modeling/feature_selection/generic_univariate_select.py +33 -61
  101. snowflake/ml/modeling/feature_selection/select_fdr.py +33 -61
  102. snowflake/ml/modeling/feature_selection/select_fpr.py +33 -61
  103. snowflake/ml/modeling/feature_selection/select_fwe.py +33 -61
  104. snowflake/ml/modeling/feature_selection/select_k_best.py +33 -61
  105. snowflake/ml/modeling/feature_selection/select_percentile.py +33 -61
  106. snowflake/ml/modeling/feature_selection/sequential_feature_selector.py +33 -61
  107. snowflake/ml/modeling/feature_selection/variance_threshold.py +33 -61
  108. snowflake/ml/modeling/framework/base.py +55 -5
  109. snowflake/ml/modeling/gaussian_process/gaussian_process_classifier.py +33 -61
  110. snowflake/ml/modeling/gaussian_process/gaussian_process_regressor.py +33 -61
  111. snowflake/ml/modeling/impute/iterative_imputer.py +33 -61
  112. snowflake/ml/modeling/impute/knn_imputer.py +33 -61
  113. snowflake/ml/modeling/impute/missing_indicator.py +33 -61
  114. snowflake/ml/modeling/impute/simple_imputer.py +4 -15
  115. snowflake/ml/modeling/kernel_approximation/additive_chi2_sampler.py +33 -61
  116. snowflake/ml/modeling/kernel_approximation/nystroem.py +33 -61
  117. snowflake/ml/modeling/kernel_approximation/polynomial_count_sketch.py +33 -61
  118. snowflake/ml/modeling/kernel_approximation/rbf_sampler.py +33 -61
  119. snowflake/ml/modeling/kernel_approximation/skewed_chi2_sampler.py +33 -61
  120. snowflake/ml/modeling/kernel_ridge/kernel_ridge.py +33 -61
  121. snowflake/ml/modeling/lightgbm/lgbm_classifier.py +36 -63
  122. snowflake/ml/modeling/lightgbm/lgbm_regressor.py +36 -63
  123. snowflake/ml/modeling/linear_model/ard_regression.py +33 -61
  124. snowflake/ml/modeling/linear_model/bayesian_ridge.py +33 -61
  125. snowflake/ml/modeling/linear_model/elastic_net.py +33 -61
  126. snowflake/ml/modeling/linear_model/elastic_net_cv.py +33 -61
  127. snowflake/ml/modeling/linear_model/gamma_regressor.py +33 -61
  128. snowflake/ml/modeling/linear_model/huber_regressor.py +33 -61
  129. snowflake/ml/modeling/linear_model/lars.py +33 -61
  130. snowflake/ml/modeling/linear_model/lars_cv.py +33 -61
  131. snowflake/ml/modeling/linear_model/lasso.py +33 -61
  132. snowflake/ml/modeling/linear_model/lasso_cv.py +33 -61
  133. snowflake/ml/modeling/linear_model/lasso_lars.py +33 -61
  134. snowflake/ml/modeling/linear_model/lasso_lars_cv.py +33 -61
  135. snowflake/ml/modeling/linear_model/lasso_lars_ic.py +33 -61
  136. snowflake/ml/modeling/linear_model/linear_regression.py +33 -61
  137. snowflake/ml/modeling/linear_model/logistic_regression.py +33 -61
  138. snowflake/ml/modeling/linear_model/logistic_regression_cv.py +33 -61
  139. snowflake/ml/modeling/linear_model/multi_task_elastic_net.py +33 -61
  140. snowflake/ml/modeling/linear_model/multi_task_elastic_net_cv.py +33 -61
  141. snowflake/ml/modeling/linear_model/multi_task_lasso.py +33 -61
  142. snowflake/ml/modeling/linear_model/multi_task_lasso_cv.py +33 -61
  143. snowflake/ml/modeling/linear_model/orthogonal_matching_pursuit.py +33 -61
  144. snowflake/ml/modeling/linear_model/passive_aggressive_classifier.py +33 -61
  145. snowflake/ml/modeling/linear_model/passive_aggressive_regressor.py +33 -61
  146. snowflake/ml/modeling/linear_model/perceptron.py +33 -61
  147. snowflake/ml/modeling/linear_model/poisson_regressor.py +33 -61
  148. snowflake/ml/modeling/linear_model/ransac_regressor.py +33 -61
  149. snowflake/ml/modeling/linear_model/ridge.py +33 -61
  150. snowflake/ml/modeling/linear_model/ridge_classifier.py +33 -61
  151. snowflake/ml/modeling/linear_model/ridge_classifier_cv.py +33 -61
  152. snowflake/ml/modeling/linear_model/ridge_cv.py +33 -61
  153. snowflake/ml/modeling/linear_model/sgd_classifier.py +33 -61
  154. snowflake/ml/modeling/linear_model/sgd_one_class_svm.py +33 -61
  155. snowflake/ml/modeling/linear_model/sgd_regressor.py +33 -61
  156. snowflake/ml/modeling/linear_model/theil_sen_regressor.py +33 -61
  157. snowflake/ml/modeling/linear_model/tweedie_regressor.py +33 -61
  158. snowflake/ml/modeling/manifold/isomap.py +33 -61
  159. snowflake/ml/modeling/manifold/mds.py +33 -61
  160. snowflake/ml/modeling/manifold/spectral_embedding.py +33 -61
  161. snowflake/ml/modeling/manifold/tsne.py +33 -61
  162. snowflake/ml/modeling/mixture/bayesian_gaussian_mixture.py +33 -61
  163. snowflake/ml/modeling/mixture/gaussian_mixture.py +33 -61
  164. snowflake/ml/modeling/model_selection/grid_search_cv.py +39 -57
  165. snowflake/ml/modeling/model_selection/randomized_search_cv.py +26 -57
  166. snowflake/ml/modeling/multiclass/one_vs_one_classifier.py +33 -61
  167. snowflake/ml/modeling/multiclass/one_vs_rest_classifier.py +33 -61
  168. snowflake/ml/modeling/multiclass/output_code_classifier.py +33 -61
  169. snowflake/ml/modeling/naive_bayes/bernoulli_nb.py +33 -61
  170. snowflake/ml/modeling/naive_bayes/categorical_nb.py +33 -61
  171. snowflake/ml/modeling/naive_bayes/complement_nb.py +33 -61
  172. snowflake/ml/modeling/naive_bayes/gaussian_nb.py +33 -61
  173. snowflake/ml/modeling/naive_bayes/multinomial_nb.py +33 -61
  174. snowflake/ml/modeling/neighbors/k_neighbors_classifier.py +33 -61
  175. snowflake/ml/modeling/neighbors/k_neighbors_regressor.py +33 -61
  176. snowflake/ml/modeling/neighbors/kernel_density.py +33 -61
  177. snowflake/ml/modeling/neighbors/local_outlier_factor.py +33 -61
  178. snowflake/ml/modeling/neighbors/nearest_centroid.py +33 -61
  179. snowflake/ml/modeling/neighbors/nearest_neighbors.py +33 -61
  180. snowflake/ml/modeling/neighbors/neighborhood_components_analysis.py +33 -61
  181. snowflake/ml/modeling/neighbors/radius_neighbors_classifier.py +33 -61
  182. snowflake/ml/modeling/neighbors/radius_neighbors_regressor.py +33 -61
  183. snowflake/ml/modeling/neural_network/bernoulli_rbm.py +33 -61
  184. snowflake/ml/modeling/neural_network/mlp_classifier.py +33 -61
  185. snowflake/ml/modeling/neural_network/mlp_regressor.py +33 -61
  186. snowflake/ml/modeling/preprocessing/polynomial_features.py +33 -61
  187. snowflake/ml/modeling/semi_supervised/label_propagation.py +33 -61
  188. snowflake/ml/modeling/semi_supervised/label_spreading.py +33 -61
  189. snowflake/ml/modeling/svm/linear_svc.py +33 -61
  190. snowflake/ml/modeling/svm/linear_svr.py +33 -61
  191. snowflake/ml/modeling/svm/nu_svc.py +33 -61
  192. snowflake/ml/modeling/svm/nu_svr.py +33 -61
  193. snowflake/ml/modeling/svm/svc.py +33 -61
  194. snowflake/ml/modeling/svm/svr.py +33 -61
  195. snowflake/ml/modeling/tree/decision_tree_classifier.py +33 -61
  196. snowflake/ml/modeling/tree/decision_tree_regressor.py +33 -61
  197. snowflake/ml/modeling/tree/extra_tree_classifier.py +33 -61
  198. snowflake/ml/modeling/tree/extra_tree_regressor.py +33 -61
  199. snowflake/ml/modeling/xgboost/xgb_classifier.py +33 -61
  200. snowflake/ml/modeling/xgboost/xgb_regressor.py +33 -61
  201. snowflake/ml/modeling/xgboost/xgbrf_classifier.py +33 -61
  202. snowflake/ml/modeling/xgboost/xgbrf_regressor.py +33 -61
  203. snowflake/ml/registry/_manager/model_manager.py +6 -2
  204. snowflake/ml/registry/model_registry.py +100 -27
  205. snowflake/ml/registry/registry.py +6 -2
  206. snowflake/ml/version.py +1 -1
  207. {snowflake_ml_python-1.3.0.dist-info → snowflake_ml_python-1.4.0.dist-info}/METADATA +43 -7
  208. {snowflake_ml_python-1.3.0.dist-info → snowflake_ml_python-1.4.0.dist-info}/RECORD +211 -206
  209. {snowflake_ml_python-1.3.0.dist-info → snowflake_ml_python-1.4.0.dist-info}/LICENSE.txt +0 -0
  210. {snowflake_ml_python-1.3.0.dist-info → snowflake_ml_python-1.4.0.dist-info}/WHEEL +0 -0
  211. {snowflake_ml_python-1.3.0.dist-info → snowflake_ml_python-1.4.0.dist-info}/top_level.txt +0 -0
@@ -103,7 +103,10 @@ def _create_registry_database(
103
103
 
104
104
 
105
105
  def _create_registry_schema(
106
- session: snowpark.Session, database_name: str, schema_name: str, statement_params: Dict[str, Any]
106
+ session: snowpark.Session,
107
+ database_name: str,
108
+ schema_name: str,
109
+ statement_params: Dict[str, Any],
107
110
  ) -> None:
108
111
  """Private helper to create the model registry schema.
109
112
 
@@ -161,7 +164,11 @@ def _create_registry_views(
161
164
 
162
165
  # Create a view on active permanent deployments.
163
166
  _create_active_permanent_deployment_view(
164
- session, fully_qualified_schema_name, registry_table_name, deployment_table_name, statement_params
167
+ session,
168
+ fully_qualified_schema_name,
169
+ registry_table_name,
170
+ deployment_table_name,
171
+ statement_params,
165
172
  )
166
173
 
167
174
  # Create views on most recent metadata items.
@@ -437,10 +444,12 @@ fully integrated into the new registry.
437
444
  # Could do a multi-table insert here with some pros and cons:
438
445
  # [PRO] Atomic insert across multiple tables.
439
446
  # [CON] Code logic becomes messy depending on which fields are set.
440
- # [CON] Harder to re-use existing methods like set_model_name.
447
+ # [CON] Harder to reuse existing methods like set_model_name.
441
448
  # Context: https://docs.snowflake.com/en/sql-reference/sql/insert-multi-table.html
442
449
  return table_manager.insert_table_entry(
443
- self._session, table=self._fully_qualified_registry_table_name(), columns=properties
450
+ self._session,
451
+ table=self._fully_qualified_registry_table_name(),
452
+ columns=properties,
444
453
  )
445
454
 
446
455
  def _insert_metadata_entry(self, *, id: str, attribute: str, value: Any, operation: str) -> List[snowpark.Row]:
@@ -471,7 +480,9 @@ fully integrated into the new registry.
471
480
  columns["VALUE"] = value
472
481
 
473
482
  return table_manager.insert_table_entry(
474
- self._session, table=self._fully_qualified_metadata_table_name(), columns=columns
483
+ self._session,
484
+ table=self._fully_qualified_metadata_table_name(),
485
+ columns=columns,
475
486
  )
476
487
 
477
488
  def _insert_deployment_entry(
@@ -484,7 +495,10 @@ fully integrated into the new registry.
484
495
  signature: Dict[str, Any],
485
496
  target_method: str,
486
497
  options: Optional[
487
- Union[model_types.WarehouseDeployOptions, model_types.SnowparkContainerServiceDeployOptions]
498
+ Union[
499
+ model_types.WarehouseDeployOptions,
500
+ model_types.SnowparkContainerServiceDeployOptions,
501
+ ]
488
502
  ] = None,
489
503
  ) -> List[snowpark.Row]:
490
504
  """Insert a new row into the model deployment table.
@@ -521,7 +535,9 @@ fully integrated into the new registry.
521
535
  columns["OPTIONS"] = options
522
536
 
523
537
  return table_manager.insert_table_entry(
524
- self._session, table=self._fully_qualified_deployment_table_name(), columns=columns
538
+ self._session,
539
+ table=self._fully_qualified_deployment_table_name(),
540
+ columns=columns,
525
541
  )
526
542
 
527
543
  def _prepare_deployment_stage(self) -> str:
@@ -596,7 +612,11 @@ fully integrated into the new registry.
596
612
  return identifier.get_schema_level_object_identifier(db, schema, stage)
597
613
 
598
614
  def _list_selected_models(
599
- self, *, id: Optional[str] = None, model_name: Optional[str] = None, model_version: Optional[str] = None
615
+ self,
616
+ *,
617
+ id: Optional[str] = None,
618
+ model_name: Optional[str] = None,
619
+ model_version: Optional[str] = None,
600
620
  ) -> snowpark.DataFrame:
601
621
  """Retrieve the Snowpark dataframe of models matching the specified ID or (name and version).
602
622
 
@@ -724,7 +744,12 @@ fully integrated into the new registry.
724
744
  assert id is not None
725
745
 
726
746
  try:
727
- self._insert_metadata_entry(id=id, attribute=attribute, value={attribute: value}, operation=operation)
747
+ self._insert_metadata_entry(
748
+ id=id,
749
+ attribute=attribute,
750
+ value={attribute: value},
751
+ operation=operation,
752
+ )
728
753
  except connector.DataError:
729
754
  raise connector.DataError(f"Setting {attribute} for mode id {id} failed.")
730
755
 
@@ -760,7 +785,10 @@ fully integrated into the new registry.
760
785
  return str(result)
761
786
 
762
787
  def _get_model_path(
763
- self, id: Optional[str] = None, model_name: Optional[str] = None, model_version: Optional[str] = None
788
+ self,
789
+ id: Optional[str] = None,
790
+ model_name: Optional[str] = None,
791
+ model_version: Optional[str] = None,
764
792
  ) -> str:
765
793
  """Get the stage path for the model with the given (model name + model version) or `id` from the registry.
766
794
 
@@ -889,10 +917,17 @@ fully integrated into the new registry.
889
917
  value=new_model,
890
918
  )
891
919
  if description:
892
- self.set_model_description(model_name=model_name, model_version=model_version, description=description)
920
+ self.set_model_description(
921
+ model_name=model_name,
922
+ model_version=model_version,
923
+ description=description,
924
+ )
893
925
  if tags:
894
926
  self._set_metadata_attribute(
895
- _METADATA_ATTRIBUTE_TAGS, value=tags, model_name=model_name, model_version=model_version
927
+ _METADATA_ATTRIBUTE_TAGS,
928
+ value=tags,
929
+ model_name=model_name,
930
+ model_version=model_version,
896
931
  )
897
932
  else:
898
933
  raise connector.DatabaseError("Failed to insert the model properties to the registry table.")
@@ -961,7 +996,10 @@ fully integrated into the new registry.
961
996
  model_tags = self.get_tags(model_name=model_name, model_version=model_version)
962
997
  model_tags[tag_name] = tag_value
963
998
  self._set_metadata_attribute(
964
- _METADATA_ATTRIBUTE_TAGS, model_tags, model_name=model_name, model_version=model_version
999
+ _METADATA_ATTRIBUTE_TAGS,
1000
+ model_tags,
1001
+ model_name=model_name,
1002
+ model_version=model_version,
965
1003
  )
966
1004
 
967
1005
  @telemetry.send_api_usage_telemetry(
@@ -991,7 +1029,10 @@ fully integrated into the new registry.
991
1029
  )
992
1030
 
993
1031
  self._set_metadata_attribute(
994
- _METADATA_ATTRIBUTE_TAGS, model_tags, model_name=model_name, model_version=model_version
1032
+ _METADATA_ATTRIBUTE_TAGS,
1033
+ model_tags,
1034
+ model_name=model_name,
1035
+ model_version=model_version,
995
1036
  )
996
1037
 
997
1038
  @telemetry.send_api_usage_telemetry(
@@ -1089,7 +1130,9 @@ fully integrated into the new registry.
1089
1130
  Description of the model or None.
1090
1131
  """
1091
1132
  result = self._get_metadata_attribute(
1092
- _METADATA_ATTRIBUTE_DESCRIPTION, model_name=model_name, model_version=model_version
1133
+ _METADATA_ATTRIBUTE_DESCRIPTION,
1134
+ model_name=model_name,
1135
+ model_version=model_version,
1093
1136
  )
1094
1137
  return None if result is None else json.loads(result)
1095
1138
 
@@ -1112,7 +1155,10 @@ fully integrated into the new registry.
1112
1155
  description: Desired new model description.
1113
1156
  """
1114
1157
  self._set_metadata_attribute(
1115
- _METADATA_ATTRIBUTE_DESCRIPTION, description, model_name=model_name, model_version=model_version
1158
+ _METADATA_ATTRIBUTE_DESCRIPTION,
1159
+ description,
1160
+ model_name=model_name,
1161
+ model_version=model_version,
1116
1162
  )
1117
1163
 
1118
1164
  @telemetry.send_api_usage_telemetry(
@@ -1165,7 +1211,10 @@ fully integrated into the new registry.
1165
1211
  snowpark.DataFrame with the history of the model.
1166
1212
  """
1167
1213
  id = self._get_model_id(model_name=model_name, model_version=model_version)
1168
- return cast(snowpark.DataFrame, self.get_history().filter(snowpark.Column("MODEL_ID") == id))
1214
+ return cast(
1215
+ snowpark.DataFrame,
1216
+ self.get_history().filter(snowpark.Column("MODEL_ID") == id),
1217
+ )
1169
1218
 
1170
1219
  @telemetry.send_api_usage_telemetry(
1171
1220
  project=_TELEMETRY_PROJECT,
@@ -1194,7 +1243,10 @@ fully integrated into the new registry.
1194
1243
  model_metrics = self.get_metrics(model_name=model_name, model_version=model_version)
1195
1244
  model_metrics[metric_name] = metric_value
1196
1245
  self._set_metadata_attribute(
1197
- _METADATA_ATTRIBUTE_METRICS, model_metrics, model_name=model_name, model_version=model_version
1246
+ _METADATA_ATTRIBUTE_METRICS,
1247
+ model_metrics,
1248
+ model_name=model_name,
1249
+ model_version=model_version,
1198
1250
  )
1199
1251
 
1200
1252
  @telemetry.send_api_usage_telemetry(
@@ -1230,7 +1282,10 @@ fully integrated into the new registry.
1230
1282
  )
1231
1283
 
1232
1284
  self._set_metadata_attribute(
1233
- _METADATA_ATTRIBUTE_METRICS, model_metrics, model_name=model_name, model_version=model_version
1285
+ _METADATA_ATTRIBUTE_METRICS,
1286
+ model_metrics,
1287
+ model_name=model_name,
1288
+ model_version=model_version,
1234
1289
  )
1235
1290
 
1236
1291
  @telemetry.send_api_usage_telemetry(
@@ -1290,7 +1345,9 @@ fully integrated into the new registry.
1290
1345
  # Snowpark snowpark.dataframe returns dictionary objects as strings. We need to convert it back to a dictionary
1291
1346
  # here.
1292
1347
  result = self._get_metadata_attribute(
1293
- _METADATA_ATTRIBUTE_METRICS, model_name=model_name, model_version=model_version
1348
+ _METADATA_ATTRIBUTE_METRICS,
1349
+ model_name=model_name,
1350
+ model_version=model_version,
1294
1351
  )
1295
1352
 
1296
1353
  if result:
@@ -1432,7 +1489,7 @@ fully integrated into the new registry.
1432
1489
  metadata=tags,
1433
1490
  conda_dependencies=conda_dependencies,
1434
1491
  pip_requirements=pip_requirements,
1435
- sample_input=sample_input_data,
1492
+ sample_input_data=sample_input_data,
1436
1493
  code_paths=code_paths,
1437
1494
  options=options,
1438
1495
  )
@@ -1507,7 +1564,10 @@ fully integrated into the new registry.
1507
1564
  permanent: bool = False,
1508
1565
  platform: deploy_platforms.TargetPlatform = deploy_platforms.TargetPlatform.WAREHOUSE,
1509
1566
  options: Optional[
1510
- Union[model_types.WarehouseDeployOptions, model_types.SnowparkContainerServiceDeployOptions]
1567
+ Union[
1568
+ model_types.WarehouseDeployOptions,
1569
+ model_types.SnowparkContainerServiceDeployOptions,
1570
+ ]
1511
1571
  ] = None,
1512
1572
  ) -> model_types.Deployment:
1513
1573
  """Deploy the model with the given deployment name.
@@ -1772,7 +1832,9 @@ fully integrated into the new registry.
1772
1832
 
1773
1833
  """
1774
1834
  deployment = self._get_deployment(
1775
- model_name=model_name, model_version=model_version, deployment_name=deployment_name
1835
+ model_name=model_name,
1836
+ model_version=model_version,
1837
+ deployment_name=deployment_name,
1776
1838
  )
1777
1839
 
1778
1840
  # TODO(SNOW-759526): The following sequence should be a transaction.
@@ -1845,7 +1907,8 @@ fully integrated into the new registry.
1845
1907
 
1846
1908
  # Step 1/3: Delete the registry entry.
1847
1909
  query_result_checker.SqlResultValidator(
1848
- self._session, f"DELETE FROM {self._fully_qualified_registry_table_name()} WHERE ID='{id}'"
1910
+ self._session,
1911
+ f"DELETE FROM {self._fully_qualified_registry_table_name()} WHERE ID='{id}'",
1849
1912
  ).deletion_success(expected_num_rows=1).validate()
1850
1913
 
1851
1914
  # Step 2/3: Delete the artifact (if desired).
@@ -1966,7 +2029,11 @@ class ModelReference:
1966
2029
 
1967
2030
  def build_method(m: Callable[..., Any]) -> Callable[..., Any]:
1968
2031
  return lambda self, *args, **kwargs: m(
1969
- self._registry, self._model_name, self._model_version, *args, **kwargs
2032
+ self._registry,
2033
+ self._model_name,
2034
+ self._model_version,
2035
+ *args,
2036
+ **kwargs,
1970
2037
  )
1971
2038
 
1972
2039
  method = build_method(m=obj)
@@ -2027,7 +2094,10 @@ class ModelReference:
2027
2094
 
2028
2095
  if di:
2029
2096
  return model_api.predict(
2030
- session=self._registry._session, deployment=di, X=data, statement_params=statement_params
2097
+ session=self._registry._session,
2098
+ deployment=di,
2099
+ X=data,
2100
+ statement_params=statement_params,
2031
2101
  )
2032
2102
 
2033
2103
  # Mypy enforce to refer to the registry for calling the function
@@ -2059,7 +2129,10 @@ class ModelReference:
2059
2129
  options=options,
2060
2130
  )
2061
2131
  return model_api.predict(
2062
- session=self._registry._session, deployment=di, X=data, statement_params=statement_params
2132
+ session=self._registry._session,
2133
+ deployment=di,
2134
+ X=data,
2135
+ statement_params=statement_params,
2063
2136
  )
2064
2137
 
2065
2138
 
@@ -77,7 +77,7 @@ class Registry:
77
77
  model: model_types.SupportedModelType,
78
78
  *,
79
79
  model_name: str,
80
- version_name: str,
80
+ version_name: Optional[str] = None,
81
81
  comment: Optional[str] = None,
82
82
  metrics: Optional[Dict[str, Any]] = None,
83
83
  conda_dependencies: Optional[List[str]] = None,
@@ -95,9 +95,10 @@ class Registry:
95
95
  Args:
96
96
  model: Model object of supported types such as Scikit-learn, XGBoost, Snowpark ML,
97
97
  PyTorch, TorchScript, Tensorflow, Tensorflow Keras, MLFlow, HuggingFace Pipeline,
98
- Peft-finetuned LLM, or Custom Model.
98
+ Sentence Transformers, Peft-finetuned LLM, or Custom Model.
99
99
  model_name: Name to identify the model.
100
100
  version_name: Version identifier for the model. Combination of model_name and version_name must be unique.
101
+ If not specified, a random name will be generated.
101
102
  comment: Comment associated with the model version. Defaults to None.
102
103
  metrics: A JSON serializable dictionary containing metrics linked to the model version. Defaults to None.
103
104
  signatures: Model data signatures for inputs and outputs for various target methods. If it is None,
@@ -124,6 +125,8 @@ class Registry:
124
125
  Channel. Otherwise, defaults to False
125
126
  - relax_version: Whether or not relax the version constraints of the dependencies.
126
127
  It detects any ==x.y.z in specifiers and replaced with >=x.y, <(x+1). Defaults to True.
128
+ - function_type: Set the method function type globally. To set method function types individually see
129
+ function_type in model_options.
127
130
  - method_options: Per-method saving options including:
128
131
  - case_sensitive: Indicates whether the method and its signature should be case sensitive.
129
132
  This means when you refer the method in the SQL, you need to double quote it.
@@ -131,6 +134,7 @@ class Registry:
131
134
  non-alphabetic characters in your method or feature name. Defaults to False.
132
135
  - max_batch_size: Maximum batch size that the method could accept in the Snowflake Warehouse.
133
136
  Defaults to None, determined automatically by Snowflake.
137
+ - function_type: One of supported model method function types (FUNCTION or TABLE_FUNCTION).
134
138
 
135
139
  Raises:
136
140
  NotImplementedError: `pip_requirements` is not supported.
snowflake/ml/version.py CHANGED
@@ -1 +1 @@
1
- VERSION="1.3.0"
1
+ VERSION="1.4.0"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: snowflake-ml-python
3
- Version: 1.3.0
3
+ Version: 1.4.0
4
4
  Summary: The machine learning client library that is used for interacting with Snowflake to build machine learning solutions.
5
5
  Author-email: "Snowflake, Inc" <support@snowflake.com>
6
6
  License:
@@ -238,7 +238,7 @@ Requires-Dist: anyio <4,>=3.5.0
238
238
  Requires-Dist: cachetools <6,>=3.1.1
239
239
  Requires-Dist: cloudpickle >=2.0.0
240
240
  Requires-Dist: fsspec[http] <2024,>=2022.11
241
- Requires-Dist: importlib-resources <6,>=5.1.4
241
+ Requires-Dist: importlib-resources <7,>=6.1.1
242
242
  Requires-Dist: numpy <2,>=1.23
243
243
  Requires-Dist: packaging <24,>=20.9
244
244
  Requires-Dist: pandas <2,>=1.0.0
@@ -249,8 +249,8 @@ Requires-Dist: retrying <2,>=1.3.3
249
249
  Requires-Dist: s3fs <2024,>=2022.11
250
250
  Requires-Dist: scikit-learn <1.4,>=1.2.1
251
251
  Requires-Dist: scipy <2,>=1.9
252
- Requires-Dist: snowflake-connector-python[pandas] <4,>=3.0.4
253
- Requires-Dist: snowflake-snowpark-python !=1.12.0,<2,>=1.8.0
252
+ Requires-Dist: snowflake-connector-python[pandas] <4,>=3.5.0
253
+ Requires-Dist: snowflake-snowpark-python !=1.12.0,<2,>=1.11.1
254
254
  Requires-Dist: sqlparse <1,>=0.4
255
255
  Requires-Dist: typing-extensions <5,>=4.1.0
256
256
  Requires-Dist: xgboost <2,>=1.7.3
@@ -258,9 +258,10 @@ Provides-Extra: all
258
258
  Requires-Dist: lightgbm ==3.3.5 ; extra == 'all'
259
259
  Requires-Dist: mlflow <2.4,>=2.1.0 ; extra == 'all'
260
260
  Requires-Dist: peft <1,>=0.5.0 ; extra == 'all'
261
+ Requires-Dist: sentence-transformers <3,>=2.2.2 ; extra == 'all'
261
262
  Requires-Dist: sentencepiece <0.2,>=0.1.95 ; extra == 'all'
262
263
  Requires-Dist: shap ==0.42.1 ; extra == 'all'
263
- Requires-Dist: tensorflow !=2.12.0,<3,>=2.9 ; extra == 'all'
264
+ Requires-Dist: tensorflow <3,>=2.10 ; extra == 'all'
264
265
  Requires-Dist: tokenizers <1,>=0.10 ; extra == 'all'
265
266
  Requires-Dist: torchdata <1,>=0.4 ; extra == 'all'
266
267
  Requires-Dist: transformers <5,>=4.32.1 ; extra == 'all'
@@ -274,11 +275,12 @@ Requires-Dist: mlflow <2.4,>=2.1.0 ; extra == 'mlflow'
274
275
  Provides-Extra: shap
275
276
  Requires-Dist: shap ==0.42.1 ; extra == 'shap'
276
277
  Provides-Extra: tensorflow
277
- Requires-Dist: tensorflow !=2.12.0,<3,>=2.9 ; extra == 'tensorflow'
278
+ Requires-Dist: tensorflow <3,>=2.10 ; extra == 'tensorflow'
278
279
  Provides-Extra: torch
279
280
  Requires-Dist: torchdata <1,>=0.4 ; extra == 'torch'
280
281
  Requires-Dist: torch <2.1.0,>=2.0.1 ; (platform_system == "Windows") and extra == 'torch'
281
282
  Provides-Extra: transformers
283
+ Requires-Dist: sentence-transformers <3,>=2.2.2 ; extra == 'transformers'
282
284
  Requires-Dist: sentencepiece <0.2,>=0.1.95 ; extra == 'transformers'
283
285
  Requires-Dist: tokenizers <1,>=0.10 ; extra == 'transformers'
284
286
  Requires-Dist: transformers <5,>=4.32.1 ; extra == 'transformers'
@@ -368,7 +370,41 @@ be compatibility issues. Server-side functionality that `snowflake-ml-python` de
368
370
 
369
371
  # Release History
370
372
 
371
- ## 1.3.0
373
+ ## 1.4.0
374
+
375
+ ### Bug Fixes
376
+
377
+ - Registry: Fix a bug when multiple models are being called from the same query, models other than the first one will
378
+ have incorrect result. This fix only works for newly logged model.
379
+ - Modeling: When registering a model, only method(s) that is mentioned in `save_model` would be added to model signature
380
+ in SnowML models.
381
+ - Modeling: Fix a bug that when n_jobs is not 1, model cannot execute methods such as
382
+ predict, predict_log_proba, and other batch inference methods. The n_jobs would automatically
383
+ set to 1 because vectorized udf currently doesn't support joblib parallel backend.
384
+ - Modeling: Fix a bug that batch inference methods cannot infer the datatype when the first row of data contains NULL.
385
+ - Modeling: Matches Distributed HPO output column names with the snowflake identifier.
386
+ - Modeling: Relax package versions for all Distributed HPO methods if the installed version
387
+ is not available in the Snowflake conda channel
388
+ - Modeling: Add sklearn as required dependency for LightGBM package.
389
+
390
+ ### Behavior Changes
391
+
392
+ - Registry: `apply` method is no longer by default logged when logging a xgboost model. If that is required, it could
393
+ be specified manually when logging the model by `log_model(..., options={"target_methods": ["apply", ...]})`.
394
+
395
+ ### New Features
396
+
397
+ - Registry: Add support for `sentence-transformers` model (`sentence_transformers.SentenceTransformer`).
398
+ - Registry: Now version name is no longer required when logging a model. If not provided, a random human readable ID
399
+ will be generated.
400
+
401
+ ## 1.3.1 (2024-03-21)
402
+
403
+ ### New Features
404
+
405
+ - FileSet: `snowflake.ml.fileset.sfcfs.SFFileSystem` can now be used in UDFs and stored procedures.
406
+
407
+ ## 1.3.0 (2024-03-12)
372
408
 
373
409
  ### Bug Fixes
374
410