snowflake-ml-python 1.6.4__py3-none-any.whl → 1.7.1__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 (176) hide show
  1. snowflake/cortex/__init__.py +4 -0
  2. snowflake/cortex/_complete.py +107 -64
  3. snowflake/cortex/_finetune.py +273 -0
  4. snowflake/cortex/_sse_client.py +91 -28
  5. snowflake/cortex/_util.py +30 -1
  6. snowflake/ml/_internal/telemetry.py +4 -2
  7. snowflake/ml/_internal/type_utils.py +3 -3
  8. snowflake/ml/_internal/utils/import_utils.py +31 -0
  9. snowflake/ml/_internal/utils/snowpark_dataframe_utils.py +13 -0
  10. snowflake/ml/data/__init__.py +5 -0
  11. snowflake/ml/data/_internal/arrow_ingestor.py +8 -0
  12. snowflake/ml/data/data_connector.py +1 -1
  13. snowflake/ml/data/torch_utils.py +33 -14
  14. snowflake/ml/feature_store/examples/airline_features/features/plane_features.py +5 -3
  15. snowflake/ml/feature_store/examples/airline_features/features/weather_features.py +7 -5
  16. snowflake/ml/feature_store/examples/citibike_trip_features/features/station_feature.py +4 -2
  17. snowflake/ml/feature_store/examples/citibike_trip_features/features/trip_feature.py +3 -1
  18. snowflake/ml/feature_store/examples/example_helper.py +6 -3
  19. snowflake/ml/feature_store/examples/new_york_taxi_features/features/location_features.py +4 -2
  20. snowflake/ml/feature_store/examples/new_york_taxi_features/features/trip_features.py +4 -2
  21. snowflake/ml/feature_store/examples/wine_quality_features/features/managed_wine_features.py +3 -1
  22. snowflake/ml/feature_store/examples/wine_quality_features/features/static_wine_features.py +3 -1
  23. snowflake/ml/feature_store/feature_store.py +1 -2
  24. snowflake/ml/feature_store/feature_view.py +5 -1
  25. snowflake/ml/model/_client/model/model_version_impl.py +145 -11
  26. snowflake/ml/model/_client/ops/model_ops.py +56 -16
  27. snowflake/ml/model/_client/ops/service_ops.py +46 -30
  28. snowflake/ml/model/_client/service/model_deployment_spec.py +19 -8
  29. snowflake/ml/model/_client/service/model_deployment_spec_schema.py +3 -1
  30. snowflake/ml/model/_client/sql/service.py +25 -1
  31. snowflake/ml/model/_model_composer/model_composer.py +2 -0
  32. snowflake/ml/model/_model_composer/model_manifest/model_manifest.py +4 -0
  33. snowflake/ml/model/_model_composer/model_manifest/model_manifest_schema.py +1 -0
  34. snowflake/ml/model/_model_composer/model_method/infer_function.py_template +2 -1
  35. snowflake/ml/model/_model_composer/model_method/model_method.py +1 -1
  36. snowflake/ml/model/_packager/model_env/model_env.py +12 -0
  37. snowflake/ml/model/_packager/model_handlers/_utils.py +6 -2
  38. snowflake/ml/model/_packager/model_handlers/catboost.py +4 -7
  39. snowflake/ml/model/_packager/model_handlers/custom.py +5 -1
  40. snowflake/ml/model/_packager/model_handlers/huggingface_pipeline.py +10 -1
  41. snowflake/ml/model/_packager/model_handlers/lightgbm.py +5 -7
  42. snowflake/ml/model/_packager/model_handlers/sentence_transformers.py +8 -1
  43. snowflake/ml/model/_packager/model_handlers/sklearn.py +51 -7
  44. snowflake/ml/model/_packager/model_handlers/snowmlmodel.py +8 -66
  45. snowflake/ml/model/_packager/model_handlers/tensorflow.py +23 -6
  46. snowflake/ml/model/_packager/model_handlers/torchscript.py +14 -14
  47. snowflake/ml/model/_packager/model_handlers/xgboost.py +10 -40
  48. snowflake/ml/model/_packager/model_meta/_packaging_requirements.py +2 -3
  49. snowflake/ml/model/_packager/model_meta/model_meta_schema.py +5 -0
  50. snowflake/ml/model/_packager/model_packager.py +0 -11
  51. snowflake/ml/model/_packager/model_runtime/_snowml_inference_alternative_requirements.py +2 -10
  52. snowflake/ml/model/_packager/model_runtime/model_runtime.py +4 -9
  53. snowflake/ml/model/_packager/{model_handlers/model_objective_utils.py → model_task/model_task_utils.py} +14 -26
  54. snowflake/ml/model/_signatures/core.py +63 -16
  55. snowflake/ml/model/_signatures/pandas_handler.py +87 -27
  56. snowflake/ml/model/_signatures/pytorch_handler.py +2 -2
  57. snowflake/ml/model/_signatures/snowpark_handler.py +2 -1
  58. snowflake/ml/model/_signatures/tensorflow_handler.py +2 -2
  59. snowflake/ml/model/_signatures/utils.py +4 -0
  60. snowflake/ml/model/custom_model.py +47 -7
  61. snowflake/ml/model/model_signature.py +40 -9
  62. snowflake/ml/model/type_hints.py +9 -1
  63. snowflake/ml/modeling/_internal/estimator_utils.py +13 -0
  64. snowflake/ml/modeling/_internal/local_implementations/pandas_handlers.py +7 -2
  65. snowflake/ml/modeling/_internal/snowpark_implementations/distributed_hpo_trainer.py +16 -5
  66. snowflake/ml/modeling/_internal/snowpark_implementations/snowpark_handlers.py +8 -2
  67. snowflake/ml/modeling/_internal/snowpark_implementations/snowpark_trainer.py +9 -3
  68. snowflake/ml/modeling/calibration/calibrated_classifier_cv.py +1 -8
  69. snowflake/ml/modeling/cluster/agglomerative_clustering.py +17 -19
  70. snowflake/ml/modeling/cluster/dbscan.py +5 -2
  71. snowflake/ml/modeling/cluster/feature_agglomeration.py +7 -19
  72. snowflake/ml/modeling/cluster/k_means.py +14 -19
  73. snowflake/ml/modeling/cluster/mini_batch_k_means.py +3 -3
  74. snowflake/ml/modeling/cluster/optics.py +6 -6
  75. snowflake/ml/modeling/cluster/spectral_clustering.py +4 -3
  76. snowflake/ml/modeling/compose/column_transformer.py +15 -5
  77. snowflake/ml/modeling/compose/transformed_target_regressor.py +7 -6
  78. snowflake/ml/modeling/covariance/elliptic_envelope.py +1 -1
  79. snowflake/ml/modeling/covariance/graphical_lasso_cv.py +1 -1
  80. snowflake/ml/modeling/covariance/min_cov_det.py +2 -2
  81. snowflake/ml/modeling/covariance/oas.py +1 -1
  82. snowflake/ml/modeling/decomposition/kernel_pca.py +2 -2
  83. snowflake/ml/modeling/decomposition/mini_batch_dictionary_learning.py +5 -12
  84. snowflake/ml/modeling/decomposition/mini_batch_sparse_pca.py +5 -12
  85. snowflake/ml/modeling/decomposition/pca.py +28 -15
  86. snowflake/ml/modeling/discriminant_analysis/linear_discriminant_analysis.py +6 -0
  87. snowflake/ml/modeling/ensemble/ada_boost_classifier.py +1 -12
  88. snowflake/ml/modeling/ensemble/ada_boost_regressor.py +1 -11
  89. snowflake/ml/modeling/ensemble/bagging_classifier.py +1 -8
  90. snowflake/ml/modeling/ensemble/bagging_regressor.py +1 -8
  91. snowflake/ml/modeling/ensemble/extra_trees_classifier.py +21 -2
  92. snowflake/ml/modeling/ensemble/extra_trees_regressor.py +18 -2
  93. snowflake/ml/modeling/ensemble/gradient_boosting_classifier.py +2 -0
  94. snowflake/ml/modeling/ensemble/gradient_boosting_regressor.py +2 -0
  95. snowflake/ml/modeling/ensemble/hist_gradient_boosting_classifier.py +21 -8
  96. snowflake/ml/modeling/ensemble/hist_gradient_boosting_regressor.py +21 -11
  97. snowflake/ml/modeling/ensemble/random_forest_classifier.py +21 -2
  98. snowflake/ml/modeling/ensemble/random_forest_regressor.py +18 -2
  99. snowflake/ml/modeling/feature_selection/generic_univariate_select.py +2 -1
  100. snowflake/ml/modeling/feature_selection/sequential_feature_selector.py +5 -3
  101. snowflake/ml/modeling/kernel_ridge/kernel_ridge.py +2 -2
  102. snowflake/ml/modeling/lightgbm/lgbm_classifier.py +2 -4
  103. snowflake/ml/modeling/lightgbm/lgbm_regressor.py +2 -4
  104. snowflake/ml/modeling/linear_model/ard_regression.py +5 -10
  105. snowflake/ml/modeling/linear_model/bayesian_ridge.py +5 -11
  106. snowflake/ml/modeling/linear_model/elastic_net.py +3 -0
  107. snowflake/ml/modeling/linear_model/elastic_net_cv.py +1 -1
  108. snowflake/ml/modeling/linear_model/lars.py +0 -10
  109. snowflake/ml/modeling/linear_model/lars_cv.py +1 -11
  110. snowflake/ml/modeling/linear_model/lasso_cv.py +1 -1
  111. snowflake/ml/modeling/linear_model/lasso_lars.py +0 -10
  112. snowflake/ml/modeling/linear_model/lasso_lars_cv.py +1 -11
  113. snowflake/ml/modeling/linear_model/lasso_lars_ic.py +0 -10
  114. snowflake/ml/modeling/linear_model/logistic_regression.py +28 -22
  115. snowflake/ml/modeling/linear_model/logistic_regression_cv.py +30 -24
  116. snowflake/ml/modeling/linear_model/multi_task_elastic_net_cv.py +1 -1
  117. snowflake/ml/modeling/linear_model/multi_task_lasso_cv.py +1 -1
  118. snowflake/ml/modeling/linear_model/orthogonal_matching_pursuit.py +4 -13
  119. snowflake/ml/modeling/linear_model/passive_aggressive_classifier.py +4 -4
  120. snowflake/ml/modeling/linear_model/passive_aggressive_regressor.py +1 -1
  121. snowflake/ml/modeling/linear_model/perceptron.py +3 -3
  122. snowflake/ml/modeling/linear_model/ransac_regressor.py +3 -2
  123. snowflake/ml/modeling/linear_model/ridge_classifier_cv.py +14 -6
  124. snowflake/ml/modeling/linear_model/ridge_cv.py +17 -11
  125. snowflake/ml/modeling/linear_model/sgd_classifier.py +2 -2
  126. snowflake/ml/modeling/linear_model/sgd_one_class_svm.py +5 -1
  127. snowflake/ml/modeling/linear_model/sgd_regressor.py +12 -3
  128. snowflake/ml/modeling/manifold/isomap.py +1 -1
  129. snowflake/ml/modeling/manifold/mds.py +3 -3
  130. snowflake/ml/modeling/manifold/tsne.py +10 -4
  131. snowflake/ml/modeling/metrics/classification.py +12 -16
  132. snowflake/ml/modeling/metrics/ranking.py +3 -3
  133. snowflake/ml/modeling/metrics/regression.py +3 -3
  134. snowflake/ml/modeling/naive_bayes/bernoulli_nb.py +3 -3
  135. snowflake/ml/modeling/naive_bayes/categorical_nb.py +3 -3
  136. snowflake/ml/modeling/naive_bayes/complement_nb.py +3 -3
  137. snowflake/ml/modeling/naive_bayes/multinomial_nb.py +3 -3
  138. snowflake/ml/modeling/neighbors/k_neighbors_classifier.py +10 -4
  139. snowflake/ml/modeling/neighbors/k_neighbors_regressor.py +5 -2
  140. snowflake/ml/modeling/neighbors/local_outlier_factor.py +2 -2
  141. snowflake/ml/modeling/neighbors/nearest_centroid.py +7 -14
  142. snowflake/ml/modeling/neighbors/nearest_neighbors.py +1 -1
  143. snowflake/ml/modeling/neighbors/radius_neighbors_classifier.py +6 -1
  144. snowflake/ml/modeling/neighbors/radius_neighbors_regressor.py +1 -1
  145. snowflake/ml/modeling/neural_network/mlp_classifier.py +7 -1
  146. snowflake/ml/modeling/neural_network/mlp_regressor.py +3 -0
  147. snowflake/ml/modeling/pipeline/pipeline.py +16 -14
  148. snowflake/ml/modeling/preprocessing/one_hot_encoder.py +8 -4
  149. snowflake/ml/modeling/preprocessing/ordinal_encoder.py +9 -7
  150. snowflake/ml/modeling/svm/linear_svc.py +25 -16
  151. snowflake/ml/modeling/svm/linear_svr.py +23 -17
  152. snowflake/ml/modeling/svm/nu_svc.py +5 -3
  153. snowflake/ml/modeling/svm/nu_svr.py +3 -1
  154. snowflake/ml/modeling/svm/svc.py +9 -5
  155. snowflake/ml/modeling/svm/svr.py +3 -1
  156. snowflake/ml/modeling/tree/decision_tree_classifier.py +21 -2
  157. snowflake/ml/modeling/tree/decision_tree_regressor.py +18 -2
  158. snowflake/ml/modeling/tree/extra_tree_classifier.py +28 -9
  159. snowflake/ml/modeling/tree/extra_tree_regressor.py +18 -2
  160. snowflake/ml/monitoring/_client/model_monitor_sql_client.py +448 -0
  161. snowflake/ml/monitoring/_manager/model_monitor_manager.py +238 -0
  162. snowflake/ml/monitoring/entities/model_monitor_config.py +10 -10
  163. snowflake/ml/monitoring/model_monitor.py +37 -0
  164. snowflake/ml/registry/_manager/model_manager.py +15 -1
  165. snowflake/ml/registry/registry.py +32 -37
  166. snowflake/ml/version.py +1 -1
  167. {snowflake_ml_python-1.6.4.dist-info → snowflake_ml_python-1.7.1.dist-info}/METADATA +104 -12
  168. {snowflake_ml_python-1.6.4.dist-info → snowflake_ml_python-1.7.1.dist-info}/RECORD +172 -171
  169. {snowflake_ml_python-1.6.4.dist-info → snowflake_ml_python-1.7.1.dist-info}/WHEEL +1 -1
  170. snowflake/ml/monitoring/_client/model_monitor.py +0 -126
  171. snowflake/ml/monitoring/_client/model_monitor_manager.py +0 -361
  172. snowflake/ml/monitoring/_client/monitor_sql_client.py +0 -1335
  173. snowflake/ml/monitoring/entities/model_monitor_interval.py +0 -46
  174. /snowflake/ml/monitoring/{_client/model_monitor_version.py → model_monitor_version.py} +0 -0
  175. {snowflake_ml_python-1.6.4.dist-info → snowflake_ml_python-1.7.1.dist-info}/LICENSE.txt +0 -0
  176. {snowflake_ml_python-1.6.4.dist-info → snowflake_ml_python-1.7.1.dist-info}/top_level.txt +0 -0
