snowflake-ml-python 1.11.0__py3-none-any.whl → 1.13.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 (198) hide show
  1. snowflake/cortex/_complete.py +3 -2
  2. snowflake/ml/_internal/telemetry.py +3 -1
  3. snowflake/ml/_internal/utils/service_logger.py +26 -1
  4. snowflake/ml/experiment/_client/artifact.py +76 -0
  5. snowflake/ml/experiment/_client/experiment_tracking_sql_client.py +64 -1
  6. snowflake/ml/experiment/experiment_tracking.py +113 -6
  7. snowflake/ml/feature_store/feature_store.py +1150 -131
  8. snowflake/ml/feature_store/feature_view.py +122 -0
  9. snowflake/ml/jobs/_utils/constants.py +8 -16
  10. snowflake/ml/jobs/_utils/feature_flags.py +16 -0
  11. snowflake/ml/jobs/_utils/payload_utils.py +19 -5
  12. snowflake/ml/jobs/_utils/scripts/get_instance_ip.py +18 -7
  13. snowflake/ml/jobs/_utils/scripts/mljob_launcher.py +23 -5
  14. snowflake/ml/jobs/_utils/spec_utils.py +4 -6
  15. snowflake/ml/jobs/_utils/types.py +2 -1
  16. snowflake/ml/jobs/job.py +38 -19
  17. snowflake/ml/jobs/manager.py +136 -19
  18. snowflake/ml/model/__init__.py +6 -1
  19. snowflake/ml/model/_client/model/batch_inference_specs.py +25 -0
  20. snowflake/ml/model/_client/model/model_version_impl.py +62 -65
  21. snowflake/ml/model/_client/ops/model_ops.py +42 -9
  22. snowflake/ml/model/_client/ops/service_ops.py +75 -154
  23. snowflake/ml/model/_client/service/model_deployment_spec.py +23 -37
  24. snowflake/ml/model/_client/service/model_deployment_spec_schema.py +15 -4
  25. snowflake/ml/model/_client/sql/service.py +4 -0
  26. snowflake/ml/model/_packager/model_handlers/huggingface_pipeline.py +309 -22
  27. snowflake/ml/model/_packager/model_handlers/sklearn.py +3 -1
  28. snowflake/ml/model/_packager/model_handlers/xgboost.py +5 -0
  29. snowflake/ml/model/_packager/model_meta/model_meta_schema.py +1 -0
  30. snowflake/ml/model/_packager/model_runtime/_snowml_inference_alternative_requirements.py +3 -3
  31. snowflake/ml/model/_signatures/snowpark_handler.py +1 -1
  32. snowflake/ml/model/_signatures/utils.py +4 -2
  33. snowflake/ml/model/models/huggingface_pipeline.py +23 -0
  34. snowflake/ml/model/openai_signatures.py +57 -0
  35. snowflake/ml/modeling/_internal/estimator_utils.py +43 -1
  36. snowflake/ml/modeling/_internal/local_implementations/pandas_trainer.py +14 -3
  37. snowflake/ml/modeling/_internal/snowpark_implementations/snowpark_trainer.py +17 -6
  38. snowflake/ml/modeling/calibration/calibrated_classifier_cv.py +1 -1
  39. snowflake/ml/modeling/cluster/affinity_propagation.py +1 -1
  40. snowflake/ml/modeling/cluster/agglomerative_clustering.py +1 -1
  41. snowflake/ml/modeling/cluster/birch.py +1 -1
  42. snowflake/ml/modeling/cluster/bisecting_k_means.py +1 -1
  43. snowflake/ml/modeling/cluster/dbscan.py +1 -1
  44. snowflake/ml/modeling/cluster/feature_agglomeration.py +1 -1
  45. snowflake/ml/modeling/cluster/k_means.py +1 -1
  46. snowflake/ml/modeling/cluster/mean_shift.py +1 -1
  47. snowflake/ml/modeling/cluster/mini_batch_k_means.py +1 -1
  48. snowflake/ml/modeling/cluster/optics.py +1 -1
  49. snowflake/ml/modeling/cluster/spectral_biclustering.py +1 -1
  50. snowflake/ml/modeling/cluster/spectral_clustering.py +1 -1
  51. snowflake/ml/modeling/cluster/spectral_coclustering.py +1 -1
  52. snowflake/ml/modeling/compose/column_transformer.py +1 -1
  53. snowflake/ml/modeling/compose/transformed_target_regressor.py +1 -1
  54. snowflake/ml/modeling/covariance/elliptic_envelope.py +1 -1
  55. snowflake/ml/modeling/covariance/empirical_covariance.py +1 -1
  56. snowflake/ml/modeling/covariance/graphical_lasso.py +1 -1
  57. snowflake/ml/modeling/covariance/graphical_lasso_cv.py +1 -1
  58. snowflake/ml/modeling/covariance/ledoit_wolf.py +1 -1
  59. snowflake/ml/modeling/covariance/min_cov_det.py +1 -1
  60. snowflake/ml/modeling/covariance/oas.py +1 -1
  61. snowflake/ml/modeling/covariance/shrunk_covariance.py +1 -1
  62. snowflake/ml/modeling/decomposition/dictionary_learning.py +1 -1
  63. snowflake/ml/modeling/decomposition/factor_analysis.py +1 -1
  64. snowflake/ml/modeling/decomposition/fast_ica.py +1 -1
  65. snowflake/ml/modeling/decomposition/incremental_pca.py +1 -1
  66. snowflake/ml/modeling/decomposition/kernel_pca.py +1 -1
  67. snowflake/ml/modeling/decomposition/mini_batch_dictionary_learning.py +1 -1
  68. snowflake/ml/modeling/decomposition/mini_batch_sparse_pca.py +1 -1
  69. snowflake/ml/modeling/decomposition/pca.py +1 -1
  70. snowflake/ml/modeling/decomposition/sparse_pca.py +1 -1
  71. snowflake/ml/modeling/decomposition/truncated_svd.py +1 -1
  72. snowflake/ml/modeling/discriminant_analysis/linear_discriminant_analysis.py +1 -1
  73. snowflake/ml/modeling/discriminant_analysis/quadratic_discriminant_analysis.py +1 -1
  74. snowflake/ml/modeling/ensemble/ada_boost_classifier.py +1 -1
  75. snowflake/ml/modeling/ensemble/ada_boost_regressor.py +1 -1
  76. snowflake/ml/modeling/ensemble/bagging_classifier.py +1 -1
  77. snowflake/ml/modeling/ensemble/bagging_regressor.py +1 -1
  78. snowflake/ml/modeling/ensemble/extra_trees_classifier.py +1 -1
  79. snowflake/ml/modeling/ensemble/extra_trees_regressor.py +1 -1
  80. snowflake/ml/modeling/ensemble/gradient_boosting_classifier.py +1 -1
  81. snowflake/ml/modeling/ensemble/gradient_boosting_regressor.py +1 -1
  82. snowflake/ml/modeling/ensemble/hist_gradient_boosting_classifier.py +1 -1
  83. snowflake/ml/modeling/ensemble/hist_gradient_boosting_regressor.py +1 -1
  84. snowflake/ml/modeling/ensemble/isolation_forest.py +1 -1
  85. snowflake/ml/modeling/ensemble/random_forest_classifier.py +1 -1
  86. snowflake/ml/modeling/ensemble/random_forest_regressor.py +1 -1
  87. snowflake/ml/modeling/ensemble/stacking_regressor.py +1 -1
  88. snowflake/ml/modeling/ensemble/voting_classifier.py +1 -1
  89. snowflake/ml/modeling/ensemble/voting_regressor.py +1 -1
  90. snowflake/ml/modeling/feature_selection/generic_univariate_select.py +1 -1
  91. snowflake/ml/modeling/feature_selection/select_fdr.py +1 -1
  92. snowflake/ml/modeling/feature_selection/select_fpr.py +1 -1
  93. snowflake/ml/modeling/feature_selection/select_fwe.py +1 -1
  94. snowflake/ml/modeling/feature_selection/select_k_best.py +1 -1
  95. snowflake/ml/modeling/feature_selection/select_percentile.py +1 -1
  96. snowflake/ml/modeling/feature_selection/sequential_feature_selector.py +1 -1
  97. snowflake/ml/modeling/feature_selection/variance_threshold.py +1 -1
  98. snowflake/ml/modeling/gaussian_process/gaussian_process_classifier.py +1 -1
  99. snowflake/ml/modeling/gaussian_process/gaussian_process_regressor.py +1 -1
  100. snowflake/ml/modeling/impute/iterative_imputer.py +1 -1
  101. snowflake/ml/modeling/impute/knn_imputer.py +1 -1
  102. snowflake/ml/modeling/impute/missing_indicator.py +1 -1
  103. snowflake/ml/modeling/kernel_approximation/additive_chi2_sampler.py +1 -1
  104. snowflake/ml/modeling/kernel_approximation/nystroem.py +1 -1
  105. snowflake/ml/modeling/kernel_approximation/polynomial_count_sketch.py +1 -1
  106. snowflake/ml/modeling/kernel_approximation/rbf_sampler.py +1 -1
  107. snowflake/ml/modeling/kernel_approximation/skewed_chi2_sampler.py +1 -1
  108. snowflake/ml/modeling/kernel_ridge/kernel_ridge.py +1 -1
  109. snowflake/ml/modeling/lightgbm/lgbm_classifier.py +1 -1
  110. snowflake/ml/modeling/lightgbm/lgbm_regressor.py +1 -1
  111. snowflake/ml/modeling/linear_model/ard_regression.py +1 -1
  112. snowflake/ml/modeling/linear_model/bayesian_ridge.py +1 -1
  113. snowflake/ml/modeling/linear_model/elastic_net.py +1 -1
  114. snowflake/ml/modeling/linear_model/elastic_net_cv.py +1 -1
  115. snowflake/ml/modeling/linear_model/gamma_regressor.py +1 -1
  116. snowflake/ml/modeling/linear_model/huber_regressor.py +1 -1
  117. snowflake/ml/modeling/linear_model/lars.py +1 -1
  118. snowflake/ml/modeling/linear_model/lars_cv.py +1 -1
  119. snowflake/ml/modeling/linear_model/lasso.py +1 -1
  120. snowflake/ml/modeling/linear_model/lasso_cv.py +1 -1
  121. snowflake/ml/modeling/linear_model/lasso_lars.py +1 -1
  122. snowflake/ml/modeling/linear_model/lasso_lars_cv.py +1 -1
  123. snowflake/ml/modeling/linear_model/lasso_lars_ic.py +1 -1
  124. snowflake/ml/modeling/linear_model/linear_regression.py +1 -1
  125. snowflake/ml/modeling/linear_model/logistic_regression.py +1 -1
  126. snowflake/ml/modeling/linear_model/logistic_regression_cv.py +1 -1
  127. snowflake/ml/modeling/linear_model/multi_task_elastic_net.py +1 -1
  128. snowflake/ml/modeling/linear_model/multi_task_elastic_net_cv.py +1 -1
  129. snowflake/ml/modeling/linear_model/multi_task_lasso.py +1 -1
  130. snowflake/ml/modeling/linear_model/multi_task_lasso_cv.py +1 -1
  131. snowflake/ml/modeling/linear_model/orthogonal_matching_pursuit.py +1 -1
  132. snowflake/ml/modeling/linear_model/passive_aggressive_classifier.py +1 -1
  133. snowflake/ml/modeling/linear_model/passive_aggressive_regressor.py +1 -1
  134. snowflake/ml/modeling/linear_model/perceptron.py +1 -1
  135. snowflake/ml/modeling/linear_model/poisson_regressor.py +1 -1
  136. snowflake/ml/modeling/linear_model/ransac_regressor.py +1 -1
  137. snowflake/ml/modeling/linear_model/ridge.py +1 -1
  138. snowflake/ml/modeling/linear_model/ridge_classifier.py +1 -1
  139. snowflake/ml/modeling/linear_model/ridge_classifier_cv.py +1 -1
  140. snowflake/ml/modeling/linear_model/ridge_cv.py +1 -1
  141. snowflake/ml/modeling/linear_model/sgd_classifier.py +1 -1
  142. snowflake/ml/modeling/linear_model/sgd_one_class_svm.py +1 -1
  143. snowflake/ml/modeling/linear_model/sgd_regressor.py +1 -1
  144. snowflake/ml/modeling/linear_model/theil_sen_regressor.py +1 -1
  145. snowflake/ml/modeling/linear_model/tweedie_regressor.py +1 -1
  146. snowflake/ml/modeling/manifold/isomap.py +1 -1
  147. snowflake/ml/modeling/manifold/mds.py +1 -1
  148. snowflake/ml/modeling/manifold/spectral_embedding.py +1 -1
  149. snowflake/ml/modeling/manifold/tsne.py +1 -1
  150. snowflake/ml/modeling/mixture/bayesian_gaussian_mixture.py +1 -1
  151. snowflake/ml/modeling/mixture/gaussian_mixture.py +1 -1
  152. snowflake/ml/modeling/multiclass/one_vs_one_classifier.py +1 -1
  153. snowflake/ml/modeling/multiclass/one_vs_rest_classifier.py +1 -1
  154. snowflake/ml/modeling/multiclass/output_code_classifier.py +1 -1
  155. snowflake/ml/modeling/naive_bayes/bernoulli_nb.py +1 -1
  156. snowflake/ml/modeling/naive_bayes/categorical_nb.py +1 -1
  157. snowflake/ml/modeling/naive_bayes/complement_nb.py +1 -1
  158. snowflake/ml/modeling/naive_bayes/gaussian_nb.py +1 -1
  159. snowflake/ml/modeling/naive_bayes/multinomial_nb.py +1 -1
  160. snowflake/ml/modeling/neighbors/k_neighbors_classifier.py +1 -1
  161. snowflake/ml/modeling/neighbors/k_neighbors_regressor.py +1 -1
  162. snowflake/ml/modeling/neighbors/kernel_density.py +1 -1
  163. snowflake/ml/modeling/neighbors/local_outlier_factor.py +1 -1
  164. snowflake/ml/modeling/neighbors/nearest_centroid.py +1 -1
  165. snowflake/ml/modeling/neighbors/nearest_neighbors.py +1 -1
  166. snowflake/ml/modeling/neighbors/neighborhood_components_analysis.py +1 -1
  167. snowflake/ml/modeling/neighbors/radius_neighbors_classifier.py +1 -1
  168. snowflake/ml/modeling/neighbors/radius_neighbors_regressor.py +1 -1
  169. snowflake/ml/modeling/neural_network/bernoulli_rbm.py +1 -1
  170. snowflake/ml/modeling/neural_network/mlp_classifier.py +1 -1
  171. snowflake/ml/modeling/neural_network/mlp_regressor.py +1 -1
  172. snowflake/ml/modeling/preprocessing/polynomial_features.py +1 -1
  173. snowflake/ml/modeling/semi_supervised/label_propagation.py +1 -1
  174. snowflake/ml/modeling/semi_supervised/label_spreading.py +1 -1
  175. snowflake/ml/modeling/svm/linear_svc.py +1 -1
  176. snowflake/ml/modeling/svm/linear_svr.py +1 -1
  177. snowflake/ml/modeling/svm/nu_svc.py +1 -1
  178. snowflake/ml/modeling/svm/nu_svr.py +1 -1
  179. snowflake/ml/modeling/svm/svc.py +1 -1
  180. snowflake/ml/modeling/svm/svr.py +1 -1
  181. snowflake/ml/modeling/tree/decision_tree_classifier.py +1 -1
  182. snowflake/ml/modeling/tree/decision_tree_regressor.py +1 -1
  183. snowflake/ml/modeling/tree/extra_tree_classifier.py +1 -1
  184. snowflake/ml/modeling/tree/extra_tree_regressor.py +1 -1
  185. snowflake/ml/modeling/xgboost/xgb_classifier.py +1 -1
  186. snowflake/ml/modeling/xgboost/xgb_regressor.py +1 -1
  187. snowflake/ml/modeling/xgboost/xgbrf_classifier.py +1 -1
  188. snowflake/ml/modeling/xgboost/xgbrf_regressor.py +1 -1
  189. snowflake/ml/monitoring/_client/model_monitor_sql_client.py +91 -6
  190. snowflake/ml/monitoring/_manager/model_monitor_manager.py +3 -0
  191. snowflake/ml/monitoring/entities/model_monitor_config.py +3 -0
  192. snowflake/ml/monitoring/model_monitor.py +26 -0
  193. snowflake/ml/version.py +1 -1
  194. {snowflake_ml_python-1.11.0.dist-info → snowflake_ml_python-1.13.0.dist-info}/METADATA +82 -5
  195. {snowflake_ml_python-1.11.0.dist-info → snowflake_ml_python-1.13.0.dist-info}/RECORD +198 -194
  196. {snowflake_ml_python-1.11.0.dist-info → snowflake_ml_python-1.13.0.dist-info}/WHEEL +0 -0
  197. {snowflake_ml_python-1.11.0.dist-info → snowflake_ml_python-1.13.0.dist-info}/licenses/LICENSE.txt +0 -0
  198. {snowflake_ml_python-1.11.0.dist-info → snowflake_ml_python-1.13.0.dist-info}/top_level.txt +0 -0
