snowflake-ml-python 1.5.2__py3-none-any.whl → 1.5.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (250) hide show
  1. snowflake/cortex/__init__.py +2 -1
  2. snowflake/cortex/_complete.py +240 -16
  3. snowflake/cortex/_extract_answer.py +0 -1
  4. snowflake/cortex/_sentiment.py +0 -1
  5. snowflake/cortex/_sse_client.py +81 -0
  6. snowflake/cortex/_summarize.py +0 -1
  7. snowflake/cortex/_translate.py +0 -1
  8. snowflake/cortex/_util.py +34 -10
  9. snowflake/ml/_internal/container_services/image_registry/http_client.py +10 -3
  10. snowflake/ml/_internal/container_services/image_registry/imagelib.py +23 -10
  11. snowflake/ml/_internal/container_services/image_registry/registry_client.py +7 -1
  12. snowflake/ml/_internal/exceptions/dataset_errors.py +7 -7
  13. snowflake/ml/_internal/exceptions/fileset_errors.py +3 -3
  14. snowflake/ml/_internal/exceptions/sql_error_codes.py +6 -0
  15. snowflake/ml/_internal/lineage/lineage_utils.py +34 -25
  16. snowflake/ml/_internal/telemetry.py +26 -0
  17. snowflake/ml/_internal/utils/identifier.py +14 -0
  18. snowflake/ml/_internal/utils/snowpark_dataframe_utils.py +15 -4
  19. snowflake/ml/dataset/dataset.py +54 -32
  20. snowflake/ml/dataset/dataset_factory.py +3 -4
  21. snowflake/ml/feature_store/feature_store.py +440 -243
  22. snowflake/ml/feature_store/feature_view.py +61 -9
  23. snowflake/ml/fileset/embedded_stage_fs.py +25 -21
  24. snowflake/ml/fileset/fileset.py +2 -2
  25. snowflake/ml/fileset/snowfs.py +4 -15
  26. snowflake/ml/fileset/stage_fs.py +6 -8
  27. snowflake/ml/lineage/__init__.py +3 -0
  28. snowflake/ml/lineage/lineage_node.py +139 -0
  29. snowflake/ml/model/_client/model/model_impl.py +47 -14
  30. snowflake/ml/model/_client/model/model_version_impl.py +82 -2
  31. snowflake/ml/model/_client/ops/model_ops.py +77 -5
  32. snowflake/ml/model/_client/sql/model.py +1 -0
  33. snowflake/ml/model/_client/sql/model_version.py +47 -4
  34. snowflake/ml/model/_deploy_client/image_builds/inference_server/main.py +2 -3
  35. snowflake/ml/model/_model_composer/model_composer.py +7 -6
  36. snowflake/ml/model/_model_composer/model_manifest/model_manifest.py +7 -1
  37. snowflake/ml/model/_model_composer/model_method/function_generator.py +17 -1
  38. snowflake/ml/model/_model_composer/model_method/infer_partitioned.py_template +79 -0
  39. snowflake/ml/model/_model_composer/model_method/infer_table_function.py_template +5 -3
  40. snowflake/ml/model/_model_composer/model_method/model_method.py +5 -5
  41. snowflake/ml/model/_packager/model_handlers/_base.py +2 -2
  42. snowflake/ml/model/_packager/model_handlers/_utils.py +1 -0
  43. snowflake/ml/model/_packager/model_handlers/catboost.py +2 -2
  44. snowflake/ml/model/_packager/model_handlers/custom.py +12 -4
  45. snowflake/ml/model/_packager/model_handlers/huggingface_pipeline.py +18 -15
  46. snowflake/ml/model/_packager/model_handlers/lightgbm.py +2 -2
  47. snowflake/ml/model/_packager/model_handlers/llm.py +2 -2
  48. snowflake/ml/model/_packager/model_handlers/mlflow.py +2 -2
  49. snowflake/ml/model/_packager/model_handlers/pytorch.py +2 -2
  50. snowflake/ml/model/_packager/model_handlers/sentence_transformers.py +2 -2
  51. snowflake/ml/model/_packager/model_handlers/sklearn.py +2 -2
  52. snowflake/ml/model/_packager/model_handlers/snowmlmodel.py +2 -2
  53. snowflake/ml/model/_packager/model_handlers/tensorflow.py +2 -2
  54. snowflake/ml/model/_packager/model_handlers/torchscript.py +2 -2
  55. snowflake/ml/model/_packager/model_handlers/xgboost.py +2 -2
  56. snowflake/ml/model/_packager/model_meta/_core_requirements.py +1 -1
  57. snowflake/ml/model/_packager/model_meta/model_blob_meta.py +2 -0
  58. snowflake/ml/model/_packager/model_meta/model_meta.py +21 -1
  59. snowflake/ml/model/_packager/model_meta/model_meta_schema.py +6 -1
  60. snowflake/ml/model/_packager/model_packager.py +9 -4
  61. snowflake/ml/model/_packager/model_runtime/_snowml_inference_alternative_requirements.py +1 -1
  62. snowflake/ml/model/_signatures/builtins_handler.py +2 -1
  63. snowflake/ml/model/_signatures/core.py +13 -1
  64. snowflake/ml/model/_signatures/pandas_handler.py +2 -0
  65. snowflake/ml/model/_signatures/snowpark_handler.py +3 -3
  66. snowflake/ml/model/custom_model.py +22 -2
  67. snowflake/ml/model/model_signature.py +2 -0
  68. snowflake/ml/model/type_hints.py +74 -4
  69. snowflake/ml/modeling/_internal/estimator_utils.py +58 -1
  70. snowflake/ml/modeling/_internal/snowpark_implementations/distributed_hpo_trainer.py +158 -121
  71. snowflake/ml/modeling/_internal/snowpark_implementations/distributed_search_udf_file.py +2 -0
  72. snowflake/ml/modeling/_internal/snowpark_implementations/snowpark_handlers.py +39 -18
  73. snowflake/ml/modeling/_internal/snowpark_implementations/snowpark_trainer.py +88 -134
  74. snowflake/ml/modeling/_internal/snowpark_implementations/xgboost_external_memory_trainer.py +22 -17
  75. snowflake/ml/modeling/calibration/calibrated_classifier_cv.py +1 -1
  76. snowflake/ml/modeling/cluster/affinity_propagation.py +5 -3
  77. snowflake/ml/modeling/cluster/agglomerative_clustering.py +5 -3
  78. snowflake/ml/modeling/cluster/birch.py +5 -3
  79. snowflake/ml/modeling/cluster/bisecting_k_means.py +5 -3
  80. snowflake/ml/modeling/cluster/dbscan.py +5 -3
  81. snowflake/ml/modeling/cluster/feature_agglomeration.py +5 -3
  82. snowflake/ml/modeling/cluster/k_means.py +5 -3
  83. snowflake/ml/modeling/cluster/mean_shift.py +5 -3
  84. snowflake/ml/modeling/cluster/mini_batch_k_means.py +5 -3
  85. snowflake/ml/modeling/cluster/optics.py +5 -3
  86. snowflake/ml/modeling/cluster/spectral_biclustering.py +5 -3
  87. snowflake/ml/modeling/cluster/spectral_clustering.py +5 -3
  88. snowflake/ml/modeling/cluster/spectral_coclustering.py +5 -3
  89. snowflake/ml/modeling/compose/column_transformer.py +5 -3
  90. snowflake/ml/modeling/compose/transformed_target_regressor.py +1 -1
  91. snowflake/ml/modeling/covariance/elliptic_envelope.py +5 -3
  92. snowflake/ml/modeling/covariance/empirical_covariance.py +5 -3
  93. snowflake/ml/modeling/covariance/graphical_lasso.py +5 -3
  94. snowflake/ml/modeling/covariance/graphical_lasso_cv.py +5 -3
  95. snowflake/ml/modeling/covariance/ledoit_wolf.py +5 -3
  96. snowflake/ml/modeling/covariance/min_cov_det.py +5 -3
  97. snowflake/ml/modeling/covariance/oas.py +5 -3
  98. snowflake/ml/modeling/covariance/shrunk_covariance.py +5 -3
  99. snowflake/ml/modeling/decomposition/dictionary_learning.py +5 -3
  100. snowflake/ml/modeling/decomposition/factor_analysis.py +5 -3
  101. snowflake/ml/modeling/decomposition/fast_ica.py +5 -3
  102. snowflake/ml/modeling/decomposition/incremental_pca.py +5 -3
  103. snowflake/ml/modeling/decomposition/kernel_pca.py +5 -3
  104. snowflake/ml/modeling/decomposition/mini_batch_dictionary_learning.py +5 -3
  105. snowflake/ml/modeling/decomposition/mini_batch_sparse_pca.py +5 -3
  106. snowflake/ml/modeling/decomposition/pca.py +5 -3
  107. snowflake/ml/modeling/decomposition/sparse_pca.py +5 -3
  108. snowflake/ml/modeling/decomposition/truncated_svd.py +5 -3
  109. snowflake/ml/modeling/discriminant_analysis/linear_discriminant_analysis.py +1 -1
  110. snowflake/ml/modeling/discriminant_analysis/quadratic_discriminant_analysis.py +1 -1
  111. snowflake/ml/modeling/ensemble/ada_boost_classifier.py +1 -1
  112. snowflake/ml/modeling/ensemble/ada_boost_regressor.py +1 -1
  113. snowflake/ml/modeling/ensemble/bagging_classifier.py +1 -1
  114. snowflake/ml/modeling/ensemble/bagging_regressor.py +1 -1
  115. snowflake/ml/modeling/ensemble/extra_trees_classifier.py +1 -1
  116. snowflake/ml/modeling/ensemble/extra_trees_regressor.py +1 -1
  117. snowflake/ml/modeling/ensemble/gradient_boosting_classifier.py +1 -1
  118. snowflake/ml/modeling/ensemble/gradient_boosting_regressor.py +1 -1
  119. snowflake/ml/modeling/ensemble/hist_gradient_boosting_classifier.py +1 -1
  120. snowflake/ml/modeling/ensemble/hist_gradient_boosting_regressor.py +1 -1
  121. snowflake/ml/modeling/ensemble/isolation_forest.py +5 -3
  122. snowflake/ml/modeling/ensemble/random_forest_classifier.py +1 -1
  123. snowflake/ml/modeling/ensemble/random_forest_regressor.py +1 -1
  124. snowflake/ml/modeling/ensemble/stacking_regressor.py +1 -1
  125. snowflake/ml/modeling/ensemble/voting_classifier.py +1 -1
  126. snowflake/ml/modeling/ensemble/voting_regressor.py +1 -1
  127. snowflake/ml/modeling/feature_selection/generic_univariate_select.py +1 -1
  128. snowflake/ml/modeling/feature_selection/select_fdr.py +1 -1
  129. snowflake/ml/modeling/feature_selection/select_fpr.py +1 -1
  130. snowflake/ml/modeling/feature_selection/select_fwe.py +1 -1
  131. snowflake/ml/modeling/feature_selection/select_k_best.py +1 -1
  132. snowflake/ml/modeling/feature_selection/select_percentile.py +1 -1
  133. snowflake/ml/modeling/feature_selection/sequential_feature_selector.py +5 -3
  134. snowflake/ml/modeling/feature_selection/variance_threshold.py +5 -3
  135. snowflake/ml/modeling/framework/base.py +3 -8
  136. snowflake/ml/modeling/gaussian_process/gaussian_process_classifier.py +1 -1
  137. snowflake/ml/modeling/gaussian_process/gaussian_process_regressor.py +1 -1
  138. snowflake/ml/modeling/impute/iterative_imputer.py +5 -3
  139. snowflake/ml/modeling/impute/knn_imputer.py +5 -3
  140. snowflake/ml/modeling/impute/missing_indicator.py +5 -3
  141. snowflake/ml/modeling/impute/simple_imputer.py +8 -4
  142. snowflake/ml/modeling/kernel_approximation/additive_chi2_sampler.py +5 -3
  143. snowflake/ml/modeling/kernel_approximation/nystroem.py +5 -3
  144. snowflake/ml/modeling/kernel_approximation/polynomial_count_sketch.py +5 -3
  145. snowflake/ml/modeling/kernel_approximation/rbf_sampler.py +5 -3
  146. snowflake/ml/modeling/kernel_approximation/skewed_chi2_sampler.py +5 -3
  147. snowflake/ml/modeling/kernel_ridge/kernel_ridge.py +1 -1
  148. snowflake/ml/modeling/lightgbm/lgbm_classifier.py +1 -1
  149. snowflake/ml/modeling/lightgbm/lgbm_regressor.py +1 -1
  150. snowflake/ml/modeling/linear_model/ard_regression.py +1 -1
  151. snowflake/ml/modeling/linear_model/bayesian_ridge.py +1 -1
  152. snowflake/ml/modeling/linear_model/elastic_net.py +1 -1
  153. snowflake/ml/modeling/linear_model/elastic_net_cv.py +1 -1
  154. snowflake/ml/modeling/linear_model/gamma_regressor.py +1 -1
  155. snowflake/ml/modeling/linear_model/huber_regressor.py +1 -1
  156. snowflake/ml/modeling/linear_model/lars.py +1 -1
  157. snowflake/ml/modeling/linear_model/lars_cv.py +1 -1
  158. snowflake/ml/modeling/linear_model/lasso.py +1 -1
  159. snowflake/ml/modeling/linear_model/lasso_cv.py +1 -1
  160. snowflake/ml/modeling/linear_model/lasso_lars.py +1 -1
  161. snowflake/ml/modeling/linear_model/lasso_lars_cv.py +1 -1
  162. snowflake/ml/modeling/linear_model/lasso_lars_ic.py +1 -1
  163. snowflake/ml/modeling/linear_model/linear_regression.py +1 -1
  164. snowflake/ml/modeling/linear_model/logistic_regression.py +1 -1
  165. snowflake/ml/modeling/linear_model/logistic_regression_cv.py +1 -1
  166. snowflake/ml/modeling/linear_model/multi_task_elastic_net.py +1 -1
  167. snowflake/ml/modeling/linear_model/multi_task_elastic_net_cv.py +1 -1
  168. snowflake/ml/modeling/linear_model/multi_task_lasso.py +1 -1
  169. snowflake/ml/modeling/linear_model/multi_task_lasso_cv.py +1 -1
  170. snowflake/ml/modeling/linear_model/orthogonal_matching_pursuit.py +1 -1
  171. snowflake/ml/modeling/linear_model/passive_aggressive_classifier.py +1 -1
  172. snowflake/ml/modeling/linear_model/passive_aggressive_regressor.py +1 -1
  173. snowflake/ml/modeling/linear_model/perceptron.py +1 -1
  174. snowflake/ml/modeling/linear_model/poisson_regressor.py +1 -1
  175. snowflake/ml/modeling/linear_model/ransac_regressor.py +1 -1
  176. snowflake/ml/modeling/linear_model/ridge.py +1 -1
  177. snowflake/ml/modeling/linear_model/ridge_classifier.py +1 -1
  178. snowflake/ml/modeling/linear_model/ridge_classifier_cv.py +1 -1
  179. snowflake/ml/modeling/linear_model/ridge_cv.py +1 -1
  180. snowflake/ml/modeling/linear_model/sgd_classifier.py +1 -1
  181. snowflake/ml/modeling/linear_model/sgd_one_class_svm.py +5 -3
  182. snowflake/ml/modeling/linear_model/sgd_regressor.py +1 -1
  183. snowflake/ml/modeling/linear_model/theil_sen_regressor.py +1 -1
  184. snowflake/ml/modeling/linear_model/tweedie_regressor.py +1 -1
  185. snowflake/ml/modeling/manifold/isomap.py +5 -3
  186. snowflake/ml/modeling/manifold/mds.py +5 -3
  187. snowflake/ml/modeling/manifold/spectral_embedding.py +5 -3
  188. snowflake/ml/modeling/manifold/tsne.py +5 -3
  189. snowflake/ml/modeling/metrics/ranking.py +3 -0
  190. snowflake/ml/modeling/metrics/regression.py +3 -0
  191. snowflake/ml/modeling/mixture/bayesian_gaussian_mixture.py +5 -3
  192. snowflake/ml/modeling/mixture/gaussian_mixture.py +5 -3
  193. snowflake/ml/modeling/model_selection/grid_search_cv.py +1 -5
  194. snowflake/ml/modeling/model_selection/randomized_search_cv.py +1 -5
  195. snowflake/ml/modeling/multiclass/one_vs_one_classifier.py +1 -1
  196. snowflake/ml/modeling/multiclass/one_vs_rest_classifier.py +1 -1
  197. snowflake/ml/modeling/multiclass/output_code_classifier.py +1 -1
  198. snowflake/ml/modeling/naive_bayes/bernoulli_nb.py +1 -1
  199. snowflake/ml/modeling/naive_bayes/categorical_nb.py +1 -1
  200. snowflake/ml/modeling/naive_bayes/complement_nb.py +1 -1
  201. snowflake/ml/modeling/naive_bayes/gaussian_nb.py +1 -1
  202. snowflake/ml/modeling/naive_bayes/multinomial_nb.py +1 -1
  203. snowflake/ml/modeling/neighbors/k_neighbors_classifier.py +1 -1
  204. snowflake/ml/modeling/neighbors/k_neighbors_regressor.py +1 -1
  205. snowflake/ml/modeling/neighbors/kernel_density.py +5 -3
  206. snowflake/ml/modeling/neighbors/local_outlier_factor.py +5 -3
  207. snowflake/ml/modeling/neighbors/nearest_centroid.py +1 -1
  208. snowflake/ml/modeling/neighbors/nearest_neighbors.py +5 -3
  209. snowflake/ml/modeling/neighbors/neighborhood_components_analysis.py +1 -1
  210. snowflake/ml/modeling/neighbors/radius_neighbors_classifier.py +1 -1
  211. snowflake/ml/modeling/neighbors/radius_neighbors_regressor.py +1 -1
  212. snowflake/ml/modeling/neural_network/bernoulli_rbm.py +5 -3
  213. snowflake/ml/modeling/neural_network/mlp_classifier.py +1 -1
  214. snowflake/ml/modeling/neural_network/mlp_regressor.py +1 -1
  215. snowflake/ml/modeling/pipeline/pipeline.py +6 -0
  216. snowflake/ml/modeling/preprocessing/binarizer.py +7 -3
  217. snowflake/ml/modeling/preprocessing/k_bins_discretizer.py +7 -2
  218. snowflake/ml/modeling/preprocessing/label_encoder.py +8 -7
  219. snowflake/ml/modeling/preprocessing/max_abs_scaler.py +7 -3
  220. snowflake/ml/modeling/preprocessing/min_max_scaler.py +7 -4
  221. snowflake/ml/modeling/preprocessing/normalizer.py +7 -3
  222. snowflake/ml/modeling/preprocessing/one_hot_encoder.py +53 -11
  223. snowflake/ml/modeling/preprocessing/ordinal_encoder.py +44 -13
  224. snowflake/ml/modeling/preprocessing/polynomial_features.py +5 -3
  225. snowflake/ml/modeling/preprocessing/robust_scaler.py +7 -4
  226. snowflake/ml/modeling/preprocessing/standard_scaler.py +7 -3
  227. snowflake/ml/modeling/semi_supervised/label_propagation.py +1 -1
  228. snowflake/ml/modeling/semi_supervised/label_spreading.py +1 -1
  229. snowflake/ml/modeling/svm/linear_svc.py +1 -1
  230. snowflake/ml/modeling/svm/linear_svr.py +1 -1
  231. snowflake/ml/modeling/svm/nu_svc.py +1 -1
  232. snowflake/ml/modeling/svm/nu_svr.py +1 -1
  233. snowflake/ml/modeling/svm/svc.py +1 -1
  234. snowflake/ml/modeling/svm/svr.py +1 -1
  235. snowflake/ml/modeling/tree/decision_tree_classifier.py +1 -1
  236. snowflake/ml/modeling/tree/decision_tree_regressor.py +1 -1
  237. snowflake/ml/modeling/tree/extra_tree_classifier.py +1 -1
  238. snowflake/ml/modeling/tree/extra_tree_regressor.py +1 -1
  239. snowflake/ml/modeling/xgboost/xgb_classifier.py +1 -1
  240. snowflake/ml/modeling/xgboost/xgb_regressor.py +1 -1
  241. snowflake/ml/modeling/xgboost/xgbrf_classifier.py +1 -1
  242. snowflake/ml/modeling/xgboost/xgbrf_regressor.py +1 -1
  243. snowflake/ml/registry/_manager/model_manager.py +16 -3
  244. snowflake/ml/version.py +1 -1
  245. {snowflake_ml_python-1.5.2.dist-info → snowflake_ml_python-1.5.4.dist-info}/METADATA +51 -7
  246. snowflake_ml_python-1.5.4.dist-info/RECORD +389 -0
  247. {snowflake_ml_python-1.5.2.dist-info → snowflake_ml_python-1.5.4.dist-info}/WHEEL +1 -1
  248. snowflake_ml_python-1.5.2.dist-info/RECORD +0 -384
  249. {snowflake_ml_python-1.5.2.dist-info → snowflake_ml_python-1.5.4.dist-info}/LICENSE.txt +0 -0
  250. {snowflake_ml_python-1.5.2.dist-info → snowflake_ml_python-1.5.4.dist-info}/top_level.txt +0 -0