@@ -1,17 +1,19 @@
1
1
  from dataclasses import dataclass
2
- from typing import List
2
+ from typing import List, Optional
3
3
 
4
4
  from snowflake.ml.model._client.model import model_version_impl
5
- from snowflake.ml.monitoring.entities import model_monitor_interval
6
5
 
7
6
 
8
7
  @dataclass
9
- class ModelMonitorTableConfig:
10
- source_table: str
8
+ class ModelMonitorSourceConfig:
9
+ source: str
11
10
  timestamp_column: str
12
- prediction_columns: List[str]
13
- label_columns: List[str]
14
11
  id_columns: List[str]
12
+ prediction_score_columns: Optional[List[str]] = None
13
+ prediction_class_columns: Optional[List[str]] = None
14
+ actual_score_columns: Optional[List[str]] = None
15
+ actual_class_columns: Optional[List[str]] = None
16
+ baseline: Optional[str] = None
15
17
 
16
18
 
17
19
  @dataclass
@@ -22,7 +24,5 @@ class ModelMonitorConfig:
22
24
  model_function_name: str
23
25
  background_compute_warehouse_name: str
24
26
  # TODO: Add support for pythonic notion of time.
25
- refresh_interval: str = model_monitor_interval.ModelMonitorRefreshInterval.DAILY
26
- aggregation_window: model_monitor_interval.ModelMonitorAggregationWindow = (
27
- model_monitor_interval.ModelMonitorAggregationWindow.WINDOW_1_DAY
28
- )
27
+ refresh_interval: str = "1 hour"
28
+ aggregation_window: str = "1 day"
@@ -0,0 +1,37 @@
1
+ from snowflake.ml._internal import telemetry
2
+ from snowflake.ml._internal.utils import sql_identifier
3
+ from snowflake.ml.monitoring._client import model_monitor_sql_client
4
+
5
+
6
+ class ModelMonitor:
7
+ """Class to manage instrumentation of Model Monitoring and Observability"""
8
+
9
+ name: sql_identifier.SqlIdentifier
10
+ _model_monitor_client: model_monitor_sql_client.ModelMonitorSQLClient
11
+
12
+ statement_params = telemetry.get_statement_params(
13
+ telemetry.TelemetryProject.MLOPS.value,
14
+ telemetry.TelemetrySubProject.MONITORING.value,
15
+ )
16
+
17
+ def __init__(self) -> None:
18
+ raise RuntimeError("ModelMonitor's initializer is not meant to be used.")
19
+
20
+ @classmethod
21
+ def _ref(
22
+ cls,
23
+ model_monitor_client: model_monitor_sql_client.ModelMonitorSQLClient,
24
+ name: sql_identifier.SqlIdentifier,
25
+ ) -> "ModelMonitor":
26
+ self: "ModelMonitor" = object.__new__(cls)
27
+ self.name = name
28
+ self._model_monitor_client = model_monitor_client
29
+ return self
30
+
31
+ def suspend(self) -> None:
32
+ """Suspend pipeline for ModelMonitor"""
33
+ self._model_monitor_client.suspend_monitor(self.name, statement_params=self.statement_params)
34
+
35
+ def resume(self) -> None:
36
+ """Resume pipeline for ModelMonitor"""
37
+ self._model_monitor_client.resume_monitor(self.name, statement_params=self.statement_params)
@@ -3,10 +3,11 @@ from typing import Any, Dict, List, Optional, Union
3
3
 