@@ -1,3 +1,4 @@
1
+ from enum import Enum, auto
1
2
  from typing import Any, Mapping, Optional
2
3
 
3
4
  from snowflake import snowpark
@@ -15,6 +16,25 @@ MODEL_JSON_MODEL_NAME_FIELD = "model_name"
15
16
  MODEL_JSON_VERSION_NAME_FIELD = "version_name"
16
17
 
17
18
 
19
+ class MonitorOperation(Enum):
20
+ SUSPEND = auto()
21
+ RESUME = auto()
22
+ ADD = auto()
23
+ DROP = auto()
24
+
25
+ @property
26
+ def supported_target_properties(self) -> frozenset[str]:
27
+ return _OPERATION_SUPPORTED_PROPS[self]
28
+
29
+
30
+ _OPERATION_SUPPORTED_PROPS: dict[MonitorOperation, frozenset[str]] = {
31
+ MonitorOperation.SUSPEND: frozenset(),
32
+ MonitorOperation.RESUME: frozenset(),
33
+ MonitorOperation.ADD: frozenset({"SEGMENT_COLUMN"}),
34
+ MonitorOperation.DROP: frozenset({"SEGMENT_COLUMN"}),
35
+ }
36
+
37
+
18
38
  def _build_sql_list_from_columns(columns: list[sql_identifier.SqlIdentifier]) -> str:
