Skip to content

Commit 4044414

Browse files
snowflake-provisionerSnowflake Authors
andauthored
Project import generated by Copybara. (#12)
GitOrigin-RevId: c940ae2b6eabf1ea03ae27ac404d5004a4e894cc Co-authored-by: Snowflake Authors <[email protected]>
1 parent 0cd258b commit 4044414

File tree

8 files changed

+25
-14
lines changed

8 files changed

+25
-14
lines changed

ci/conda_recipe/meta.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
package:
77
name: snowflake-ml-python
8-
version: 0.2.4 # this has to be in sync with snowflake/ml/BUILD.bazel and snowflake/ml/version.py
8+
version: 0.3.0 # this has to be in sync with snowflake/ml/BUILD.bazel and snowflake/ml/version.py
99

1010
source:
1111
path: ../../
@@ -40,11 +40,11 @@ requirements:
4040
about:
4141
home: https://github.com/snowflakedb/snowflake-ml-python
4242
license: Apache-2.0
43-
license_family : Apache
43+
license_family: Apache
4444
license_file: ../../LICENSE.txt
4545
summary: Snowflake ML Library
4646
description: |
47-
Snowflake ML client Library is used for interacting with Snowflake to build machine learning solutions.
48-
Functionalities include feature engineering, modeling, model management, deployment, etc
47+
Snowflake ML client Library is used for interacting with Snowflake to build machine learning solutions.
48+
Functionalities include feature engineering, modeling, model management, deployment, etc
4949
dev_url: https://github.com/snowflakedb/snowflake-ml-python
5050
doc_url: https://github.com/snowflakedb/snowflake-ml-python/blob/main/README.md

snowflake/ml/BUILD.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ snowml_wheel(
4646
# versions in the requirements file, we are pinning the versions here.
4747
"scikit-learn==1.2.1",
4848
"xgboost==1.7.3",
49-
"joblib>=1.0.0,<=1.1.1", # All the release versions between 1.0.0 and 1.1.1 are available in SF Conda channel.
49+
"joblib>=1.0.0,<=1.1.1", # All the release versions between 1.0.0 and 1.1.1 are available in SF Conda channel.
5050
],
51-
version = "0.2.4", # this has to be in sync with version.py and ci/conda_recipe/meta.yaml
51+
version = "0.3.0", # this has to be in sync with version.py and ci/conda_recipe/meta.yaml
5252
deps = [
5353
"//snowflake/ml/metrics:metrics_pkg",
5454
"//snowflake/ml/preprocessing:preprocessing_pkg",

snowflake/ml/_internal/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ py_library(
2727
py_test(
2828
name = "file_utils_test",
2929
srcs = ["file_utils_test.py"],
30+
timeout = "short",
3031
deps = [
3132
":file_utils",
3233
],

snowflake/ml/_internal/file_utils.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,11 @@ def zip_file_or_directory_to_stream(
7070
with io.BytesIO() as input_stream:
7171
with zipfile.ZipFile(input_stream, mode="w", compression=zipfile.ZIP_DEFLATED) as zf:
7272

73-
cur_path = os.path.dirname(path)
74-
while os.path.realpath(cur_path) != os.path.realpath(start_path):
75-
zf.writestr(f"{os.path.relpath(cur_path, start_path)}/", "")
76-
cur_path = os.path.dirname(cur_path)
73+
if os.path.realpath(path) != os.path.realpath(start_path):
74+
cur_path = os.path.dirname(path)
75+
while os.path.realpath(cur_path) != os.path.realpath(start_path):
76+
zf.writestr(f"{os.path.relpath(cur_path, start_path)}/", "")
77+
cur_path = os.path.dirname(cur_path)
7778

7879
if os.path.isdir(path):
7980
for dirname, _, files in os.walk(path):

snowflake/ml/_internal/file_utils_test.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,7 @@ def test_zip_file_or_directory_to_stream(self) -> None:
4646
importlib.import_module("snowflake.snowpark.fake_module.p")
4747

4848
sys.path.remove(os.path.abspath(zip_module_filename))
49+
50+
with file_utils.zip_file_or_directory_to_stream(fake_mod_dirpath, fake_mod_dirpath) as input_stream:
51+
with open(zip_module_filename, "wb") as f:
52+
f.write(input_stream.getbuffer())

snowflake/ml/registry/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ py_library(
1111
"//snowflake/ml/_internal/utils:formatting",
1212
"//snowflake/ml/_internal/utils:query_result_checker",
1313
"//snowflake/ml/_internal/utils:uri",
14+
"//snowflake/ml/_internal:file_utils",
1415
"//snowflake/ml/model:_model",
1516
"//snowflake/ml/model:_deployer",
1617
"//snowflake/ml/utils:telemetry",

snowflake/ml/registry/model_registry.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from absl import logging
1313

1414
from snowflake import connector, snowpark
15+
from snowflake.ml._internal import file_utils
1516
from snowflake.ml._internal.utils import formatting, query_result_checker, uri
1617
from snowflake.ml.model import (
1718
_deployer,
@@ -21,7 +22,6 @@
2122
)
2223
from snowflake.ml.registry import _schema
2324
from snowflake.ml.utils import telemetry
24-
from snowflake.snowpark._internal import utils
2525

2626
if TYPE_CHECKING:
2727
import pandas as pd
@@ -998,6 +998,9 @@ def log_model(
998998
output, which could be inferred by calling `infer_signature` method with sample input data.
999999
sample_input_data: Sample of the input data for the model.
10001000
1001+
Raises:
1002+
TypeError: Raised when both signatures and sample_input_data is not presented. Will be captured locally.
1003+
10011004
Returns:
10021005
String of the auto-generate unique model identifier. None if failed.
10031006
"""
@@ -1031,6 +1034,8 @@ def log_model(
10311034
pip_requirements=pip_requirements,
10321035
sample_input=sample_input_data,
10331036
)
1037+
else:
1038+
raise TypeError("Either signature or sample input data should exist for native model packaging.")
10341039
id = self.log_model_path(
10351040
path=tmpdir,
10361041
type="snowflake_native",
@@ -1174,7 +1179,6 @@ def log_model_path(
11741179
Returns:
11751180
String of the auto-generate unique model identifier.
11761181
"""
1177-
11781182
# Copy model from local disk to remote stage.
11791183
fully_qualified_model_stage_name = self._prepare_model_stage(model_name=name, model_version=version)
11801184

@@ -1183,7 +1187,7 @@ def log_model_path(
11831187
if os.path.isfile(path):
11841188
self._session.file.put(path, f"{fully_qualified_model_stage_name}/data")
11851189
elif os.path.isdir(path):
1186-
with utils.zip_file_or_directory_to_stream(path, path, add_init_py=True) as input_stream:
1190+
with file_utils.zip_file_or_directory_to_stream(path, path) as input_stream:
11871191
self._session._conn.upload_stream(
11881192
input_stream=input_stream,
11891193
stage_location=fully_qualified_model_stage_name,

snowflake/ml/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Update this for the versions
22
# Don't change the forth version number from None
3-
VERSION = (0, 2, 4, None) # this has to be in sync with BUILD.bazel and ci/conda_recipe/meta.yaml
3+
VERSION = (0, 3, 0, None) # this has to be in sync with BUILD.bazel and ci/conda_recipe/meta.yaml
44

55

66
def get_version() -> str:

0 commit comments

Comments
 (0)