4
4
  import pandas as pd
5
5
  from absl.logging import logging
6
+ from packaging import version
6
7
 
7
8
  from snowflake.ml._internal import telemetry
8
9
  from snowflake.ml._internal.human_readable_id import hrid_generator
9
- from snowflake.ml._internal.utils import sql_identifier
10
+ from snowflake.ml._internal.utils import snowflake_env, sql_identifier
10
11
  from snowflake.ml.model import model_signature, type_hints as model_types
11
12
  from snowflake.ml.model._client.model import model_impl, model_version_impl
12
13
  from snowflake.ml.model._client.ops import metadata_ops, model_ops, service_ops
@@ -45,6 +46,7 @@ class ModelManager:
45
46
  metrics: Optional[Dict[str, Any]] = None,
46
47
  conda_dependencies: Optional[List[str]] = None,
47
48
  pip_requirements: Optional[List[str]] = None,
49
+ target_platforms: Optional[List[model_types.SupportedTargetPlatformType]] = None,
48
50
  python_version: Optional[str] = None,
49
51
  signatures: Optional[Dict[str, model_signature.ModelSignature]] = None,
50
52
  sample_input_data: Optional[model_types.SupportedDataType] = None,
@@ -85,6 +87,7 @@ class ModelManager:
85
87
  metrics=metrics,