19
39
  sql_list = ", ".join([f"'{column}'" for column in columns])
20
40
  return f"({sql_list})"
@@ -70,11 +90,17 @@ class ModelMonitorSQLClient:
70
90
  baseline_database: Optional[sql_identifier.SqlIdentifier] = None,
71
91
  baseline_schema: Optional[sql_identifier.SqlIdentifier] = None,
72
92
  baseline: Optional[sql_identifier.SqlIdentifier] = None,
93
+ segment_columns: Optional[list[sql_identifier.SqlIdentifier]] = None,
73
94
  statement_params: Optional[dict[str, Any]] = None,
74
95
  ) -> None:
75
96
  baseline_sql = ""
76
97
  if baseline:
77
98
  baseline_sql = f"""BASELINE={self._infer_qualified_schema(baseline_database, baseline_schema)}.{baseline}"""
99
+
100
+ segment_columns_sql = ""
101
+ if segment_columns:
102
+ segment_columns_sql = f"SEGMENT_COLUMNS={_build_sql_list_from_columns(segment_columns)}"
103
+
78
104
  query_result_checker.SqlResultValidator(
79
105
  self._sql_client._session,
80
106
  f"""
@@ -93,6 +119,7 @@ class ModelMonitorSQLClient:
93
119
  TIMESTAMP_COLUMN='{timestamp_column}'
94
120
  REFRESH_INTERVAL='{refresh_interval}'
95
121
  AGGREGATION_WINDOW='{aggregation_window}'
122
+ {segment_columns_sql}
96
123
  {baseline_sql}""",
97
124
  statement_params=statement_params,
98
125
  ).has_column("status").has_dimensions(1, 1).validate()