@@ -1,4 +1,4 @@
1
- from snowflake.cortex._complete import Complete
1
+ from snowflake.cortex._complete import Complete, CompleteOptions
2
2
  from snowflake.cortex._extract_answer import ExtractAnswer
3
3
  from snowflake.cortex._sentiment import Sentiment
4
4
  from snowflake.cortex._summarize import Summarize
@@ -6,6 +6,7 @@ from snowflake.cortex._translate import Translate
6
6
 
7
7
  __all__ = [
8
8
  "Complete",
9
+ "CompleteOptions",
9
10
  "ExtractAnswer",
10
11
  "Sentiment",
11
12
  "Summarize",
@@ -1,35 +1,259 @@
1
- from typing import Optional, Union
1
+ import json
2
+ import logging
3
+ from typing import Iterator, List, Optional, TypedDict, Union, cast
4
+ from urllib.parse import urlunparse
5
+
6
+ import requests
7
+ from typing_extensions import NotRequired
2
8
 
3
9
  from snowflake import snowpark
4
- from snowflake.cortex._util import CORTEX_FUNCTIONS_TELEMETRY_PROJECT, call_sql_function
10
+ from snowflake.cortex._sse_client import SSEClient
11
+ from snowflake.cortex._util import (
12
+ CORTEX_FUNCTIONS_TELEMETRY_PROJECT,
13
+ SnowflakeAuthenticationException,
14
+ SnowflakeConfigurationException,
15
+ )
5
16
  from snowflake.ml._internal import telemetry
17
+ from snowflake.snowpark import context, functions
18
+
19
+ logger = logging.getLogger(__name__)
20
+
21
+
22
+ class ConversationMessage(TypedDict):
23
+ """Represents an conversation interaction."""
24
+
25
+ role: str
26
+ """The role of the participant. For example, "user" or "assistant"."""
27
+
28
+ content: str
29
+ """The content of the message."""
30
+
31
+
32
+ class CompleteOptions(TypedDict):
33
+ """Options configuring a snowflake.cortex.Complete call."""
34
+
35
+ max_tokens: NotRequired[int]
36
+ """ Sets the maximum number of output tokens in the response. Small values can result in
37
+ truncated responses. """
38
+ temperature: NotRequired[float]
39
+ """ A value from 0 to 1 (inclusive) that controls the randomness of the output of the language
40
+ model. A higher temperature (for example, 0.7) results in more diverse and random output, while a lower
41
+ temperature (such as 0.2) makes the output more deterministic and focused. """
42
+
43
+ top_p: NotRequired[float]
44
+ """ A value from 0 to 1 (inclusive) that controls the randomness and diversity of the language model,
45
+ generally used as an alternative to temperature. The difference is that top_p restricts the set of possible tokens
46
+ that the model outputs, while temperature influences which tokens are chosen at each step. """
47
+
48
+
49
+ class ResponseParseException(Exception):
50
+ """This exception is raised when the server response cannot be parsed."""
51
+
52
+ pass
53
+
54
+
55
+ def _call_complete_rest(
56
+ model: str,
57
+ prompt: Union[str, List[ConversationMessage]],
58
+ options: Optional[CompleteOptions] = None,
59
+ session: Optional[snowpark.Session] = None,
60
+ stream: bool = False,
61
+ ) -> requests.Response:
62
+ session = session or context.get_active_session()
63
+ if session is None:
64
+ raise SnowflakeAuthenticationException(
65
+ """Session required. Provide the session through a session=... argument or ensure an active session is
66
+ available in your environment."""
67
+ )
68
+
69
+ if session.connection.host is None or session.connection.host == "":
70
+ raise SnowflakeConfigurationException("Snowflake connection configuration does not specify 'host'")
71
+
72
+ if session.connection.rest is None or not hasattr(session.connection.rest, "token"):
73
+ raise SnowflakeAuthenticationException("Snowflake session error: REST token missing.")
74
+
75
+ if session.connection.rest.token is None or session.connection.rest.token == "":
76
+ raise SnowflakeAuthenticationException("Snowflake session error: REST token is empty.")
77
+
78
+ scheme = "https"
79
+ if hasattr(session.connection, "scheme"):
80
+ scheme = session.connection.scheme
81
+ url = urlunparse((scheme, session.connection.host, "api/v2/cortex/inference/complete", "", "", ""))
82
+
83
+ headers = {
84
+ "Content-Type": "application/json",
85
+ "Authorization": f'Snowflake Token="{session.connection.rest.token}"',
86
+ "Accept": "application/json, text/event-stream",
87
+ }
88
+
89
+ data = {
90
+ "model": model,
91
+ "stream": stream,
92
+ }
93
+ if isinstance(prompt, List):
94
+ data["messages"] = prompt
95
+ else:
96
+ data["messages"] = [{"content": prompt}]
97
+
98
+ if options:
99
+ if "max_tokens" in options:
100
+ data["max_tokens"] = options["max_tokens"]
101
+ data["max_output_tokens"] = options["max_tokens"]
102
+ if "temperature" in options:
103
+ data["temperature"] = options["temperature"]
104
+ if "top_p" in options:
105
+ data["top_p"] = options["top_p"]
106
+
107
+ logger.debug(f"making POST request to {url} (model={model}, stream={stream})")
108
+ response = requests.post(
109
+ url,
110
+ json=data,
111
+ headers=headers,
112
+ stream=stream,
113
+ )
114
+ response.raise_for_status()
115
+ return response
116
+
117
+
118
+ def _process_rest_response(response: requests.Response, stream: bool = False) -> Union[str, Iterator[str]]:
119
+ if stream:
120
+ return _return_stream_response(response)
121
+
122
+ try:
123
+ content = response.json()["choices"][0]["message"]["content"]
124
+ assert isinstance(content, str)
125
+ return content
126
+ except (KeyError, IndexError, AssertionError) as e:
127
+ # Unlike the streaming case, errors are not ignored because a message must be returned.
128
+ raise ResponseParseException("Failed to parse message from response.") from e
129
+
130
+
131
+ def _return_stream_response(response: requests.Response) -> Iterator[str]:
132
+ client = SSEClient(response)
133
+ for event in client.events():
134
+ try:
135
+ yield json.loads(event.data)["choices"][0]["delta"]["content"]
136
+ except (json.JSONDecodeError, KeyError, IndexError):
137
+ # For the sake of evolution of the output format,
138
+ # ignore stream messages that don't match the expected format.
139
+ pass
140
+
141
+
142
+ def _complete_call_sql_function_snowpark(
143
+ function: str, *args: Union[str, snowpark.Column, CompleteOptions]
144
+ ) -> snowpark.Column:
145
+ return cast(snowpark.Column, functions.builtin(function)(*args))
146
+
147
+
148
+ def _complete_call_sql_function_immediate(
149
+ function: str,
150
+ model: str,
151
+ prompt: Union[str, List[ConversationMessage]],
152
+ options: Optional[CompleteOptions],
153
+ session: Optional[snowpark.Session],
154
+ ) -> str:
155
+ session = session or context.get_active_session()
156
+ if session is None:
157
+ raise SnowflakeAuthenticationException(
158
+ """Session required. Provide the session through a session=... argument or ensure an active session is
159
+ available in your environment."""
160
+ )
161
+
162
+ # https://docs.snowflake.com/en/sql-reference/functions/complete-snowflake-cortex
163
+ if options is not None or not isinstance(prompt, str):
164
+ if isinstance(prompt, List):
165
+ prompt_arg = prompt
166
+ else:
167
+ prompt_arg = [{"role": "user", "content": prompt}]
168
+ options = options or {}
169
+ lit_args = [
170
+ functions.lit(model),
171
+ functions.lit(prompt_arg),
172
+ functions.lit(options),
173
+ ]
174
+ else:
175
+ lit_args = [
176
+ functions.lit(model),
177
+ functions.lit(prompt),
178
+ ]
179
+
180
+ empty_df = session.create_dataframe([snowpark.Row()])
181
+ df = empty_df.select(functions.builtin(function)(*lit_args))
182
+ return cast(str, df.collect()[0][0])
183
+
184
+
185
+ def _complete_sql_impl(
186
+ function: str,
187
+ model: Union[str, snowpark.Column],
188
+ prompt: Union[str, List[ConversationMessage], snowpark.Column],
189
+ options: Optional[Union[CompleteOptions, snowpark.Column]],
190
+ session: Optional[snowpark.Session],
191
+ ) -> Union[str, snowpark.Column]:
192
+ if isinstance(prompt, snowpark.Column):
193
+ if options is not None:
194
+ return _complete_call_sql_function_snowpark(function, model, prompt, options)
195
+ else:
196
+ return _complete_call_sql_function_snowpark(function, model, prompt)
197
+ if isinstance(model, snowpark.Column):
198
+ raise ValueError("'model' cannot be a snowpark.Column when 'prompt' is a string.")
199
+ if isinstance(options, snowpark.Column):
200
+ raise ValueError("'options' cannot be a snowpark.Column when 'prompt' is a string.")
201
+ return _complete_call_sql_function_immediate(function, model, prompt, options, session)
202
+
203
+
204
+ def _complete_impl(
205
+ model: Union[str, snowpark.Column],
206
+ prompt: Union[str, List[ConversationMessage], snowpark.Column],
207
+ options: Optional[CompleteOptions] = None,
208
+ session: Optional[snowpark.Session] = None,
209
+ use_rest_api_experimental: bool = False,
210
+ stream: bool = False,
211
+ function: str = "snowflake.cortex.complete",
212
+ ) -> Union[str, Iterator[str], snowpark.Column]:
213
+ if use_rest_api_experimental:
214
+ if not isinstance(model, str):
215
+ raise ValueError("in REST mode, 'model' must be a string")
216
+ if not isinstance(prompt, str) and not isinstance(prompt, List):
217
+ raise ValueError("in REST mode, 'prompt' must be a string or a list of ConversationMessage")
218
+ response = _call_complete_rest(model, prompt, options, session=session, stream=stream)
219
+ return _process_rest_response(response, stream=stream)
220
+ if stream is True:
221
+ raise ValueError("streaming can only be enabled in REST mode, set use_rest_api_experimental=True")
222
+ return _complete_sql_impl(function, model, prompt, options, session)
6
223
 
7
224
 
8
- @snowpark._internal.utils.experimental(version="1.0.12")
9
225
  @telemetry.send_api_usage_telemetry(
10
226
  project=CORTEX_FUNCTIONS_TELEMETRY_PROJECT,
11
227
  )
12
228
  def Complete(
13
- model: Union[str, snowpark.Column], prompt: Union[str, snowpark.Column], session: Optional[snowpark.Session] = None
14
- ) -> Union[str, snowpark.Column]:
229
+ model: Union[str, snowpark.Column],
230
+ prompt: Union[str, List[ConversationMessage], snowpark.Column],
231
+ *,
232
+ options: Optional[CompleteOptions] = None,
233
+ session: Optional[snowpark.Session] = None,
234
+ use_rest_api_experimental: bool = False,
235
+ stream: bool = False,
236
+ ) -> Union[str, Iterator[str], snowpark.Column]:
15
237
  """Complete calls into the LLM inference service to perform completion.
16
238
 
17
239
  Args:
18
240
  model: A Column of strings representing model types.
19
241
  prompt: A Column of prompts to send to the LLM.
242
+ options: A instance of snowflake.cortex.CompleteOptions
20
243
  session: The snowpark session to use. Will be inferred by context if not specified.
244
+ use_rest_api_experimental (bool): Toggles between the use of SQL and REST implementation. This feature is
245
+ experimental and can be removed at any time.
246
+ stream (bool): Enables streaming. When enabled, a generator function is returned that provides the streaming
247
+ output as it is received. Each update is a string containing the new text content since the previous update.
248
+ The use of streaming requires the experimental use_rest_api_experimental flag to be enabled.
249
+
250
+ Raises:
251
+ ValueError: If `stream` is set to True and `use_rest_api_experimental` is set to False.
21
252
 
22
253
  Returns:
23
254
  A column of string responses.
24
255
  """