86
88
  conda_dependencies=conda_dependencies,
87
89
  pip_requirements=pip_requirements,
90
+ target_platforms=target_platforms,
88
91
  python_version=python_version,
89
92
  signatures=signatures,
90
93
  sample_input_data=sample_input_data,
@@ -105,6 +108,7 @@ class ModelManager:
105
108
  metrics: Optional[Dict[str, Any]] = None,
106
109
  conda_dependencies: Optional[List[str]] = None,
107
110
  pip_requirements: Optional[List[str]] = None,
111
+ target_platforms: Optional[List[model_types.SupportedTargetPlatformType]] = None,
108
112
  python_version: Optional[str] = None,
109
113
  signatures: Optional[Dict[str, model_signature.ModelSignature]] = None,
110
114
  sample_input_data: Optional[model_types.SupportedDataType] = None,
@@ -143,6 +147,15 @@ class ModelManager:
143
147
  statement_params=statement_params,
144
148
  )
145
149
 
150
+ platforms = None
151
+ # TODO(jbahk): Remove the version check after Snowflake 8.40.0 release
152
+ # User specified target platforms are defaulted to None and will not show up in the generated manifest.
153
+ # In the backend, we attempt to create a model for all platforms (WH, SPCS) regardless by default.
154
+ if snowflake_env.get_current_snowflake_version(self._model_ops._session) >= version.parse("8.40.0"):
155
+ # Convert any string target platforms to TargetPlatform objects
156
+ if target_platforms:
157
+ platforms = [model_types.TargetPlatform(platform) for platform in target_platforms]
158
+
146
159
  logger.info("Start packaging and uploading your model. It might take some time based on the size of the model.")
147
160
 