@@ -182,6 +209,7 @@ class ModelMonitorSQLClient:
182
209
  actual_score_columns: list[sql_identifier.SqlIdentifier],
183
210
  actual_class_columns: list[sql_identifier.SqlIdentifier],
184
211
  id_columns: list[sql_identifier.SqlIdentifier],
212
+ segment_columns: Optional[list[sql_identifier.SqlIdentifier]] = None,
185
213
  ) -> None:
186
214
  """Ensures all columns exist in the source table.
187
215
 
@@ -193,11 +221,14 @@ class ModelMonitorSQLClient:
193
221
  actual_score_columns: List of actual score column names.
194
222
  actual_class_columns: List of actual class column names.
195
223
  id_columns: List of id column names.
224
+ segment_columns: List of segment column names.
196
225
 
197
226
  Raises:
198
227
  ValueError: If any of the columns do not exist in the source.
199
228
  """
200
229
 
230
+ segment_columns = [] if segment_columns is None else segment_columns
231
+
201
232
  if timestamp_column not in source_column_schema:
202
233
  raise ValueError(f"Timestamp column {timestamp_column} does not exist in source.")
203
234
 
@@ -214,6 +245,9 @@ class ModelMonitorSQLClient:
214
245
  if not all([column_name in source_column_schema for column_name in id_columns]):