25
-
26
- return _complete_impl("snowflake.cortex.complete", model, prompt, session=session)
27
-
28
-
29
- def _complete_impl(
30
- function: str,
31
- model: Union[str, snowpark.Column],
32
- prompt: Union[str, snowpark.Column],
33
- session: Optional[snowpark.Session] = None,
34
- ) -> Union[str, snowpark.Column]:
35
- return call_sql_function(function, session, model, prompt)
256
+ try:
257
+ return _complete_impl(model, prompt, options, session, use_rest_api_experimental, stream)
258
+ except ValueError as err:
259
+ raise err
@@ -5,7 +5,6 @@ from snowflake.cortex._util import CORTEX_FUNCTIONS_TELEMETRY_PROJECT, call_sql_
5
5
  from snowflake.ml._internal import telemetry
6
6
 
7
7
 
8
- @snowpark._internal.utils.experimental(version="1.0.12")
9
8
  @telemetry.send_api_usage_telemetry(
10
9
  project=CORTEX_FUNCTIONS_TELEMETRY_PROJECT,
11
10
  )
@@ -5,7 +5,6 @@ from snowflake.cortex._util import CORTEX_FUNCTIONS_TELEMETRY_PROJECT, call_sql_
5
5
  from snowflake.ml._internal import telemetry