148
161
  mc = model_composer.ModelComposer(
@@ -155,6 +168,7 @@ class ModelManager:
155
168
  sample_input_data=sample_input_data,
156
169
  conda_dependencies=conda_dependencies,
157
170
  pip_requirements=pip_requirements,
171
+ target_platforms=platforms,
158
172
  python_version=python_version,
159
173
  code_paths=code_paths,
160
174
  ext_modules=ext_modules,
@@ -14,11 +14,8 @@ from snowflake.ml.model import (
14
14
  type_hints as model_types,
15
15
  )
16
16
  from snowflake.ml.model._client.model import model_version_impl
17
- from snowflake.ml.monitoring._client import (
18
- model_monitor,
19
- model_monitor_manager,
20
- model_monitor_version,
21
- )
17
+ from snowflake.ml.monitoring import model_monitor, model_monitor_version
18
+ from snowflake.ml.monitoring._manager import model_monitor_manager
22
19
  from snowflake.ml.monitoring.entities import model_monitor_config
23
20
  from snowflake.ml.registry._manager import model_manager
24
21
  from snowflake.snowpark import session
@@ -26,6 +23,11 @@ from snowflake.snowpark import session
26
23
  _TELEMETRY_PROJECT = "MLOps"
27
24
  _MODEL_TELEMETRY_SUBPROJECT = "ModelManagement"
28
25
 
26
+ _MODEL_MONITORING_UNIMPLEMENTED_ERROR = "Model Monitoring is not implemented in python yet."
27
+ _MODEL_MONITORING_DISABLED_ERROR = (
28
+ """Must enable monitoring to use this method. Please set `options={"enable_monitoring": True}` in the Registry"""
29
+ )
30
+
29
31
 
30
32
  class Registry:
31
33
  def __init__(
@@ -87,7 +89,6 @@ class Registry:
87
89
  session=session,
88
90
  database_name=self._database_name,
89
91
  schema_name=self._schema_name,
90
- create_if_not_exists=True, # TODO: Support static setup method to configure schema for monitoring.
91
92
  statement_params=monitor_statement_params,
92
93
  )
93
94
 
@@ -107,6 +108,7 @@ class Registry:
107
108
  metrics: Optional[Dict[str, Any]] = None,
108
109
  conda_dependencies: Optional[List[str]] = None,
109
110
  pip_requirements: Optional[List[str]] = None,
111
+ target_platforms: Optional[List[model_types.SupportedTargetPlatformType]] = None,
110
112
  python_version: Optional[str] = None,
111
113
  signatures: Optional[Dict[str, model_signature.ModelSignature]] = None,
112
114
  sample_input_data: Optional[model_types.SupportedDataType] = None,
@@ -128,14 +130,17 @@ class Registry:
128
130
  metrics: A JSON serializable dictionary containing metrics linked to the model version. Defaults to None.
129
131
  signatures: Model data signatures for inputs and outputs for various target methods. If it is None,
130
132
  sample_input_data would be used to infer the signatures for those models that cannot automatically
131
- infer the signature. If not None, sample_input_data should not be specified. Defaults to None.
132
- sample_input_data: Sample input data to infer model signatures from. Defaults to None.
133
+ infer the signature. Defaults to None.
134
+ sample_input_data: Sample input data to infer model signatures from.
135
+ It would also be used as background data in explanation and to capture data lineage. Defaults to None.
133
136
  conda_dependencies: List of Conda package specifications. Use "[channel::]package [operator version]" syntax
134
137
  to specify a dependency. It is a recommended way to specify your dependencies using conda. When channel
135
138
  is not specified, Snowflake Anaconda Channel will be used. Defaults to None.
136
139
  pip_requirements: List of Pip package specifications. Defaults to None.
137
140
  Currently it is not supported since Model can only executed in Snowflake Warehouse where all
138
141
  dependencies are required to be retrieved from Snowflake Anaconda Channel.
142
+ target_platforms: List of target platforms to run the model. The only acceptable inputs are a combination of
143
+ {"WAREHOUSE", "SNOWPARK_CONTAINER_SERVICES"}. Defaults to None.
139
144
  python_version: Python version in which the model is run. Defaults to None.
140
145
  code_paths: List of directories containing code to import. Defaults to None.
141
146
  ext_modules: List of external modules to pickle with the model object.
@@ -190,6 +195,7 @@ class Registry:
190
195
  "metrics",
191
196
  "conda_dependencies",
192
197
  "pip_requirements",
198
+ "target_platforms",
193
199
  "python_version",
194
200
  "signatures",
195
201
  ],
@@ -204,6 +210,7 @@ class Registry:
204
210
  metrics: Optional[Dict[str, Any]] = None,
205
211
  conda_dependencies: Optional[List[str]] = None,
206
212
  pip_requirements: Optional[List[str]] = None,
213
+ target_platforms: Optional[List[model_types.SupportedTargetPlatformType]] = None,
207
214
  python_version: Optional[str] = None,
208
215
  signatures: Optional[Dict[str, model_signature.ModelSignature]] = None,
209
216
  sample_input_data: Optional[model_types.SupportedDataType] = None,
@@ -229,13 +236,16 @@ class Registry:
229
236
  signatures: Model data signatures for inputs and outputs for various target methods. If it is None,
230
237
  sample_input_data would be used to infer the signatures for those models that cannot automatically
231
238
  infer the signature. If not None, sample_input_data should not be specified. Defaults to None.
232
- sample_input_data: Sample input data to infer model signatures from. Defaults to None.
239
+ sample_input_data: Sample input data to infer model signatures from.
240
+ It would also be used as background data in explanation and to capture data lineage. Defaults to None.
233
241
  conda_dependencies: List of Conda package specifications. Use "[channel::]package [operator version]" syntax
234
242
  to specify a dependency. It is a recommended way to specify your dependencies using conda. When channel
235
243
  is not specified, Snowflake Anaconda Channel will be used. Defaults to None.
236
244
  pip_requirements: List of Pip package specifications. Defaults to None.
237
245
  Currently it is not supported since Model can only executed in Snowflake Warehouse where all
238
246
  dependencies are required to be retrieved from Snowflake Anaconda Channel.