215
246
  raise ValueError(f"ID column(s): {id_columns} do not exist in source.")
216
247
 
248
+ if not all([column_name in source_column_schema for column_name in segment_columns]):
249
+ raise ValueError(f"Segment column(s): {segment_columns} do not exist in source.")
250
+
217
251
  def validate_source(
218
252
  self,
219
253
  *,
@@ -226,7 +260,9 @@ class ModelMonitorSQLClient:
226
260
  actual_score_columns: list[sql_identifier.SqlIdentifier],
227
261
  actual_class_columns: list[sql_identifier.SqlIdentifier],
228
262
  id_columns: list[sql_identifier.SqlIdentifier],
263
+ segment_columns: Optional[list[sql_identifier.SqlIdentifier]] = None,
229
264
  ) -> None:
265
+
230
266
  source_database = source_database or self._database_name
231
267
  source_schema = source_schema or self._schema_name
232
268
  # Get Schema of the source. Implicitly validates that the source exists.
@@ -244,19 +280,38 @@ class ModelMonitorSQLClient:
244
280
  actual_score_columns=actual_score_columns,
245
281
  actual_class_columns=actual_class_columns,
246
282
  id_columns=id_columns,
283
+ segment_columns=segment_columns,
247
284
  )
248
285
 
249
286
  def _alter_monitor(
250
287
  self,
251
- operation: str,
288
+ operation: MonitorOperation,
252
289
  monitor_name: sql_identifier.SqlIdentifier,
290
+ target_property: Optional[str] = None,
291
+ target_value: Optional[sql_identifier.SqlIdentifier] = None,
253
292
  statement_params: Optional[dict[str, Any]] = None,
254
293
  ) -> None:
