snowflake-ml-python 2.5.0__py3-none-any.whl → 2.6.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.
- snowflake/cortex/_classify_text.py +38 -32
- snowflake/ml/_internal/platform_capabilities.py +1 -1
- snowflake/ml/dataset/dataset.py +1 -1
- snowflake/ml/feature_store/decl/__init__.py +168 -0
- snowflake/ml/feature_store/decl/api.py +1796 -0
- snowflake/ml/feature_store/decl/compiler.py +770 -0
- snowflake/ml/feature_store/decl/dependencies.py +163 -0
- snowflake/ml/feature_store/decl/enums.py +55 -0
- snowflake/ml/feature_store/decl/errors.py +87 -0
- snowflake/ml/feature_store/decl/exporter.py +2376 -0
- snowflake/ml/feature_store/decl/imperative_executor.py +3487 -0
- snowflake/ml/feature_store/decl/invariants.py +3869 -0
- snowflake/ml/feature_store/decl/loader.py +871 -0
- snowflake/ml/feature_store/decl/manifest.py +348 -0
- snowflake/ml/feature_store/decl/planner.py +1319 -0
- snowflake/ml/feature_store/decl/project_paths.py +152 -0
- snowflake/ml/feature_store/decl/python_codegen.py +413 -0
- snowflake/ml/feature_store/decl/queries.py +172 -0
- snowflake/ml/feature_store/decl/serializer.py +313 -0
- snowflake/ml/feature_store/decl/service.py +736 -0
- snowflake/ml/feature_store/decl/spec_compiler.py +612 -0
- snowflake/ml/feature_store/decl/spec_models.py +1040 -0
- snowflake/ml/feature_store/decl/state.py +1995 -0
- snowflake/ml/feature_store/decl/templating.py +158 -0
- snowflake/ml/feature_store/decl/types.py +219 -0
- snowflake/ml/feature_store/decl/udf_loader.py +99 -0
- snowflake/ml/feature_store/feature_store.py +45 -21
- snowflake/ml/feature_store/feature_view.py +59 -17
- snowflake/ml/feature_store/spec/table_schema_evolution.py +10 -4
- snowflake/ml/jobs/__init__.py +10 -0
- snowflake/ml/jobs/_interop/data_utils.py +34 -2
- snowflake/ml/jobs/_interop/legacy.py +3 -3
- snowflake/ml/jobs/_utils/constants.py +9 -0
- snowflake/ml/jobs/_utils/object_naming.py +45 -0
- snowflake/ml/jobs/_utils/option_parsing.py +102 -0
- snowflake/ml/jobs/_utils/runtime_env_utils.py +25 -1
- snowflake/ml/jobs/_utils/stage_utils.py +25 -1
- snowflake/ml/jobs/code_bundle.py +532 -0
- snowflake/ml/jobs/job.py +17 -0
- snowflake/ml/jobs/job_definition.py +20 -51
- snowflake/ml/jobs/manager.py +3 -1
- snowflake/ml/model/__init__.py +0 -2
- snowflake/ml/model/_client/model/batch_inference_task.py +5 -9
- snowflake/ml/model/_client/model/model_version_impl.py +6 -34
- snowflake/ml/model/_packager/model_handlers/huggingface/_handler.py +19 -50
- snowflake/ml/model/_packager/model_handlers/mlflow.py +66 -101
- snowflake/ml/model/models/huggingface.py +135 -37
- snowflake/ml/model/type_hints.py +3 -4
- snowflake/ml/registry/_manager/model_parameter_reconciler.py +31 -1
- snowflake/ml/version.py +1 -1
- {snowflake_ml_python-2.5.0.dist-info → snowflake_ml_python-2.6.0.dist-info}/METADATA +36 -2
- {snowflake_ml_python-2.5.0.dist-info → snowflake_ml_python-2.6.0.dist-info}/RECORD +55 -30
- snowflake/ml/model/models/huggingface_pipeline.py +0 -268
- {snowflake_ml_python-2.5.0.dist-info → snowflake_ml_python-2.6.0.dist-info}/WHEEL +0 -0
- {snowflake_ml_python-2.5.0.dist-info → snowflake_ml_python-2.6.0.dist-info}/licenses/LICENSE.txt +0 -0
- {snowflake_ml_python-2.5.0.dist-info → snowflake_ml_python-2.6.0.dist-info}/top_level.txt +0 -0
|
@@ -6,24 +6,23 @@ from typing_extensions import deprecated
|
|
|
6
6
|
from snowflake import snowpark
|
|
7
7
|
from snowflake.cortex._util import (
|
|
8
8
|
CORTEX_FUNCTIONS_TELEMETRY_PROJECT,
|
|
9
|
-
|
|
9
|
+
SnowflakeAuthenticationException,
|
|
10
10
|
warn_cortex_deprecated,
|
|
11
11
|
)
|
|
12
12
|
from snowflake.ml._internal import telemetry
|
|
13
|
-
from snowflake.snowpark import functions
|
|
13
|
+
from snowflake.snowpark import context, functions
|
|
14
14
|
|
|
15
15
|
_AI_CLASSIFY_FUNCTION_NAME = "AI_CLASSIFY"
|
|
16
|
-
#
|
|
17
|
-
#
|
|
18
|
-
#
|
|
19
|
-
|
|
16
|
+
# AI_CLASSIFY requires its config argument to be a constant object literal. A Python dict is rendered by
|
|
17
|
+
# Snowpark as PARSE_JSON('...')::OBJECT, which the server rejects ("... is not a constant"), so emit the
|
|
18
|
+
# config as a SQL object constant via sql_expr -- this mirrors snowflake.snowpark.functions.ai_classify.
|
|
19
|
+
# Legacy CLASSIFY_TEXT was always single-label, so set output_mode explicitly to keep that contract.
|
|
20
|
+
_AI_CLASSIFY_SINGLE_LABEL_CONFIG_SQL = "{'output_mode': 'single'}"
|
|
20
21
|
|
|
21
22
|
|
|
22
23
|
def _adapt_ai_classify_result(result: Any) -> str:
|
|
23
24
|
"""Map an AI_CLASSIFY result to the legacy CLASSIFY_TEXT {"label": ...} JSON string."""
|
|
24
|
-
#
|
|
25
|
-
# collects as a JSON string such as '{"label": "positive"}'. We reproduce that exact shape so
|
|
26
|
-
# existing callers that json.loads the result and read ["label"] keep working.
|
|
25
|
+
# Used for non-Column results (e.g. a dict/JSON string): reproduce the legacy single-label object shape.
|
|
27
26
|
parsed: Any = result
|
|
28
27
|
if isinstance(result, str):
|
|
29
28
|
try:
|
|
@@ -40,6 +39,20 @@ def _adapt_ai_classify_result(result: Any) -> str:
|
|
|
40
39
|
return json.dumps({"label": label})
|
|
41
40
|
|
|
42
41
|
|
|
42
|
+
def _ai_classify_label_column(
|
|
43
|
+
str_input: str | snowpark.Column,
|
|
44
|
+
categories: list[str] | snowpark.Column,
|
|
45
|
+
) -> snowpark.Column:
|
|
46
|
+
"""Call AI_CLASSIFY in single-label mode and re-wrap to the legacy CLASSIFY_TEXT {"label": ...} OBJECT."""
|
|
47
|
+
result = functions.builtin(_AI_CLASSIFY_FUNCTION_NAME)(
|
|
48
|
+
str_input, categories, functions.sql_expr(_AI_CLASSIFY_SINGLE_LABEL_CONFIG_SQL)
|
|
49
|
+
)
|
|
50
|
+
# AI_CLASSIFY returns {"labels": [...]}; collapse to the legacy single {"label": ...}. Subscript access
|
|
51
|
+
# (not functions.get with a bare string, which Snowpark treats as a column identifier) uses literal keys.
|
|
52
|
+
label = functions.coalesce(result["labels"][0], result["label"])
|
|
53
|
+
return functions.object_construct(functions.lit("label"), label)
|
|
54
|
+
|
|
55
|
+
|
|
43
56
|
@telemetry.send_api_usage_telemetry(
|
|
44
57
|
project=CORTEX_FUNCTIONS_TELEMETRY_PROJECT,
|
|
45
58
|
)
|
|
@@ -56,32 +69,25 @@ def classify_text(
|
|
|
56
69
|
session: The snowpark session to use. Will be inferred by context if not specified.
|
|
57
70
|
|
|
58
71
|
Returns:
|
|
59
|
-
A column of classification responses.
|
|
72
|
+
A column of classification responses (legacy CLASSIFY_TEXT {"label": ...} shape).
|
|
73
|
+
|
|
74
|
+
Raises:
|
|
75
|
+
SnowflakeAuthenticationException: if no session is provided and none is active.
|
|
60
76
|
"""
|
|
61
77
|
warn_cortex_deprecated("classify_text", "ai_classify")
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
if isinstance(result, snowpark.Column):
|
|
66
|
-
# AI_CLASSIFY returns {"labels": [...]}; re-wrap as the legacy CLASSIFY_TEXT {"label": ...} OBJECT
|
|
67
|
-
# so downstream SQL that reads col["label"] is unchanged. Subscript access (not functions.get with
|
|
68
|
-
# a bare string, which Snowpark treats as a column identifier) extracts the field by literal key.
|
|
69
|
-
label = functions.coalesce(result["labels"][0], result["label"])
|
|
70
|
-
return functions.object_construct(functions.lit("label"), label)
|
|
71
|
-
return _adapt_ai_classify_result(result)
|
|
72
|
-
|
|
78
|
+
column = _ai_classify_label_column(str_input, categories)
|
|
79
|
+
if isinstance(str_input, snowpark.Column) or isinstance(categories, snowpark.Column):
|
|
80
|
+
return column
|
|
73
81
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
args.append(config)
|
|
84
|
-
return cast(str | snowpark.Column, call_sql_function(function, session, *args))
|
|
82
|
+
# Immediate (literal) path: evaluate and return the collected OBJECT as a JSON string, exactly as the
|
|
83
|
+
# legacy CLASSIFY_TEXT immediate path did.
|
|
84
|
+
session = session or context.get_active_session()
|
|
85
|
+
if session is None:
|
|
86
|
+
raise SnowflakeAuthenticationException(
|
|
87
|
+
"""Session required. Provide the session through a session=... argument or ensure an active session is
|
|
88
|
+
available in your environment."""
|
|
89
|
+
)
|
|
90
|
+
return cast(str, session.create_dataframe([snowpark.Row()]).select(column).collect()[0][0])
|
|
85
91
|
|
|
86
92
|
|
|
87
93
|
ClassifyText = deprecated(
|
|
@@ -93,7 +93,7 @@ class PlatformCapabilities:
|
|
|
93
93
|
return self._get_bool_feature(ENABLE_MODEL_METHOD_SIGNATURE_PARAMETERS, False)
|
|
94
94
|
|
|
95
95
|
def is_lora_adapters_enabled(self) -> bool:
|
|
96
|
-
return False
|
|
96
|
+
return self._get_bool_feature(ENABLE_LORA_ADAPTERS, False)
|
|
97
97
|
|
|
98
98
|
def is_single_output_native_type_enabled(self) -> bool:
|
|
99
99
|
"""Whether a single, non-OBJECT model FUNCTION output is registered with its native SQL type.
|
snowflake/ml/dataset/dataset.py
CHANGED
|
@@ -341,7 +341,7 @@ class Dataset(lineage_node.LineageNode):
|
|
|
341
341
|
metadata = dataset_metadata.DatasetMetadata(
|
|
342
342
|
source_query=source_query,
|
|
343
343
|
owner=self._session.sql("SELECT CURRENT_USER()").collect(statement_params=_TELEMETRY_STATEMENT_PARAMS)[0][
|
|
344
|
-
|
|
344
|
+
0
|
|
345
345
|
],
|
|
346
346
|
exclude_cols=exclude_cols,
|
|
347
347
|
label_cols=label_cols,
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
"""Public API for the declarative feature store library.
|
|
2
|
+
|
|
3
|
+
Import the key functions and types from this package:
|
|
4
|
+
|
|
5
|
+
from snowflake.ml.feature_store.decl import (
|
|
6
|
+
load_specs,
|
|
7
|
+
validate_specs,
|
|
8
|
+
generate_plan,
|
|
9
|
+
fetch_applied_state,
|
|
10
|
+
SpecBatch,
|
|
11
|
+
AppliedState,
|
|
12
|
+
Plan,
|
|
13
|
+
PlanOptions,
|
|
14
|
+
ValidationResult,
|
|
15
|
+
PlanOp,
|
|
16
|
+
AppliedObject,
|
|
17
|
+
SpecLoadError,
|
|
18
|
+
ValidationError,
|
|
19
|
+
DependencyError,
|
|
20
|
+
StateDriftError,
|
|
21
|
+
FSBaseType,
|
|
22
|
+
FeatureViewKind,
|
|
23
|
+
SourceType,
|
|
24
|
+
FeatureAggregationMethod,
|
|
25
|
+
OpKind,
|
|
26
|
+
TYPE_ALIASES,
|
|
27
|
+
normalize_type,
|
|
28
|
+
FSColumn,
|
|
29
|
+
SpecBase,
|
|
30
|
+
Entity,
|
|
31
|
+
StreamingSource,
|
|
32
|
+
BatchSource,
|
|
33
|
+
SourceRef,
|
|
34
|
+
UDF,
|
|
35
|
+
Feature,
|
|
36
|
+
FeatureView,
|
|
37
|
+
FeatureViewRef,
|
|
38
|
+
FeatureGroup,
|
|
39
|
+
)
|
|
40
|
+
"""
|
|
41
|
+
|
|
42
|
+
try:
|
|
43
|
+
from snowflake.ml.feature_store.decl.api import (
|
|
44
|
+
discover_project,
|
|
45
|
+
fetch_applied_state,
|
|
46
|
+
generate_plan,
|
|
47
|
+
load_manifest,
|
|
48
|
+
load_project,
|
|
49
|
+
load_specs,
|
|
50
|
+
resolve_datasource_columns,
|
|
51
|
+
resolve_target,
|
|
52
|
+
validate_specs,
|
|
53
|
+
)
|
|
54
|
+
except ModuleNotFoundError: # lower-layer BUILD targets omit api.py
|
|
55
|
+
pass
|
|
56
|
+
from snowflake.ml.feature_store.decl.enums import (
|
|
57
|
+
TYPE_ALIASES,
|
|
58
|
+
FeatureAggregationMethod,
|
|
59
|
+
FeatureViewKind,
|
|
60
|
+
FSBaseType,
|
|
61
|
+
OpKind,
|
|
62
|
+
SourceType,
|
|
63
|
+
normalize_type,
|
|
64
|
+
)
|
|
65
|
+
from snowflake.ml.feature_store.decl.errors import (
|
|
66
|
+
DependencyError,
|
|
67
|
+
SpecLoadError,
|
|
68
|
+
StateDriftError,
|
|
69
|
+
ValidationError,
|
|
70
|
+
)
|
|
71
|
+
from snowflake.ml.feature_store.decl.manifest import (
|
|
72
|
+
FSManifest,
|
|
73
|
+
FSTarget,
|
|
74
|
+
FSTemplating,
|
|
75
|
+
InvalidManifestError,
|
|
76
|
+
ManifestConfigurationError,
|
|
77
|
+
ManifestNotFoundError,
|
|
78
|
+
TargetContext,
|
|
79
|
+
)
|
|
80
|
+
from snowflake.ml.feature_store.decl.project_paths import FSProjectPaths
|
|
81
|
+
from snowflake.ml.feature_store.decl.spec_models import (
|
|
82
|
+
UDF,
|
|
83
|
+
Backfill,
|
|
84
|
+
BatchFeatureView,
|
|
85
|
+
BatchSource,
|
|
86
|
+
Entity,
|
|
87
|
+
Feature,
|
|
88
|
+
FeatureGroup,
|
|
89
|
+
FeatureView,
|
|
90
|
+
FeatureViewRef,
|
|
91
|
+
FSColumn,
|
|
92
|
+
RealtimeFeatureView,
|
|
93
|
+
SourceRef,
|
|
94
|
+
SpecBase,
|
|
95
|
+
StorageConfig,
|
|
96
|
+
StreamingFeatureView,
|
|
97
|
+
StreamingSource,
|
|
98
|
+
)
|
|
99
|
+
from snowflake.ml.feature_store.decl.types import (
|
|
100
|
+
AppliedObject,
|
|
101
|
+
AppliedState,
|
|
102
|
+
Plan,
|
|
103
|
+
PlanOp,
|
|
104
|
+
PlanOptions,
|
|
105
|
+
SpecBatch,
|
|
106
|
+
ValidationResult,
|
|
107
|
+
)
|
|
108
|
+
|
|
109
|
+
__all__ = [
|
|
110
|
+
# api.py
|
|
111
|
+
"load_specs",
|
|
112
|
+
"validate_specs",
|
|
113
|
+
"generate_plan",
|
|
114
|
+
"fetch_applied_state",
|
|
115
|
+
"resolve_datasource_columns",
|
|
116
|
+
"load_manifest",
|
|
117
|
+
"discover_project",
|
|
118
|
+
"resolve_target",
|
|
119
|
+
"load_project",
|
|
120
|
+
# enums.py
|
|
121
|
+
"FSBaseType",
|
|
122
|
+
"FeatureViewKind",
|
|
123
|
+
"SourceType",
|
|
124
|
+
"FeatureAggregationMethod",
|
|
125
|
+
"OpKind",
|
|
126
|
+
"TYPE_ALIASES",
|
|
127
|
+
"normalize_type",
|
|
128
|
+
# errors.py
|
|
129
|
+
"SpecLoadError",
|
|
130
|
+
"ValidationError",
|
|
131
|
+
"DependencyError",
|
|
132
|
+
"StateDriftError",
|
|
133
|
+
# manifest.py
|
|
134
|
+
"FSManifest",
|
|
135
|
+
"FSTarget",
|
|
136
|
+
"FSTemplating",
|
|
137
|
+
"TargetContext",
|
|
138
|
+
"ManifestNotFoundError",
|
|
139
|
+
"InvalidManifestError",
|
|
140
|
+
"ManifestConfigurationError",
|
|
141
|
+
# project_paths.py
|
|
142
|
+
"FSProjectPaths",
|
|
143
|
+
# spec_models.py
|
|
144
|
+
"FSColumn",
|
|
145
|
+
"SpecBase",
|
|
146
|
+
"Entity",
|
|
147
|
+
"StreamingSource",
|
|
148
|
+
"BatchSource",
|
|
149
|
+
"SourceRef",
|
|
150
|
+
"UDF",
|
|
151
|
+
"Feature",
|
|
152
|
+
"FeatureView",
|
|
153
|
+
"StreamingFeatureView",
|
|
154
|
+
"BatchFeatureView",
|
|
155
|
+
"RealtimeFeatureView",
|
|
156
|
+
"FeatureViewRef",
|
|
157
|
+
"FeatureGroup",
|
|
158
|
+
"Backfill",
|
|
159
|
+
"StorageConfig",
|
|
160
|
+
# types.py
|
|
161
|
+
"AppliedObject",
|
|
162
|
+
"AppliedState",
|
|
163
|
+
"PlanOp",
|
|
164
|
+
"Plan",
|
|
165
|
+
"ValidationResult",
|
|
166
|
+
"PlanOptions",
|
|
167
|
+
"SpecBatch",
|
|
168
|
+
]
|