Skip to content

Commit 1578599

Browse files
snowflake-provisionerSnowflake Authors
authored andcommitted
Project import generated by Copybara. (#48)
Project import generated by Copybara. (#49) GitOrigin-RevId: 0fdc2918b11abd8900c694506e4dc30d1836d332 Co-authored-by: Snowflake Authors <[email protected]>
1 parent 76d191e commit 1578599

File tree

340 files changed

+86419
-1483
lines changed

Some content is hidden

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

340 files changed

+86419
-1483
lines changed

.bazelrc

Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,46 @@
1-
# Make the target platform and the host platform the same
2-
build --platforms //bazel/platforms:snowflake_conda_env --host_platform //bazel/platforms:snowflake_conda_env --repo_env=BUILD_CONDA_ENV=build
3-
test --platforms //bazel/platforms:snowflake_conda_env --host_platform //bazel/platforms:snowflake_conda_env --run_under='//bazel:test_wrapper' --repo_env=BUILD_CONDA_ENV=sf_only
4-
run --platforms //bazel/platforms:snowflake_conda_env --host_platform //bazel/platforms:snowflake_conda_env --repo_env=BUILD_CONDA_ENV=sf_only
5-
cquery --platforms //bazel/platforms:snowflake_conda_env --host_platform //bazel/platforms:snowflake_conda_env --repo_env=BUILD_CONDA_ENV=sf_only
1+
# Common Default
62

7-
run:pre_build --platforms //bazel/platforms:snowflake_conda_env --host_platform //bazel/platforms:snowflake_conda_env --repo_env=BUILD_CONDA_ENV=build
8-
build:typecheck --aspects //bazel/mypy:mypy.bzl%mypy_aspect --output_groups=mypy --platforms //bazel/platforms:extended_conda_env --host_platform //bazel/platforms:extended_conda_env --repo_env=BUILD_CONDA_ENV=extended
3+
# Wrapper to make sure tests are run.
4+
test --run_under='//bazel:test_wrapper'
95

106
# Since integration tests are located in different packages than code under test,
117
# the default instrumentation filter would exclude the code under test. This
128
# makes bazel consider all the source code in our repo for coverage.
139
coverage --instrumentation_filter="-//tests[/:]"
1410

15-
test:extended --platforms //bazel/platforms:extended_conda_env --host_platform //bazel/platforms:extended_conda_env --run_under='//bazel:test_wrapper' --repo_env=BUILD_CONDA_ENV=extended
16-
run:extended --platforms //bazel/platforms:extended_conda_env --host_platform //bazel/platforms:extended_conda_env --repo_env=BUILD_CONDA_ENV=extended
17-
cquery:extended --platforms //bazel/platforms:extended_conda_env --host_platform //bazel/platforms:extended_conda_env --repo_env=BUILD_CONDA_ENV=extended
11+
# Internal definitions
12+
13+
# Make the target platform and the host platform the same
14+
build:_build --platforms //bazel/platforms:snowflake_conda_env --host_platform //bazel/platforms:snowflake_conda_env --repo_env=BAZEL_CONDA_ENV_NAME=build
15+
build:_sf_only --platforms //bazel/platforms:snowflake_conda_env --host_platform //bazel/platforms:snowflake_conda_env --repo_env=BAZEL_CONDA_ENV_NAME=sf_only
16+
build:_extended --platforms //bazel/platforms:extended_conda_env --host_platform //bazel/platforms:extended_conda_env --repo_env=BAZEL_CONDA_ENV_NAME=extended
17+
18+
# Public definitions
19+
20+
# Python environment flag, should use in combination with other configs
21+
22+
build:py3.8 --repo_env=BAZEL_CONDA_PYTHON_VERSION=3.8
23+
build:py3.9 --repo_env=BAZEL_CONDA_PYTHON_VERSION=3.9
24+
build:py3.10 --repo_env=BAZEL_CONDA_PYTHON_VERSION=3.10
25+
26+
# Default
27+
28+
build --config=_build
29+
test --config=_sf_only
30+
run --config=_sf_only
31+
cquery --config=_sf_only
32+
33+
# Config to sync files
34+
run:pre_build --config=_build --config=py3.8
35+
36+
# Config to run type check
37+
build:typecheck --aspects @rules_mypy//:mypy.bzl%mypy_aspect --output_groups=mypy --config=_extended --config=py3.8
38+
39+
# Config to build the doc
40+
build:docs --config=_sf_only --config=py3.8
41+
42+
# Public the extended setting
43+
44+
test:extended --config=_extended
45+
run:extended --config=_extended
46+
cquery:extended --config=_extended

.gitignore

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ dkms.conf
8585
# User-specific stuff
8686
.idea/
8787

88-
8988
# Gradle and Maven with auto-import
9089
# When using Gradle or Maven with auto-import, you should exclude module files,
9190
# since they will be recreated, and may cause churn. Uncomment if using
@@ -332,8 +331,8 @@ coverage.xml
332331
# Scrapy stuff:
333332
.scrapy
334333

335-
# Sphinx documentation
336-
docs/_build/
334+
# Auto-generated API reference
335+
docs/source/api/
337336

338337
# PyBuilder
339338
target/

.pre-commit-config.yaml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
exclude: ^(.*egg.info.*|docs/.*|.*/parameters.py$|docs/.*|.*\.py_template|.*/experimental/.*)
2+
exclude: ^(.*egg.info.*|.*/parameters.py$|.*\.py_template|.*/experimental/.*|docs/source/_themes/.*)
33
minimum_pre_commit_version: 3.4.0
44
repos:
55
- repo: https://github.com/asottile/pyupgrade
@@ -26,6 +26,8 @@ repos:
2626
hooks:
2727
- id: trailing-whitespace
2828
- id: end-of-file-fixer
29+
exclude_types:
30+
- image
2931
exclude: >
3032
(?x)^(
3133
license_header.txt|
@@ -66,12 +68,15 @@ repos:
6668
- id: buildifier
6769
args:
6870
- --warnings=all
71+
files: \.(bzl|bazel|sky)$
6972
# - id: buildifier-lint
7073
# args: *args
7174
- repo: https://github.com/crate-ci/typos # config: _typos.toml
7275
rev: v1.16.10
7376
hooks:
7477
- id: typos
78+
exclude_types:
79+
- image
7580
- repo: https://github.com/lyz-code/yamlfix
7681
rev: 1.13.0
7782
hooks:
@@ -89,3 +94,18 @@ repos:
8994
- id: shellcheck
9095
args:
9196
- --severity=warning
97+
- repo: https://github.com/python-jsonschema/check-jsonschema
98+
rev: 0.26.3
99+
hooks:
100+
- id: check-jsonschema
101+
files: ^requirements.*\.yml$
102+
args:
103+
- --schemafile
104+
- bazel/requirements/requirements.schema.json
105+
- id: check-github-workflows
106+
- repo: https://github.com/pre-commit/pygrep-hooks
107+
rev: v1.10.0
108+
hooks:
109+
- id: python-check-blanket-noqa
110+
- id: python-check-blanket-type-ignore
111+
- id: python-check-mock-methods

CHANGELOG.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,26 @@
11
# Release History
22

3-
## 1.0.8
3+
## 1.0.9
44

55
### Behavior Changes
66

7+
- Model Development: log_loss metric calculation is now distributed.
8+
79
### New Features
810

911
### Bug Fixes
1012

13+
- Model Registry: Fix an issue that building images fails with specific docker setup.
14+
- Model Registry: Fix an issue that unable to embed local ML library when the library is imported by `zipimport`.
15+
- Model Registry: Fix out-of-date doc about `platform` argument in the `deploy` function.
16+
- Model Registry: Fix an issue that unable to deploy a GPU-trained PyTorch model to a platform where GPU is not available.
17+
18+
## 1.0.8 (2023-09-15)
19+
20+
### Bug Fixes
21+
1122
- Model Development: Ordinal encoder can be used with mixed input column types.
23+
- Model Development: Fix an issue when the sklearn default value is `np.nan`.
1224
- Model Registry: Fix an issue that incorrect docker executable is used when building images.
1325
- Model Registry: Fix an issue that specifying `token` argument when using
1426
`snowflake.ml.model.models.huggingface_pipeline.HuggingFacePipelineModel` with `transformers < 4.32.0` is not effective.

WORKSPACE

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,16 @@ aspect_bazel_lib_dependencies()
4747

4848
register_yq_toolchains()
4949

50+
local_repository(
51+
name = "rules_sphinx",
52+
path = "./third_party/rules_sphinx",
53+
)
54+
55+
local_repository(
56+
name = "rules_mypy",
57+
path = "./third_party/rules_mypy",
58+
)
59+
5060
# Below two conda environments (toolchains) are created and they require different
5161
# constraint values. Two platforms defined in bazel/platforms/BUILD provide those
5262
# constraint values. A toolchain matches a platform as long as the platform provides
@@ -63,26 +73,29 @@ load("@SnowML//bazel/environments:fetch_conda_env_config.bzl", "fetch_conda_env_
6373

6474
fetch_conda_env_config(name = "fetch_conda_env_config_repo")
6575

66-
load("@fetch_conda_env_config_repo//:config.bzl", "COMPATIBLE_TARGET", "ENVIRONMENT", "NAME")
76+
load("@fetch_conda_env_config_repo//:config.bzl", "COMPATIBLE_TARGET", "ENVIRONMENT", "NAME", "PYTHON_VERSION")
77+
78+
PYTHON_VERSION_DISPLAY_NAME = "".join(PYTHON_VERSION.split("."))
6779

6880
load_conda(
69-
conda_repo_name = "{}_conda".format(NAME),
81+
conda_repo_name = "{}_conda_{}".format(NAME, PYTHON_VERSION_DISPLAY_NAME),
7082
quiet = True,
7183
)
7284

7385
conda_create(
74-
name = "{}_env".format(NAME),
86+
name = "{}_env_{}".format(NAME, PYTHON_VERSION_DISPLAY_NAME),
7587
timeout = 3600,
7688
clean = False,
77-
conda_repo_name = "{}_conda".format(NAME),
89+
conda_repo_name = "{}_conda_{}".format(NAME, PYTHON_VERSION_DISPLAY_NAME),
7890
coverage_tool = "@//bazel/coverage_tool:coverage_tool.py",
7991
environment = ENVIRONMENT,
92+
python_version = PYTHON_VERSION,
8093
quiet = True,
8194
)
8295

8396
register_toolchain(
84-
name = "{}_env_repo".format(NAME),
85-
env = "{}_env".format(NAME),
97+
name = "{}_env_{}_repo".format(NAME, PYTHON_VERSION_DISPLAY_NAME),
98+
env = "{}_env_{}".format(NAME, PYTHON_VERSION_DISPLAY_NAME),
8699
target_compatible_with = COMPATIBLE_TARGET,
87-
toolchain_name = "py3_toolchain_{}_env".format(NAME),
100+
toolchain_name = "py{}_toolchain_{}_env".format(PYTHON_VERSION_DISPLAY_NAME, NAME),
88101
)

bazel/environments/conda-env-build.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@ channels:
77
- nodefaults
88
dependencies:
99
- absl-py==1.3.0
10-
- conda-libmamba-solver==23.3.0
10+
- conda-libmamba-solver==23.7.0
1111
- inflection==0.5.1
1212
- jsonschema==3.2.0
1313
- lightgbm==3.3.5
1414
- numpy==1.24.3
1515
- packaging==23.0
16-
- python==3.8.13
16+
- pytimeparse==1.1.8
1717
- ruamel.yaml==0.17.21
1818
- scikit-learn==1.3.0
19+
- sphinx==5.0.2
1920
- xgboost==1.7.3

bazel/environments/conda-env-snowflake.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ dependencies:
1212
- boto3==1.24.28
1313
- cachetools==4.2.2
1414
- cloudpickle==2.0.0
15-
- conda-libmamba-solver==23.3.0
15+
- conda-libmamba-solver==23.7.0
1616
- coverage==6.3.2
1717
- cryptography==39.0.1
1818
- flask-cors==3.0.10
@@ -31,7 +31,7 @@ dependencies:
3131
- pandas==1.5.3
3232
- protobuf==3.20.3
3333
- pytest==7.1.2
34-
- python==3.8.13
34+
- pytimeparse==1.1.8
3535
- pytorch==2.0.1
3636
- pyyaml==6.0
3737
- requests==2.29.0
@@ -40,9 +40,11 @@ dependencies:
4040
- scikit-learn==1.3.0
4141
- scipy==1.9.3
4242
- sentencepiece==0.1.99
43-
- snowflake-connector-python==3.1.0
44-
- snowflake-snowpark-python==1.5.1
45-
- sqlparse==0.4.3
43+
- shap==0.42.1
44+
- snowflake-connector-python==3.2.0
45+
- snowflake-snowpark-python==1.6.1
46+
- sphinx==5.0.2
47+
- sqlparse==0.4.4
4648
- tensorflow==2.10.0
4749
- torchdata==0.6.1
4850
- transformers==4.29.2

bazel/environments/conda-env.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ dependencies:
1717
- conda-forge::starlette==0.27.0
1818
- conda-forge::types-PyYAML==6.0.12
1919
- conda-forge::types-cachetools==4.2.2
20-
- conda-libmamba-solver==23.3.0
20+
- conda-libmamba-solver==23.7.0
2121
- coverage==6.3.2
2222
- cryptography==39.0.1
2323
- flask-cors==3.0.10
@@ -36,7 +36,7 @@ dependencies:
3636
- pandas==1.5.3
3737
- protobuf==3.20.3
3838
- pytest==7.1.2
39-
- python==3.8.13
39+
- pytimeparse==1.1.8
4040
- pytorch==2.0.1
4141
- pyyaml==6.0
4242
- requests==2.29.0
@@ -45,9 +45,11 @@ dependencies:
4545
- scikit-learn==1.3.0
4646
- scipy==1.9.3
4747
- sentencepiece==0.1.99
48-
- snowflake-connector-python==3.1.0
49-
- snowflake-snowpark-python==1.5.1
50-
- sqlparse==0.4.3
48+
- shap==0.42.1
49+
- snowflake-connector-python==3.2.0
50+
- snowflake-snowpark-python==1.6.1
51+
- sphinx==5.0.2
52+
- sqlparse==0.4.4
5153
- tensorflow==2.10.0
5254
- torchdata==0.6.1
5355
- transformers==4.29.2

bazel/environments/fetch_conda_env_config.bzl

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
def _fetch_conda_env_config_impl(rctx):
22
# read the particular environment variable we are interested in
3-
config = rctx.os.environ.get("BUILD_CONDA_ENV", "extended").lower()
3+
env_name = rctx.os.environ.get("BAZEL_CONDA_ENV_NAME", "extended").lower()
4+
python_ver = rctx.os.environ.get("BAZEL_CONDA_PYTHON_VERSION", "3.8").lower()
45

56
# necessary to create empty BUILD file for this rule
67
# which will be located somewhere in the Bazel build files
@@ -21,8 +22,8 @@ def _fetch_conda_env_config_impl(rctx):
2122
},
2223
}
2324

24-
if config not in conda_env_map.keys():
25-
fail("Unsupported conda env {} specified. Only {} is supported.".format(config, repr(conda_env_map.keys())))
25+
if env_name not in conda_env_map.keys():
26+
fail("Unsupported conda env {} specified. Only {} is supported.".format(env_name, repr(conda_env_map.keys())))
2627

2728
# create a temporary file called config.bzl to be loaded into WORKSPACE
2829
# passing in any desired information from this rule implementation
@@ -32,10 +33,11 @@ def _fetch_conda_env_config_impl(rctx):
3233
NAME = {}
3334
ENVIRONMENT = {}
3435
COMPATIBLE_TARGET = {}
35-
""".format(repr(config), repr(conda_env_map[config]["environment"]), repr(conda_env_map[config]["compatible_target"])),
36+
PYTHON_VERSION = {}
37+
""".format(repr(env_name), repr(conda_env_map[env_name]["environment"]), repr(conda_env_map[env_name]["compatible_target"]), repr(python_ver)),
3638
)
3739

3840
fetch_conda_env_config = repository_rule(
3941
implementation = _fetch_conda_env_config_impl,
40-
environ = ["BUILD_CONDA_ENV"],
42+
environ = ["BAZEL_CONDA_ENV_NAME", "BAZEL_CONDA_PYTHON_VERSION"],
4143
)

bazel/get_affected_targets.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
set -o pipefail
1919
set -u
20+
set -e
21+
2022
PROG=$0
2123

2224
help() {
@@ -79,6 +81,7 @@ SeedFileContent
7981
"${bazel}" run --config=pre_build :bazel-diff --script_path="${bazel_diff}"
8082

8183
git -C "${workspace_path}" checkout "${pr_revision}" --quiet
84+
trap 'git -C "${workspace_path}" checkout "${current_revision}" --quiet' EXIT
8285

8386
echo "Generating Hashes for Revision '${pr_revision}'"
8487

@@ -109,5 +112,3 @@ EndOfMessage
109112
# -- End of Query Rules Heredoc --
110113

111114
"${bazel}" query --query_file="${filter_query_rules_file}" >"${output_path}"
112-
113-
git -C "${workspace_path}" checkout "${current_revision}" --quiet

0 commit comments

Comments
 (0)