255
- if operation not in {"SUSPEND", "RESUME"}:
256
- raise ValueError(f"Operation {operation} not supported for altering Dynamic Tables")
294
+ supported_target_properties = operation.supported_target_properties
295
+
296
+ if supported_target_properties:
297
+ if target_property is None or target_value is None:
298
+ raise ValueError(f"Target property and value must be provided for {operation.name} operation")
299
+
300
+ if target_property not in supported_target_properties:
301
+ raise ValueError(
302
+ f"Only {', '.join(supported_target_properties)} supported as target property "
303
+ f"for {operation.name} operation"
304
+ )
305
+
306
+ property_clause = f"{target_property}={target_value}" if target_property and target_value else ""
307
+ alter_momo_sql = (
308
+ f"""ALTER MODEL MONITOR {self._database_name}.{self._schema_name}.{monitor_name} """
309
+ f"""{operation.name} {property_clause}"""
310
+ )
311
+
257
312
  query_result_checker.SqlResultValidator(
258
313
  self._sql_client._session,
259
- f"""ALTER MODEL MONITOR {self._database_name}.{self._schema_name}.{monitor_name} {operation}""",
314
+ alter_momo_sql,
260
315
  statement_params=statement_params,
261
316
  ).has_column("status").has_dimensions(1, 1).validate()
262
317
 
@@ -266,7 +321,7 @@ class ModelMonitorSQLClient:
266
321
  statement_params: Optional[dict[str, Any]] = None,
267
322
  ) -> None:
268
323
  self._alter_monitor(
269
- operation="SUSPEND",
324
+ operation=MonitorOperation.SUSPEND,
270
325
  monitor_name=monitor_name,
271
326
  statement_params=statement_params,
272
327
  )
@@ -277,7 +332,37 @@ class ModelMonitorSQLClient:
277
332
  statement_params: Optional[dict[str, Any]] = None,
278
333
  ) -> None:
279
334
  self._alter_monitor(
280
- operation="RESUME",
335
+ operation=MonitorOperation.RESUME,
336
+ monitor_name=monitor_name,
337
+ statement_params=statement_params,
338
+ )
339
+
340
+ def add_segment_column(
341
+ self,
342
+ monitor_name: sql_identifier.SqlIdentifier,
343
+ segment_column: sql_identifier.SqlIdentifier,
344
+ statement_params: Optional[dict[str, Any]] = None,
345
+ ) -> None:
346
+ """Add a segment column to the Model Monitor"""
347
+ self._alter_monitor(
348
+ operation=MonitorOperation.ADD,
349
+ monitor_name=monitor_name,
350
+ target_property="SEGMENT_COLUMN",
351
+ target_value=segment_column,
352
+ statement_params=statement_params,
353
+ )
354
+
355
+ def drop_segment_column(
356
+ self,
357
+ monitor_name: sql_identifier.SqlIdentifier,
358
+ segment_column: sql_identifier.SqlIdentifier,
359
+ statement_params: Optional[dict[str, Any]] = None,
360
+ ) -> None:
361
+ """Drop a segment column from the Model Monitor"""
362
+ self._alter_monitor(
363
+ operation=MonitorOperation.DROP,
281
364
  monitor_name=monitor_name,
365
+ target_property="SEGMENT_COLUMN",
366
+ target_value=segment_column,
282
367
  statement_params=statement_params,
283
368
  )
@@ -108,6 +108,7 @@ class ModelMonitorManager:
108
108
  prediction_class_columns = self._build_column_list_from_input(source_config.prediction_class_columns)