6
6
 
7
7
 
8
- @snowpark._internal.utils.experimental(version="1.0.12")
9
8
  @telemetry.send_api_usage_telemetry(
10
9
  project=CORTEX_FUNCTIONS_TELEMETRY_PROJECT,
11
10
  )
@@ -0,0 +1,81 @@
1
+ from typing import Iterator, cast
2
+
3
+ import requests
4
+
5
+
6
+ class Event:
7
+ def __init__(self, event: str = "message", data: str = "") -> None:
8
+ self.event = event
9
+ self.data = data
10
+
11
+ def __str__(self) -> str:
12
+ s = f"{self.event} event"
13
+ if self.data:
14
+ s += f", {len(self.data)} bytes"
15
+ else:
16
+ s += ", no data"
17
+ return s
18
+
19
+
20
+ class SSEClient:
21
+ def __init__(self, response: requests.Response) -> None:
22
+
23
+ self.response = response
24
+
25
+ def _read(self) -> Iterator[str]:
26
+
27
+ lines = b""
28
+ for chunk in self.response:
29
+ for line in chunk.splitlines(True):
30
+ lines += line
31
+ if lines.endswith((b"\r\r", b"\n\n", b"\r\n\r\n")):
32
+ yield cast(str, lines)
33
+ lines = b""
34
+ if lines:
35
+ yield cast(str, lines)
36
+
37
+ def events(self) -> Iterator[Event]:
38
+ for raw_event in self._read():
39
+ event = Event()
40
+ # splitlines() only uses \r and \n
41
+ for line in raw_event.splitlines():
42
+
43
+ line = cast(bytes, line).decode("utf-8")
44
+
45
+ data = line.split(":", 1)
46
+ field = data[0]
47
+
48
+ if len(data) > 1:
49
+ # "If value starts with a single U+0020 SPACE character,
50
+ # remove it from value. .strip() would remove all white spaces"
51
+ if data[1].startswith(" "):
52
+ value = data[1][1:]
53
+ else:
54
+ value = data[1]
55
+ else:
56
+ value = ""
57
+
58
+ # The data field may come over multiple lines and their values
59
+ # are concatenated with each other.
60
+ if field == "data":
61
+ event.data += value + "\n"
62
+ elif field == "event":
63
+ event.event = value
64
+
65
+ if not event.data:
66
+ continue
67
+
68
+ # If the data field ends with a newline, remove it.
69
+ if event.data.endswith("\n"):
70
+ event.data = event.data[0:-1] # Replace trailing newline - rstrip would remove multiple.
71
+
72
+ # Empty event names default to 'message'
73
+ event.event = event.event or "message"
74
+
75
+ if event.event != "message": # ignore anything but “message” or default event
76
+ continue
77
+
78
+ yield event
79
+
80
+ def close(self) -> None:
81
+ self.response.close()
@@ -5,7 +5,6 @@ from snowflake.cortex._util import CORTEX_FUNCTIONS_TELEMETRY_PROJECT, call_sql_
5
5
  from snowflake.ml._internal import telemetry