247
+ target_platforms: List of target platforms to run the model. The only acceptable inputs are a combination of
248
+ {"WAREHOUSE", "SNOWPARK_CONTAINER_SERVICES"}. Defaults to None.
239
249
  python_version: Python version in which the model is run. Defaults to None.
240
250
  code_paths: List of directories containing code to import. Defaults to None.
241
251
  ext_modules: List of external modules to pickle with the model object.
@@ -287,6 +297,7 @@ class Registry:
287
297
  metrics=metrics,
288
298
  conda_dependencies=conda_dependencies,
289
299
  pip_requirements=pip_requirements,
300
+ target_platforms=target_platforms,
290
301
  python_version=python_version,
291
302
  signatures=signatures,
292
303
  sample_input_data=sample_input_data,
@@ -374,34 +385,25 @@ class Registry:
374
385
  def add_monitor(
375
386
  self,
376
387
  name: str,
377
- table_config: model_monitor_config.ModelMonitorTableConfig,
388
+ source_config: model_monitor_config.ModelMonitorSourceConfig,
378
389
  model_monitor_config: model_monitor_config.ModelMonitorConfig,
379
- *,
380
- add_dashboard_udtfs: bool = False,
381
390
  ) -> model_monitor.ModelMonitor:
382
391
  """Add a Model Monitor to the Registry
383
392
 
384
393
  Args:
385
394
  name: Name of Model Monitor to create
386
- table_config: Configuration options of table for ModelMonitor.
395
+ source_config: Configuration options of table for ModelMonitor.
387
396
  model_monitor_config: Configuration options of ModelMonitor.
388
- add_dashboard_udtfs: Add UDTFs useful for creating a dashboard.
389
397
 
390
398
  Returns:
391
399
  The newly added ModelMonitor object.
392
400
 
393
401
  Raises:
394
- ValueError: If monitoring feature flag is not enabled.
402
+ ValueError: If monitoring is not enabled in the Registry.
395
403
  """
396
404
  if not self.enable_monitoring:
397
- raise ValueError(
398
- "Must enable monitoring in Registry to use this method. Please set the `enable_monitoring=True` option"
399
- )
400
-
401
- # TODO: Change to fully qualified source table reference to allow table to live in different DB.
402
- return self._model_monitor_manager.add_monitor(
403
- name, table_config, model_monitor_config, add_dashboard_udtfs=add_dashboard_udtfs
404
- )
405
+ raise ValueError(_MODEL_MONITORING_DISABLED_ERROR)
406
+ return self._model_monitor_manager.add_monitor(name, source_config, model_monitor_config)
405
407
 
406
408
  @overload
407
409
  def get_monitor(self, model_version: model_version_impl.ModelVersion) -> model_monitor.ModelMonitor:
@@ -439,17 +441,14 @@ class Registry:
439
441
  The fetched ModelMonitor.
440
442
 
441
443
  Raises:
442
- ValueError: If monitoring feature flag is not enabled.
443
- ValueError: If neither name nor model_version specified.
444
+ ValueError: If monitoring is not enabled in the Registry.
444
445
  """
445
446
  if not self.enable_monitoring:
446
- raise ValueError(
447
- "Must enable monitoring in Registry to use this method. Please set the `enable_monitoring=True` option"
448
- )
447
+ raise ValueError(_MODEL_MONITORING_DISABLED_ERROR)
449
448
  if name is not None:
450
449
  return self._model_monitor_manager.get_monitor(name=name)
451
450
  elif model_version is not None:
452
- return self._model_monitor_manager.get_monitor_by_model_version(model_version=model_version)
451
+ return self._model_monitor_manager.get_monitor_by_model_version(model_version)
453
452
  else:
454
453
  raise ValueError("Must provide either `name` or `model_version` to get ModelMonitor")
455
454
 
@@ -465,12 +464,10 @@ class Registry:
465
464
  List of snowpark.Row containing metadata for each model monitor.
466
465
 
467
466
  Raises:
468
- ValueError: If monitoring feature flag is not enabled.
467
+ ValueError: If monitoring is not enabled in the Registry.
469
468
  """
470
469
  if not self.enable_monitoring:
471
- raise ValueError(
472
- "Must enable monitoring in Registry to use this method. Please set the `enable_monitoring=True` option"
473
- )
470
+ raise ValueError(_MODEL_MONITORING_DISABLED_ERROR)
474
471
  return self._model_monitor_manager.show_model_monitors()
475
472
 