109
109
  actual_score_columns = self._build_column_list_from_input(source_config.actual_score_columns)
110
110
  actual_class_columns = self._build_column_list_from_input(source_config.actual_class_columns)
111
+ segment_columns = self._build_column_list_from_input(source_config.segment_columns)
111
112
 
112
113
  id_columns = [sql_identifier.SqlIdentifier(column_name) for column_name in source_config.id_columns]
113
114
  ts_column = sql_identifier.SqlIdentifier(source_config.timestamp_column)
@@ -123,6 +124,7 @@ class ModelMonitorManager:
123
124
  actual_score_columns=actual_score_columns,
124
125
  actual_class_columns=actual_class_columns,
125
126
  id_columns=id_columns,
127
+ segment_columns=segment_columns,
126
128
  )
127
129
 
128
130
  self._model_monitor_client.create_model_monitor(
@@ -144,6 +146,7 @@ class ModelMonitorManager:
144
146
  prediction_class_columns=prediction_class_columns,
145
147
  actual_score_columns=actual_score_columns,
146
148
  actual_class_columns=actual_class_columns,
149
+ segment_columns=segment_columns,
147
150
  refresh_interval=model_monitor_config.refresh_interval,
148
151
  aggregation_window=model_monitor_config.aggregation_window,
149
152
  baseline_database=baseline_database_name_id,
@@ -33,6 +33,9 @@ class ModelMonitorSourceConfig:
33
33
  baseline: Optional[str] = None
34
34
  """Name of table containing the baseline data."""
35
35
 
36
+ segment_columns: Optional[list[str]] = None
37
+ """List of columns in the source containing segment information for grouped monitoring."""
38
+
36
39
 
37
40
  @dataclass
38
41
  class ModelMonitorConfig:
@@ -46,3 +46,29 @@ class ModelMonitor:
46
46
  telemetry.TelemetrySubProject.MONITORING.value,
47
47
  )
48
48
  self._model_monitor_client.resume_monitor(self.name, statement_params=statement_params)
49
+
50
+ @telemetry.send_api_usage_telemetry(
51
+ project=telemetry.TelemetryProject.MLOPS.value,
52
+ subproject=telemetry.TelemetrySubProject.MONITORING.value,
53
+ )
54
+ def add_segment_column(self, segment_column: str) -> None:
55
+ """Add a segment column to the Model Monitor"""
56
+ statement_params = telemetry.get_statement_params(
57
+ telemetry.TelemetryProject.MLOPS.value,
58
+ telemetry.TelemetrySubProject.MONITORING.value,
59
+ )
60
+ segment_column_id = sql_identifier.SqlIdentifier(segment_column)
61
+ self._model_monitor_client.add_segment_column(self.name, segment_column_id, statement_params=statement_params)
62
+
63
+ @telemetry.send_api_usage_telemetry(
64
+ project=telemetry.TelemetryProject.MLOPS.value,
65
+ subproject=telemetry.TelemetrySubProject.MONITORING.value,
66
+ )
67
+ def drop_segment_column(self, segment_column: str) -> None:
68
+ """Drop a segment column from the Model Monitor"""
69
+ statement_params = telemetry.get_statement_params(
70
+ telemetry.TelemetryProject.MLOPS.value,
71
+ telemetry.TelemetrySubProject.MONITORING.value,
72
+ )
73
+ segment_column_id = sql_identifier.SqlIdentifier(segment_column)
74
+ self._model_monitor_client.drop_segment_column(self.name, segment_column_id, statement_params=statement_params)
snowflake/ml/version.py CHANGED
@@ -1,2 +1,2 @@
1
1
  # This is parsed by regex in conda recipe meta file. Make sure not to break it.
2
- VERSION = "1.11.0"
2
+ VERSION = "1.13.0"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: snowflake-ml-python
3
- Version: 1.11.0
3
+ Version: 1.13.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:
@@ -244,17 +244,17 @@ Requires-Dist: numpy<3,>=1.23
244
244
  Requires-Dist: packaging<25,>=20.9
245
245
  Requires-Dist: pandas<3,>=2.1.4
246
246
  Requires-Dist: platformdirs<5
247
- Requires-Dist: pyarrow
247
+ Requires-Dist: pyarrow<19.0.0
248
248
  Requires-Dist: pydantic<3,>=2.8.2
249
249
  Requires-Dist: pyjwt<3,>=2.0.0
250
250
  Requires-Dist: pytimeparse<2,>=1.1.8