6
6
 
7
7
 
8
- @snowpark._internal.utils.experimental(version="1.0.12")
9
8
  @telemetry.send_api_usage_telemetry(
10
9
  project=CORTEX_FUNCTIONS_TELEMETRY_PROJECT,
11
10
  )
@@ -5,7 +5,6 @@ from snowflake.cortex._util import CORTEX_FUNCTIONS_TELEMETRY_PROJECT, call_sql_
5
5
  from snowflake.ml._internal import telemetry
6
6
 
7
7
 
8
- @snowpark._internal.utils.experimental(version="1.0.12")
9
8
  @telemetry.send_api_usage_telemetry(
10
9
  project=CORTEX_FUNCTIONS_TELEMETRY_PROJECT,
11
10
  )
snowflake/cortex/_util.py CHANGED
@@ -1,4 +1,4 @@
1
- from typing import Optional, Union, cast
1
+ from typing import Dict, Optional, Union, cast
2
2
 
3
3
  from snowflake import snowpark
4
4
  from snowflake.snowpark import context, functions
@@ -6,32 +6,56 @@ from snowflake.snowpark import context, functions
6
6
  CORTEX_FUNCTIONS_TELEMETRY_PROJECT = "CortexFunctions"
7
7
 
8
8
 
9
+ class SnowflakeAuthenticationException(Exception):
10
+ """This exception is raised when there is an issue with Snowflake's configuration."""
11
+
12
+ pass
13
+
14
+
15
+ class SnowflakeConfigurationException(Exception):
16
+ """This exception is raised when there is an issue with Snowflake's configuration."""
17
+
18
+ pass
19
+
20
+
9
21
  # Calls a sql function, handling both immediate (e.g. python types) and batch
