Skip to content

Commit fdbf273

Browse files
sfc-gh-anavalosSnowflake Authors
and
Snowflake Authors
authored
Project import generated by Copybara. (#142)
GitOrigin-RevId: 2a14a570961b96139e5ccdaa4a2372f54f772558 Co-authored-by: Snowflake Authors <[email protected]>
1 parent ae87f58 commit fdbf273

File tree

163 files changed

+4692
-1552
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

163 files changed

+4692
-1552
lines changed

Diff for: .bazelrc

+36-25
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# DO NOT EDIT!
2+
# Generate by running 'bazel run --config=pre_build //:sync_bazelrc'
3+
14
# Common Default
25

36
# Wrapper to make sure tests are run.
@@ -12,12 +15,9 @@ coverage --instrumentation_filter="-//tests[/:]"
1215
# Internal definitions
1316

1417
# Make the target platform and the host platform the same
15-
build:_build --platforms //bazel/platforms:snowflake_conda_env --host_platform //bazel/platforms:snowflake_conda_env --repo_env=BAZEL_CONDA_ENV_NAME=build
16-
build:_sf_only --platforms //bazel/platforms:snowflake_conda_env --host_platform //bazel/platforms:snowflake_conda_env --repo_env=BAZEL_CONDA_ENV_NAME=sf_only
17-
build:_extended --platforms //bazel/platforms:extended_conda_env --host_platform //bazel/platforms:extended_conda_env --repo_env=BAZEL_CONDA_ENV_NAME=extended
18-
build:_extended_oss --platforms //bazel/platforms:extended_conda_env --host_platform //bazel/platforms:extended_conda_env --repo_env=BAZEL_CONDA_ENV_NAME=extended_oss
19-
build:_extended_gpu_oss --platforms //bazel/platforms:extended_conda_gpu_env --host_platform //bazel/platforms:extended_conda_gpu_env --repo_env=BAZEL_CONDA_ENV_NAME=extended_gpu_oss
20-
18+
build:_build --platforms //bazel/platforms:core_conda_env --host_platform //bazel/platforms:core_conda_env --repo_env=BAZEL_CONDA_ENV_NAME=build
19+
build:_core --platforms //bazel/platforms:core_conda_env --host_platform //bazel/platforms:core_conda_env --repo_env=BAZEL_CONDA_ENV_NAME=core
20+
build:_all --platforms //bazel/platforms:all_conda_env --host_platform //bazel/platforms:all_conda_env --repo_env=BAZEL_CONDA_ENV_NAME=all
2121

2222
# Public definitions
2323

@@ -26,33 +26,44 @@ build:_extended_gpu_oss --platforms //bazel/platforms:extended_conda_gpu_env --h
2626
build:py3.9 --repo_env=BAZEL_CONDA_PYTHON_VERSION=3.9
2727
build:py3.10 --repo_env=BAZEL_CONDA_PYTHON_VERSION=3.10
2828
build:py3.11 --repo_env=BAZEL_CONDA_PYTHON_VERSION=3.11
29+
build:py3.12 --repo_env=BAZEL_CONDA_PYTHON_VERSION=3.12
2930

30-
# Default
31-
32-
build --config=_build
33-
test --config=_sf_only
34-
run --config=_sf_only
35-
cquery --config=_sf_only
31+
build:build --config=_build
3632

3733
# Config to sync files
3834
run:pre_build --config=_build --config=py3.9
3935

4036
# Config to run type check
41-
build:typecheck --aspects @rules_mypy//:mypy.bzl%mypy_aspect --output_groups=mypy --config=_extended --config=py3.9
42-
build:typecheck_oss --aspects @rules_mypy//:mypy.bzl%mypy_aspect --output_groups=mypy --config=_extended_oss --config=py3.9
43-
build:typecheck_gpu_oss --aspects @rules_mypy//:mypy.bzl%mypy_aspect --output_groups=mypy --config=_extended_gpu_oss --config=py3.9
37+
build:typecheck --aspects @rules_mypy//:mypy.bzl%mypy_aspect --output_groups=mypy --config=_all --config=py3.9
4438

4539
# Config to build the doc
46-
build:docs --config=_sf_only --config=py3.9
40+
build:docs --config=_all --config=py3.9
4741

4842
# Public the extended setting
4943

50-
test:extended --config=_extended
51-
run:extended --config=_extended
52-
cquery:extended --config=_extended
53-
test:extended_oss --config=_extended_oss
54-
run:extended_oss --config=_extended_oss
55-
cquery:extended_oss --config=_extended_oss
56-
test:extended_gpu_oss --config=_extended_gpu_oss
57-
run:extended_gpu_oss --config=_extended_gpu_oss
58-
cquery:extended_gpu_oss --config=_extended_gpu_oss
44+
cquery:core --config=_core
45+
test:core --config=_core
46+
run:core --config=_core
47+
cquery:all --config=_all
48+
test:all --config=_all
49+
run:all --config=_all
50+
51+
# Below are auto-generated settings, do not modify them directly
52+
53+
build:_keras --platforms //bazel/platforms:keras_conda_env --host_platform //bazel/platforms:keras_conda_env --repo_env=BAZEL_CONDA_ENV_NAME=keras
54+
cquery:keras --config=_keras
55+
build:keras --config=_keras
56+
test:keras --config=_keras
57+
run:keras --config=_keras
58+
59+
build:_ml --platforms //bazel/platforms:ml_conda_env --host_platform //bazel/platforms:ml_conda_env --repo_env=BAZEL_CONDA_ENV_NAME=ml
60+
cquery:ml --config=_ml
61+
build:ml --config=_ml
62+
test:ml --config=_ml
63+
run:ml --config=_ml
64+
65+
build:_torch --platforms //bazel/platforms:torch_conda_env --host_platform //bazel/platforms:torch_conda_env --repo_env=BAZEL_CONDA_ENV_NAME=torch
66+
cquery:torch --config=_torch
67+
build:torch --config=_torch
68+
test:torch --config=_torch
69+
run:torch --config=_torch

Diff for: BUILD.bazel

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
11
load("@rules_java//java:defs.bzl", "java_binary")
22
load("//:packages.bzl", "PACKAGES")
33
load("//bazel:py_rules.bzl", "py_wheel")
4-
load("//bazel/requirements:rules.bzl", "generate_pyproject_file")
4+
load("//bazel/requirements:rules.bzl", "generate_pyproject_file", "sync_bazelrc_file")
55

66
package(default_visibility = ["//visibility:public"])
77

88
exports_files([
9+
".bazelrc",
910
"CHANGELOG.md",
1011
"README.md",
1112
"LICENSE.txt",
12-
"conda-env-extended.yml",
13-
"conda-env-snowflake.yml",
14-
"conda-env.yml",
1513
"mypy.ini",
16-
"requirements.txt",
1714
"requirements.yml",
1815
])
1916

@@ -38,3 +35,10 @@ py_wheel(
3835
pyproject_toml = ":snowml_pyproject",
3936
deps = PACKAGES,
4037
)
38+
39+
sync_bazelrc_file(
40+
name = "sync_bazelrc",
41+
generation_cmd = "bazel run --config=pre_build //:sync_bazelrc",
42+
root_path = "",
43+
target = ".bazelrc",
44+
)

Diff for: CHANGELOG.md

+36-5
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,61 @@
11
# Release History
22

3-
## 1.7.4
3+
## 1.7.5
4+
5+
- Support Python 3.12.
6+
- Explainability: Support native and snowml sklearn pipeline
7+
8+
### Bug Fixes
9+
10+
- Registry: Fixed a compatibility issue when using `snowflake-ml-python` 1.7.0 or greater to save a `tensorflow.keras`
11+
model with `keras` 2.x, if `relax_version` is set or default to True, and newer version of `snowflake-ml-python`
12+
is available in Snowflake Anaconda Channel, model could not be run in Snowflake. If you have such model, you could
13+
use the latest version of `snowflake-ml-python` and call `ModelVersion.load` to load it back, and re-log it.
14+
Alternatively, you can prevent this issue by setting `relax_version=False` when saving the model.
15+
- Registry: Removed the validation that disallows data that does not have non-null values being passed to
16+
`ModelVersion.run`.
17+
- ML Job (PrPr): No longer require CREATE STAGE privilege if `stage_name` points to an existing stage
18+
- ML Job (PrPr): Fixed a bug causing some payload source and entrypoint path
19+
combinations to be erroneously rejected with
20+
`ValueError(f"{self.entrypoint} must be a subpath of {self.source}")`
21+
- ML Job (PrPr): Fixed a bug in Ray cluster startup config which caused certain Runtime APIs to fail
22+
23+
### Behavior Change
24+
25+
### New Features
26+
27+
- Registry: Added support for handling Hugging Face model configurations with auto-mapping functionality.
28+
- Registry: Added support for `keras` 3.x model with `tensorflow` and `pytorch` backend
29+
- ML Job (PrPr): Support any serializable (pickleable) argument for `@remote` decorated functions
30+
31+
## 1.7.4 (01-28-2025)
432

533
- FileSet: The `snowflake.ml.fileset.FileSet` has been deprecated and will be removed in a future version.
634
Use [snowflake.ml.dataset.Dataset](https://docs.snowflake.com/en/developer-guide/snowflake-ml/dataset) and
735
[snowflake.ml.data.DataConnector](https://docs.snowflake.com/en/developer-guide/snowpark-ml/reference/latest/api/data/snowflake.ml.data.data_connector.DataConnector)
836
instead.
37+
- Registry: `ModelVersion.run` on a service would require redeploying the service once account opts into nested function.
938

1039
### Bug Fixes
1140

1241
- Registry: Fixed an issue that the hugging face pipeline is loaded using incorrect dtype.
1342
- Registry: Fixed an issue that only 1 row is used when infer the model signature in the modeling model.
1443

15-
### Behavior Changes
16-
17-
- Registry: `ModelVersion.run` on a service would require redeploying the service once account opts into nested function.
18-
1944
### New Features
2045

2146
- Add new `snowflake.ml.jobs` preview API for running headless workloads on SPCS using
2247
[Container Runtime for ML](https://docs.snowflake.com/en/developer-guide/snowflake-ml/container-runtime-ml)
2348
- Added `guardrails` option to Cortex `complete` function, enabling
2449
[Cortex Guard](https://docs.snowflake.com/en/user-guide/snowflake-cortex/llm-functions#cortex-guard) support
50+
- Model Monitoring: Expose Model Monitoring Python API by default.
2551

2652
## 1.7.3 (2025-01-08)
2753

2854
- Added lowercase versions of Cortex functions, added deprecation warning to Capitalized versions.
2955
- Bumped the requirements of `fsspec` and `s3fs` to `>=2024.6.1,<2026`
3056
- Bumped the requirement of `mlflow` to `>=2.16.0, <3`
3157
- Registry: Support 500+ features for model registry
58+
- Feature Store: Add support for `cluster_by` for feature views.
3259

3360
### Bug Fixes
3461

@@ -146,6 +173,10 @@ class ExamplePipelineModel(custom_model.CustomModel):
146173
- Data Connector: Add the option of passing a `None` sized batch to `to_torch_dataset` for better
147174
interoperability with PyTorch DataLoader.
148175
- Model Registry: Support [pandas.CategoricalDtype](https://pandas.pydata.org/docs/reference/api/pandas.CategoricalDtype.html#pandas-categoricaldtype)
176+
- Limitations:
177+
- The native categorical data handling handling by XGBoost using `enable_categorical=True` is not supported.
178+
Instead please use [`sklearn.pipeline`](https://scikit-learn.org/stable/modules/generated/sklearn.pipeline.Pipeline.html)
179+
to preprocess the categorical datatype and log the pipeline with the XGBoost model.
149180
- Registry: It is now possible to pass `signatures` and `sample_input_data` at the same time to capture background
150181
data from explainablity and data lineage.
151182

Diff for: CONTRIBUTING.md

+78-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ Note: You may need to configure your editor to run this on save.
4646
To build the package, run:
4747

4848
```shell
49-
> bazel build //:wheel
49+
> bazel build --config=build //:wheel
5050
```
5151

5252
`bazel` can be run from anywhere under the monorepo and it can accept absolute path or a relative path. For example,
@@ -58,7 +58,7 @@ snowml> bazel build :wheel
5858
You can build an entire sub-tree as:
5959

6060
```sh
61-
> bazel build //snowflake/...
61+
> bazel build --config=build //snowflake/...
6262
```
6363

6464
### Notes when you add new target in a `BUILD.bazel` file
@@ -302,6 +302,82 @@ Example:
302302
- build_essential
303303
```
304304
305+
### Using optional dependencies
306+
307+
By default, tests are running in an environment without any optional dependencies (dependencies with
308+
`requirements_extra_tags` set). This is to reduce the number of the packages in the environments to make it less likely
309+
to conflict with each other. To use optional dependencies in tests or binary, you need to specify
310+
`optional_dependencies` in your `py_test` or `py_binary` target to include the `requirements_extra_tags` of the
311+
dependencies. For example,
312+
313+
```starlark
314+
py_test(
315+
name = "keras_torch_test",
316+
srcs = ["keras_test.py"],
317+
env = {
318+
"KERAS_BACKEND": "torch",
319+
"PYTORCH_ENABLE_MPS_FALLBACK": 1,
320+
},
321+
main = "keras_test.py",
322+
optional_dependencies = ["keras"],
323+
deps = [
324+
"//snowflake/ml/model:model_signature",
325+
"//snowflake/ml/model/_packager:model_packager",
326+
"//snowflake/ml/model/_signatures:numpy_handler",
327+
"//snowflake/ml/model/_signatures:utils",
328+
],
329+
)
330+
```
331+
332+
If you added a new tag in `requirements_extra_tags`, you need to update `bazel/platforms/optional_dependency_groups.bzl`
333+
to either create a new group or add your tag into existing group. Every group here will create a test environment with
334+
corresponding optional dependencies installed to run the tests or binaries. Here are guidelines:
335+
336+
1. If there are tests needs multiple tags, there should be at least 1 group that has these tags.
337+
1. Tags in the same group should not have conflicting packages.
338+
1. Ideally, avoid too many groups and keep test numbers balanced across groups.
339+
340+
If you add a new group, please run the, following command to update the bazelrc file.
341+
342+
```sh
343+
bazel run --config=pre_build //:sync_bazelrc
344+
```
345+
346+
### Checking Package Latest Versions
347+
348+
The `bazel/requirements/update_version_requirements.py` script helps you check the latest available versions of
349+
Python packages from both PyPI and Snowflake Conda repositories against your current requirements.
350+
351+
#### Usage
352+
353+
Run the script in dry-run mode to safely check latest versions without modifying files:
354+
355+
```bash
356+
bazel run //bazel/requirements:update_version_requirements -- requirements.yml --dry-run
357+
```
358+
359+
This will scan `requirements.yml` and show the latest version of packages and the suggest changes:
360+
361+
```sh
362+
INFO: [DRY-RUN] PyPI/Conda package 'scikit-learn' latest PYPI version 1.6.1: '>=1.4,<1.6' -> '>=1.4,<2'
363+
INFO: [DRY-RUN] PyPI/Conda package 'scikit-learn' latest Conda version 1.5.2: '>=1.4,<1.6' -> '>=1.4,<2'
364+
```
365+
366+
Each line shows:
367+
368+
+ Package availbility (PyPI only, Conda only, or PyPI/Conda)
369+
+ Package name (e.g., 'scikit-learn')
370+
+ The package source (PyPI or Conda)
371+
+ Latest version available in that source repo (e.g., '1.6.1')
372+
+ Current version constraints in your requirements.yml (e.g., '>=1.4,<1.6')
373+
+ Suggested version constraints ('>=1.4,<2')
374+
375+
If you want to apply all the suggested changes, run the following command to update the `requirements.yml` file
376+
377+
```sh
378+
bazel run //bazel/requirements:update_version_requirements -- requirements.yml
379+
```
380+
305381
## Unit Testing
306382

307383
Write Python `unittest` style unit tests. Pytest is allowed, but not recommended.

Diff for: README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ If you don't have a Snowflake account yet, you can [sign up for a 30-day free tr
5353
Follow the [installation instructions](https://docs.snowflake.com/en/developer-guide/snowpark-ml/index#installing-snowpark-ml)
5454
in the Snowflake documentation.
5555

56-
Python versions 3.9 to 3.11 are supported. You can use [miniconda](https://docs.conda.io/en/latest/miniconda.html) or
56+
Python versions 3.9 to 3.12 are supported. You can use [miniconda](https://docs.conda.io/en/latest/miniconda.html) or
5757
[anaconda](https://www.anaconda.com/) to create a Conda environment (recommended),
5858
or [virtualenv](https://docs.python.org/3/tutorial/venv.html) to create a virtual environment.
5959

Diff for: bazel/environments/BUILD.bazel

100644100755
+5-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
exports_files([
2-
"conda-env-snowflake.yml",
3-
"conda-env-build.yml",
4-
"conda-env.yml",
5-
"conda-gpu-env.yml",
6-
"conda-env-build-test.yml",
7-
])
1+
exports_files(glob([
2+
"conda-env-*.yml",
3+
"requirements_*.txt",
4+
"conda-optional-dependency-*.yml",
5+
]))

0 commit comments

Comments
 (0)