251
251
  Requires-Dist: pyyaml<7,>=6.0
252
252
  Requires-Dist: retrying<2,>=1.3.3
253
253
  Requires-Dist: s3fs<2026,>=2024.6.1
254
- Requires-Dist: scikit-learn<1.6
254
+ Requires-Dist: scikit-learn<1.7
255
255
  Requires-Dist: scipy<2,>=1.9
256
256
  Requires-Dist: shap<1,>=0.46.0
257
- Requires-Dist: snowflake-connector-python[pandas]<4,>=3.15.0
257
+ Requires-Dist: snowflake-connector-python[pandas]<4,>=3.16.0
258
258
  Requires-Dist: snowflake-snowpark-python!=1.26.0,<2,>=1.17.0
259
259
  Requires-Dist: snowflake.core<2,>=1.0.2
260
260
  Requires-Dist: sqlparse<1,>=0.4
@@ -410,7 +410,84 @@ NOTE: Version 1.7.0 is used as example here. Please choose the the latest versio
410
410
 
411
411
  # Release History
412
412
 
413
- ## 1.11.0
413
+ ## 1.13.0
414
+
415
+ ### Bug Fixes
416
+
417
+ ### Behavior Changes
418
+
419
+ ### New Features
420
+
421
+ * Registry: Log a HuggingFace model without having to load the model in memory using
422
+ the `huggingface_pipeline.HuggingFacePipelineModel`. Requires `huggingface_hub` package to installed.
423
+ To disable downloading HuggingFace repository, provide `download_snapshot=False` while creating the
424
+ `huggingface_pipeline.HuggingFacePipelineModel` object.
425
+ * Registry: Added support for XGBoost models to use `enable_categorical=True` with pandas DataFrame
426
+ * Registry: Added support to display privatelink inference endpoint in ModelVersion list services.
427
+
428
+ ## 1.12.0
429
+
430
+ ### Bug Fixes
431
+
432
+ * Registry: Fixed an issue where the string representation of dictionary-type output columns was being incorrectly
433
+ created during structured output deserialization. Now, the original data type is properly preserved.
434
+ * Registry: Fixed the inference server performance issue for wide (500+ features) and JSON inputs.
435
+
436
+ ### Behavior Changes
437
+
438
+ ### New Features
439
+
440
+ * Registry: Add OpenAI chat completion compatible signature option for `text-generation` models.
441
+
442
+ ```python
443
+ from snowflake.ml.model import openai_signatures
444
+ import pandas as pd
445
+
446
+ mv = snowflake_registry.log_model(
447
+ model=generator,
448
+ model_name=...,
449
+ ...,
450
+ signatures=openai_signatures.OPENAI_CHAT_SIGNATURE,
451
+ )
452
+
453
+ # create a pd.DataFrame with openai.client.chat.completions arguments like below:
454
+ x_df = pd.DataFrame.from_records(
455
+ [
456
+ {
457
+ "messages": [
458
+ {"role": "system", "content": "Complete the sentence."},
459
+ {
460
+ "role": "user",
461
+ "content": "A descendant of the Lost City of Atlantis, who swam to Earth while saying, ",
462
+ },
463
+ ],
464
+ "max_completion_tokens": 250,
465
+ "temperature": 0.9,
466
+ "stop": None,
467
+ "n": 3,
468
+ "stream": False,
469
+ "top_p": 1.0,
470
+ "frequency_penalty": 0.1,
471
+ "presence_penalty": 0.2,
472
+ }
473
+ ],
474
+ )
475
+
476
+ # OpenAI Chat Completion compatible output
477
+ output_df = mv.run(X=x_df)
478
+ ```
479
+
480
+ * Model Monitoring: Added support for segment columns to enable filtered analysis.
481
+ * Added `segment_columns` parameter to `ModelMonitorSourceConfig` to specify columns for segmenting monitoring data
482
+ * Segment columns must be of STRING type and exist in the source table
483
+ * Added methods to dynamically manage segments:
484
+ * `add_segment_column()`: Add a new segment column to an existing monitor
485
+ * `drop_segment_column()`: Remove a segment column from an existing monitor
486
+ * Experiment Tracking (PrPr): Support for logging artifacts (files and directories) with `log_artifact`
487
+ * Experiment Tracking (PrPr): Support for listing artifacts in a run with `list_artifacts`
488
+ * Experiment Tracking (PrPr): Support for downloading artifacts in a run with `download_artifacts`
489
+
490
+ ## 1.11.0 (08-12-2025)
414
491
 
415
492
  ### Bug Fixes
416
493