10
22
  # (e.g. snowpark column and literal type modes).
11
23
  def call_sql_function(
12
- function: str, session: Optional[snowpark.Session], *args: Union[str, snowpark.Column]
24
+ function: str,
25
+ session: Optional[snowpark.Session],
26
+ *args: Union[str, snowpark.Column, Dict[str, Union[int, float]]],
13
27
  ) -> Union[str, snowpark.Column]:
14
28
  handle_as_column = False
29
+
15
30
  for arg in args:
16
31
  if isinstance(arg, snowpark.Column):
17
32
  handle_as_column = True
18
33
 
19
34
  if handle_as_column:
20
- return cast(Union[str, snowpark.Column], call_sql_function_column(function, *args))
21
- return cast(Union[str, snowpark.Column], call_sql_function_immediate(function, session, *args))
35
+ return cast(Union[str, snowpark.Column], _call_sql_function_column(function, *args))
36
+ return cast(
37
+ Union[str, snowpark.Column],
38
+ _call_sql_function_immediate(function, session, *args),
39
+ )
22
40
 
23
41
 
24
- def call_sql_function_column(function: str, *args: Union[str, snowpark.Column]) -> snowpark.Column:
42
+ def _call_sql_function_column(
43
+ function: str, *args: Union[str, snowpark.Column, Dict[str, Union[int, float]]]
44
+ ) -> snowpark.Column:
25
45
  return cast(snowpark.Column, functions.builtin(function)(*args))