476
473
  @telemetry.send_api_usage_telemetry(
@@ -485,10 +482,8 @@ class Registry:
485
482
  name: Name of the Model Monitor to delete.
486
483
 
487
484
  Raises:
488
- ValueError: If monitoring feature flag is not enabled.
485
+ ValueError: If monitoring is not enabled in the registry.
489
486
  """
490
487
  if not self.enable_monitoring:
491
- raise ValueError(
492
- "Must enable monitoring in Registry to use this method. Please set the `enable_monitoring=True` option"
493
- )
488
+ raise ValueError(_MODEL_MONITORING_DISABLED_ERROR)
494
489
  self._model_monitor_manager.delete_monitor(name)
snowflake/ml/version.py CHANGED
@@ -1 +1 @@
1
- VERSION="1.6.4"
1
+ VERSION="1.7.1"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: snowflake-ml-python
3
- Version: 1.6.4
3
+ Version: 1.7.1
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:
@@ -220,7 +220,6 @@ Classifier: Intended Audience :: Information Technology
220
220
  Classifier: Intended Audience :: System Administrators
221
221
  Classifier: License :: OSI Approved :: Apache Software License
222
222
  Classifier: Operating System :: OS Independent
223
- Classifier: Programming Language :: Python :: 3.8
224
223
  Classifier: Programming Language :: Python :: 3.9
225
224
  Classifier: Programming Language :: Python :: 3.10
226
225
  Classifier: Programming Language :: Python :: 3.11
@@ -230,38 +229,39 @@ Classifier: Topic :: Software Development :: Libraries
230
229
  Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
231
230
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
232
231
  Classifier: Topic :: Scientific/Engineering :: Information Analysis
233
- Requires-Python: <3.12,>=3.8
232
+ Requires-Python: <3.12,>=3.9
234
233
  Description-Content-Type: text/markdown
235
234
  License-File: LICENSE.txt
236
235
  Requires-Dist: absl-py <2,>=0.15
237
236
  Requires-Dist: anyio <4,>=3.5.0
238
237
  Requires-Dist: cachetools <6,>=3.1.1
239
238
  Requires-Dist: cloudpickle >=2.0.0
239
+ Requires-Dist: cryptography
240
240
  Requires-Dist: fsspec[http] <2024,>=2022.11
241
241
  Requires-Dist: importlib-resources <7,>=6.1.1
242
242
  Requires-Dist: numpy <2,>=1.23
243
- Requires-Dist: packaging <24,>=20.9
243
+ Requires-Dist: packaging <25,>=20.9
244
244
  Requires-Dist: pandas <3,>=1.0.0
245
245
  Requires-Dist: pyarrow
246
246
  Requires-Dist: pytimeparse <2,>=1.1.8
247
247
  Requires-Dist: pyyaml <7,>=6.0
248
248
  Requires-Dist: retrying <2,>=1.3.3
249
249
  Requires-Dist: s3fs <2024,>=2022.11
250
- Requires-Dist: scikit-learn <1.6,>=1.2.1
250
+ Requires-Dist: scikit-learn <1.6,>=1.4
251
251
  Requires-Dist: scipy <2,>=1.9
252
252
  Requires-Dist: snowflake-connector-python[pandas] <4,>=3.5.0
253
253
  Requires-Dist: snowflake-snowpark-python <2,>=1.17.0
254
254
  Requires-Dist: sqlparse <1,>=0.4
255
255
  Requires-Dist: typing-extensions <5,>=4.1.0
256
- Requires-Dist: xgboost <2.1,>=1.7.3
256
+ Requires-Dist: xgboost <3,>=1.7.3
257
257
  Provides-Extra: all
258
258
  Requires-Dist: catboost <2,>=1.2.0 ; extra == 'all'
259
- Requires-Dist: lightgbm <5,>=3.3.5 ; extra == 'all'
259
+ Requires-Dist: lightgbm <5,>=4.1.0 ; extra == 'all'
260
260
  Requires-Dist: mlflow <2.4,>=2.1.0 ; extra == 'all'
261
261
  Requires-Dist: peft <1,>=0.5.0 ; extra == 'all'
262
262
  Requires-Dist: sentence-transformers <3,>=2.2.2 ; extra == 'all'
263
263
  Requires-Dist: sentencepiece <1,>=0.1.95 ; extra == 'all'
264
- Requires-Dist: shap <1,>=0.42.0 ; extra == 'all'
264
+ Requires-Dist: shap <1,>=0.46.0 ; extra == 'all'
265
265
  Requires-Dist: tensorflow <3,>=2.10 ; extra == 'all'
266
266
  Requires-Dist: tokenizers <1,>=0.10 ; extra == 'all'
267
267
  Requires-Dist: torch <2.3.0,>=2.0.1 ; extra == 'all'
@@ -270,13 +270,13 @@ Requires-Dist: transformers <5,>=4.32.1 ; extra == 'all'
270
270
  Provides-Extra: catboost
271
271
  Requires-Dist: catboost <2,>=1.2.0 ; extra == 'catboost'
272
272
  Provides-Extra: lightgbm
273
- Requires-Dist: lightgbm <5,>=3.3.5 ; extra == 'lightgbm'
273
+ Requires-Dist: lightgbm <5,>=4.1.0 ; extra == 'lightgbm'
274
274
  Provides-Extra: llm
275
275
  Requires-Dist: peft <1,>=0.5.0 ; extra == 'llm'
276
276
  Provides-Extra: mlflow
277
277
  Requires-Dist: mlflow <2.4,>=2.1.0 ; extra == 'mlflow'
278
278
  Provides-Extra: shap
279
- Requires-Dist: shap <1,>=0.42.0 ; extra == 'shap'
279
+ Requires-Dist: shap <1,>=0.46.0 ; extra == 'shap'
280
280
  Provides-Extra: tensorflow
281
281
  Requires-Dist: tensorflow <3,>=2.10 ; extra == 'tensorflow'
282
282
  Provides-Extra: torch
@@ -336,7 +336,7 @@ If you don't have a Snowflake account yet, you can [sign up for a 30-day free tr
336
336
  Follow the [installation instructions](https://docs.snowflake.com/en/developer-guide/snowpark-ml/index#installing-snowpark-ml)
337
337
  in the Snowflake documentation.
338
338
 
339
- Python versions 3.8 to 3.11 are supported. You can use [miniconda](https://docs.conda.io/en/latest/miniconda.html) or
339
+ Python versions 3.9 to 3.11 are supported. You can use [miniconda](https://docs.conda.io/en/latest/miniconda.html) or
340
340
  [anaconda](https://www.anaconda.com/) to create a Conda environment (recommended),
341
341
  or [virtualenv](https://docs.python.org/3/tutorial/venv.html) to create a virtual environment.
342
342
 
@@ -373,7 +373,96 @@ be compatibility issues. Server-side functionality that `snowflake-ml-python` de
373
373
 
374
374
  # Release History
375
375
 
376
- ## 1.6.4
376
+ ## 1.7.1
377
+
378
+ ### Bug Fixes
379
+
380
+ - Registry: Null value is now allowed in the dataframe used in model signature inference. Null values will be ignored
381
+ and others will be used to infer the signature.
382
+ - Registry: Pandas Extension DTypes (`pandas.StringDType()`, `pandas.BooleanDType()`, etc.) are now supported in model
383
+ signature inference.
384
+ - Registry: Null value is now allowed in the dataframe used to predict.
385
+ - Data: Fix missing `snowflake.ml.data.*` module exports in wheel
386
+ - Dataset: Fix missing `snowflake.ml.dataset.*` module exports in wheel.
387
+ - Registry: Fix the issue that `tf_keras.Model` is not recognized as keras model when logging.
388
+
389
+ ### Behavior Changes
390
+
391
+ ### New Features
392
+
393
+ - Registry: Option to `enable_monitoring` set to False by default. This will gate access to preview features of Model Monitoring.
394
+ - Model Monitoring: `show_model_monitors` Registry method. This feature is still in Private Preview.
395
+ - Registry: Support `pd.Series` in input and output data.
396
+ - Model Monitoring: `add_monitor` Registry method. This feature is still in Private Preview.
397
+ - Model Monitoring: `resume` and `suspend` ModelMonitor. This feature is still in Private Preview.
398
+ - Model Monitoring: `get_monitor` Registry method. This feature is still in Private Preview.
399
+ - Model Monitoring: `delete_monitor` Registry method. This feature is still in Private Preview.
400
+
401
+ ## 1.7.0 (10-22-2024)
402
+
403
+ ### Behavior Change
404
+
405
+ - Generic: Require python >= 3.9.
406
+ - Data Connector: Update `to_torch_dataset` and `to_torch_datapipe` to add a dimension for scalar data.
407
+ This allows for more seamless integration with PyTorch `DataLoader`, which creates batches by stacking inputs of each batch.
408
+
409
+ Examples:
410
+
411
+ ```python
412
+ ds = connector.to_torch_dataset(shuffle=False, batch_size=3)
413
+ ```
414
+
415
+ - Input: "col1": [10, 11, 12]
416
+ - Previous batch: array([10., 11., 12.]) with shape (3,)
417
+ - New batch: array([[10.], [11.], [12.]]) with shape (3, 1)
418
+
419
+ - Input: "col2": [[0, 100], [1, 110], [2, 200]]
420
+ - Previous batch: array([[ 0, 100], [ 1, 110], [ 2, 200]]) with shape (3,2)
421
+ - New batch: No change
422
+
423
+ - Model Registry: External access integrations are optional when creating a model inference service in
424
+ Snowflake >= 8.40.0.
425
+ - Model Registry: Deprecate `build_external_access_integration` with `build_external_access_integrations` in
426
+ `ModelVersion.create_service()`.
427
+
428
+ ### Bug Fixes
429
+
430
+ - Registry: Updated `log_model` API to accept both signature and sample_input_data parameters.
431
+ - Feature Store: ExampleHelper uses fully qualified path for table name. change weather features aggregation from 1d to 1h.
432
+ - Data Connector: Return numpy array with appropriate object type instead of list for multi-dimensional
433
+ data from `to_torch_dataset` and `to_torch_datapipe`
434
+ - Model explainability: Incompatibility between SHAP 0.42.1 and XGB 2.1.1 resolved by using latest SHAP 0.46.0.
435
+
436
+ ### New Features
437
+
438
+ - Registry: Provide pass keyworded variable length of arguments to class ModelContext. Example usage:
439
+
440
+ ```python
441
+ mc = custom_model.ModelContext(
442
+ config = 'local_model_dir/config.json',
443
+ m1 = model1
444
+ )
445
+
446
+ class ExamplePipelineModel(custom_model.CustomModel):
447
+ def __init__(self, context: custom_model.ModelContext) -> None:
448
+ super().__init__(context)
449
+ v = open(self.context['config']).read()
450
+ self.bias = json.loads(v)['bias']
451
+
452
+ @custom_model.inference_api
453
+ def predict(self, input: pd.DataFrame) -> pd.DataFrame:
454
+ model_output = self.context['m1'].predict(input)
455
+ return pd.DataFrame({'output': model_output + self.bias})
456
+ ```
457
+
458
+ - Model Development: Upgrade scikit-learn in UDTF backend for log_loss metric. As a result, `eps` argument is now ignored.
459
+ - Data Connector: Add the option of passing a `None` sized batch to `to_torch_dataset` for better
460
+ interoperability with PyTorch DataLoader.
461
+ - Model Registry: Support [pandas.CategoricalDtype](https://pandas.pydata.org/docs/reference/api/pandas.CategoricalDtype.html#pandas-categoricaldtype)
462
+ - Registry: It is now possible to pass `signatures` and `sample_input_data` at the same time to capture background
463
+ data from explainablity and data lineage.
464
+
465
+ ## 1.6.4 (2024-10-17)
377
466
 
378
467
  ### Bug Fixes
379
468
 
@@ -391,6 +480,9 @@ be compatibility issues. Server-side functionality that `snowflake-ml-python` de
391
480
  - Registry: Fix a bug that `ModelVersion.run` is called in a nested way.
392
481
  - Registry: Fix an issue that leads to `log_model` failure when local package version contains parts other than
393
482
  base version.
483
+ - Fix issue where `sample_weights` were not being applied to search estimators.
484
+ - Model explainability: Fix bug which creates explain as a function instead of table function when enabling by default.
485
+ - Model explainability: Update lightgbm binary classification to return non-json values, from customer feedback.
394
486
 
395
487
  ### New Features
396
488