26
46
 
27
47
 
28
- def call_sql_function_immediate(
29
- function: str, session: Optional[snowpark.Session], *args: Union[str, snowpark.Column]
48
+ def _call_sql_function_immediate(
49
+ function: str,
50
+ session: Optional[snowpark.Session],
51
+ *args: Union[str, snowpark.Column, Dict[str, Union[int, float]]],
30
52
  ) -> str:
53
+ session = session or context.get_active_session()
31
54
  if session is None:
32
- session = context.get_active_session()
33
- if session is None:
34
- raise Exception("No session available in the current context nor specified as an argument.")
55
+ raise SnowflakeAuthenticationException(
56
+ """Session required. Provide the session through a session=... argument or ensure an active session is
57
+ available in your environment."""
58
+ )
35
59
 
36
60
  lit_args = []
37
61
  for arg in args:
@@ -64,13 +64,20 @@ class ImageRegistryHttpClient:
64
64
  operations. For general use of a retryable HTTP client, consider using the "retryable_http" module.
65
65
  """
66
66
 
67
- def __init__(self, *, session: snowpark.Session, repo_url: str) -> None:
67
+ def __init__(self, *, repo_url: str, session: Optional[snowpark.Session] = None, no_cred: bool = False) -> None:
68
68
  self._repo_url = repo_url
69
- self._session_token_manager = session_token_manager.SessionTokenManager(session)
70
69
  self._retryable_http = retryable_http.get_http_client()
71
- self._bearer_token = ""
70
+ self._no_cred = no_cred
71
+
72
+ if not self._no_cred:
73
+ self._bearer_token = ""
74
+ assert session is not None
75
+ self._session_token_manager = session_token_manager.SessionTokenManager(session)
72
76
 
73
77
  def _with_bearer_token_header(self, headers: Optional[Dict[str, str]] = None) -> Dict[str, str]:
78
+ if self._no_cred:
79
+ return {} if not headers else headers.copy()
80
+
74
81
  if not self._bearer_token:
75
82
  self._fetch_bearer_token()
76
83
  assert self._bearer_token
@@ -13,6 +13,7 @@ This library only supports a limited set of features:
13
13
  It's recommended to use this library to copy previously tested images using sha256 to avoid surprises
14
14
  with respect to compatibility.
15
15
  """
16
+
16
17
  import dataclasses
17
18
  import hashlib
18
19
  import io
@@ -152,7 +153,8 @@ class BlobTransfer:
152
153
  src_image: ImageDescriptor
153
154
  dest_image: ImageDescriptor
154
155
  manifest: Manifest
155
- image_registry_http_client: image_registry_http_client.ImageRegistryHttpClient
156
+ src_image_registry_http_client: image_registry_http_client.ImageRegistryHttpClient
157
+ dest_image_registry_http_client: image_registry_http_client.ImageRegistryHttpClient
156
158
 
157
159
  def upload_all_blobs(self) -> None:
158
160
  blob_digests = self.manifest.get_blob_digests()
@@ -169,7 +171,7 @@ class BlobTransfer:
169
171
  """
170
172
  Check if the blob already exists in the destination registry.
171
173
  """
172
- resp = self.image_registry_http_client.head(self.dest_image.blob_link(blob_digest), headers={})
174
+ resp = self.dest_image_registry_http_client.head(self.dest_image.blob_link(blob_digest), headers={})
173
175
  return resp.status_code != 200
174
176
 
175
177
  def _fetch_blob(self, blob_digest: str) -> Tuple[io.BytesIO, int]:
@@ -178,7 +180,7 @@ class BlobTransfer:
178
180
  """
179
181
  src_blob_link = self.src_image.blob_link(blob_digest)
180
182
  headers = {_CONTENT_LENGTH_HEADER: "0"}
181
- resp = self.image_registry_http_client.get(src_blob_link, headers=headers)
183
+ resp = self.src_image_registry_http_client.get(src_blob_link, headers=headers)
182
184
 
183
185
  assert resp.status_code == 200, f"Blob GET failed with code {resp.status_code}"
184
186
  assert _CONTENT_LENGTH_HEADER in resp.headers, f"Blob does not contain {_CONTENT_LENGTH_HEADER}"
@@ -189,7 +191,7 @@ class BlobTransfer:
189
191
  """
190
192
  Obtain the upload URL from the destination registry.
191
193
  """
192
- response = self.image_registry_http_client.post(self.dest_image.blob_upload_link())
194
+ response = self.dest_image_registry_http_client.post(self.dest_image.blob_upload_link())
193
195
  assert (
194
196
  response.status_code == 202
195
197
  ), f"Failed to get the upload URL to destination. Status {response.status_code}. {str(response.content)}"
@@ -216,14 +218,14 @@ class BlobTransfer:
216
218
  headers[_CONTENT_RANGE_HEADER] = f"{start_byte}-{end_byte}"
217
219
  headers[_CONTENT_LENGTH_HEADER] = str(chunk_length)
218
220
 
219
- resp = self.image_registry_http_client.patch(next_loc, headers=headers, data=chunk)
221
+ resp = self.dest_image_registry_http_client.patch(next_loc, headers=headers, data=chunk)
220
222
  assert resp.status_code == 202, f"Blob PATCH failed with code {resp.status_code}"
221
223
 
222
224
  next_loc = resp.headers[_LOCATION_HEADER]
223
225
  start_byte += chunk_length
224
226
 
225
227
  # Finalize the upload
226
- resp = self.image_registry_http_client.put(f"{next_loc}&digest={blob_digest}")
228
+ resp = self.dest_image_registry_http_client.put(f"{next_loc}&digest={blob_digest}")
227
229
  assert resp.status_code == 201, f"Blob PUT failed with code {resp.status_code}"
228
230
 
229
231
  def _transfer(self, blob_digest: str) -> None:
@@ -340,21 +342,32 @@ def copy_image(
340
342
  src_image: ImageDescriptor,
341
343
  dest_image: ImageDescriptor,
342
344
  arch: _Arch,
343
- retryable_http: image_registry_http_client.ImageRegistryHttpClient,
345
+ src_retryable_http: image_registry_http_client.ImageRegistryHttpClient,
346
+ dest_retryable_http: image_registry_http_client.ImageRegistryHttpClient,
344
347
  ) -> None:
345
348
  logger.debug(f"Pulling image manifest for {src_image}")
346
349
 
347
350
  # 1. Get the manifest
348
- manifest = get_manifest(src_image, arch, retryable_http)
351
+ manifest = get_manifest(src_image, arch, src_retryable_http)
349
352
  logger.debug(f"Manifest pulled for {src_image} with digest {manifest.manifest_digest}")
350
353
 
351
354
  # 2: Retrieve all blob digests from manifest; fetch blob based on blob digest, then upload blob.
352
- blob_transfer = BlobTransfer(src_image, dest_image, manifest, image_registry_http_client=retryable_http)
355
+ blob_transfer = BlobTransfer(
356
+ src_image,
357
+ dest_image,
358
+ manifest,
359
+ src_image_registry_http_client=src_retryable_http,
360
+ dest_image_registry_http_client=dest_retryable_http,
361
+ )
353
362
  blob_transfer.upload_all_blobs()
354
363
 
355
364
  # 3. Upload the manifest
356
365
  logger.debug(f"All blobs copied successfully. Copying manifest for {src_image} to {dest_image}")
357
- put_manifest(dest_image, manifest, retryable_http)
366
+ put_manifest(
367
+ dest_image,
368
+ manifest,
369
+ dest_retryable_http,
370
+ )
358
371
 
359
372
  logger.debug(f"Image {src_image} copied to {dest_image}")
360
373
 
@@ -201,6 +201,12 @@ class ImageRegistryClient:
201
201
  )
202
202
  # TODO[shchen]: Remove the imagelib, instead rely on the copy image system function later.
203
203
  imagelib.copy_image(
204
- src_image=src_image, dest_image=dest_image, arch=arch, retryable_http=self.image_registry_http_client
204
+ src_image=src_image,
205
+ dest_image=dest_image,
206
+ arch=arch,
207
+ src_retryable_http=image_registry_http_client.ImageRegistryHttpClient(
208
+ repo_url=src_image.registry_name, no_cred=True
209
+ ),
210
+ dest_retryable_http=self.image_registry_http_client,
205
211
  )
206
212
  logger.info("Image copy completed successfully")
@@ -1,11 +1,11 @@
1
1
  # Error code from Snowflake Python Connector.
2
- ERRNO_OBJECT_ALREADY_EXISTS = "002002"
3
- ERRNO_OBJECT_NOT_EXIST = "002043"
4
- ERRNO_FILES_ALREADY_EXISTING = "001030"
5
- ERRNO_VERSION_ALREADY_EXISTS = "092917"
6
- ERRNO_DATASET_NOT_EXIST = "399019"
7
- ERRNO_DATASET_VERSION_NOT_EXIST = "399012"
8
- ERRNO_DATASET_VERSION_ALREADY_EXISTS = "399020"
2
+ ERRNO_OBJECT_ALREADY_EXISTS = 2002
3
+ ERRNO_OBJECT_NOT_EXIST = 2043
4
+ ERRNO_FILES_ALREADY_EXISTING = 1030
5
+ ERRNO_VERSION_ALREADY_EXISTS = 92917
6
+ ERRNO_DATASET_NOT_EXIST = 399019
7
+ ERRNO_DATASET_VERSION_NOT_EXIST = 399012
8
+ ERRNO_DATASET_VERSION_ALREADY_EXISTS = 399020
9
9
 
10
10
 
11
11
  class DatasetError(Exception):
@@ -1,7 +1,7 @@
1
1
  # Error code from Snowflake Python Connector.
2
- ERRNO_FILE_EXIST_IN_STAGE = "001030"
3
- ERRNO_DOMAIN_NOT_EXIST = "002003"
4
- ERRNO_STAGE_NOT_EXIST = "391707"
2
+ ERRNO_FILE_EXIST_IN_STAGE = 1030
3
+ ERRNO_DOMAIN_NOT_EXIST = 2003
4
+ ERRNO_STAGE_NOT_EXIST = 391707
5
5
 
6
6
 
7
7
  class FileSetError(Exception):
@@ -0,0 +1,6 @@
1
+ """SQL Error Codes"""
2
+
3
+ # SQL compilation error: Object ''{0}'' does not exist or not authorized.
4
+ OBJECT_NOT_EXIST = 2001
5
+ # SQL compilation error: Object ''{0}'' already exists.
6
+ OBJECT_ALREADY_EXISTS = 2002