Skip to content

Commit

Permalink
Project import generated by Copybara. (#90)
Browse files Browse the repository at this point in the history
GitOrigin-RevId: c12bb2459ddbff1633abda8352a2f126ee767eba

Co-authored-by: Snowflake Authors <[email protected]>
  • Loading branch information
sfc-gh-anavalos and Snowflake Authors authored Feb 26, 2024
1 parent ef56e3f commit de45707
Show file tree
Hide file tree
Showing 56 changed files with 743 additions and 200 deletions.
1 change: 1 addition & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ build:_extended_gpu_oss --platforms //bazel/platforms:extended_conda_gpu_env --h
build:py3.8 --repo_env=BAZEL_CONDA_PYTHON_VERSION=3.8
build:py3.9 --repo_env=BAZEL_CONDA_PYTHON_VERSION=3.9
build:py3.10 --repo_env=BAZEL_CONDA_PYTHON_VERSION=3.10
build:py3.11 --repo_env=BAZEL_CONDA_PYTHON_VERSION=3.11

# Default

Expand Down
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
# Release History

## 1.2.3

### Bug Fixes

- Registry: Now when providing Decimal Type column to a DOUBLE or FLOAT feature will not error out but auto cast with
warnings.
- Registry: Improve the error message when specifying currently unsupported `pip_requirements` argument.
- Model Development: Fix precision_recall_fscore_support incorrect results when `average="samples"`.
- Model Registry: Fix an issue that leads to description, metrics or tags are not correctly returned in newly created
Model Registry (PrPr) due to Snowflake BCR [2024_01](
https://docs.snowflake.com/en/release-notes/bcr-bundles/2024_01/bcr-1483)

### Behavior Changes

- Feature Store: `FeatureStore.suspend_feature_view` and `FeatureStore.resume_feature_view` doesn't mutate input feature
view argument any more. The updated status only reflected in the returned feature view object.

### New Features

- Model Development: support `score_samples` method for all the classes, including Pipeline,
GridSearchCV, RandomizedSearchCV, PCA, IsolationForest, ...
- Registry: Support deleting a version of a model.

## 1.2.2

### Bug Fixes
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ If you don't have a Snowflake account yet, you can [sign up for a 30-day free tr
Follow the [installation instructions](https://docs.snowflake.com/en/developer-guide/snowpark-ml/index#installing-snowpark-ml)
in the Snowflake documentation.

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

Expand Down
4 changes: 2 additions & 2 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive", "http_jar")

http_jar(
name = "bazel_diff",
sha256 = "9c4546623a8b9444c06370165ea79a897fcb9881573b18fa5c9ee5c8ba0867e2",
sha256 = "eca2d221f5c3ec9545c841ed62d319bbb59e447a1ceade563bc8f8e1b9186a34",
urls = [
"https://github.com/Tinder/bazel-diff/releases/download/4.3.0/bazel-diff_deploy.jar",
"https://github.com/Tinder/bazel-diff/releases/download/5.0.1/bazel-diff_deploy.jar",
],
)

Expand Down
26 changes: 11 additions & 15 deletions bazel/get_affected_targets.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,38 +69,34 @@ trap 'rm -rf "${working_dir}"' EXIT
starting_hashes_json="${working_dir}/starting_hashes.json"
final_hashes_json="${working_dir}/final_hashes.json"
impacted_targets_path="${working_dir}/impacted_targets.txt"
bazel_diff="${working_dir}/bazel_diff"
seed_file="${working_dir}/bazel_diff_seed"
ci_hash_file="${working_dir}/ci_scripts_hash"

cat <<SeedFileContent >"${seed_file}"
${ci_hash_file}
${workspace_path}/requirements.yml
SeedFileContent

"${bazel}" run --config=pre_build :bazel-diff --script_path="${bazel_diff}"
ci_hash_file_pr="${working_dir}/ci_hash_file_pr"
ci_hash_file_base="${working_dir}/ci_hash_file_base"

git -C "${workspace_path}" checkout "${pr_revision}" --quiet
trap 'git -C "${workspace_path}" checkout "${current_revision}" --quiet' EXIT

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

git ls-files -s "${workspace_path}/ci" | git hash-object --stdin >"${ci_hash_file}"
git ls-files -s "${workspace_path}/ci" "${workspace_path}/bazel" | git hash-object --stdin >"${ci_hash_file_pr}"

"${bazel_diff}" generate-hashes -w "${workspace_path}" -b "${bazel}" -s "${seed_file}" "${final_hashes_json}"
"${bazel}" run --config=pre_build :bazel-diff -- generate-hashes -w "${workspace_path}" -b "${bazel}" "${final_hashes_json}"

MERGE_BASE_MAIN=$(git merge-base "${pr_revision}" main)
git -C "${workspace_path}" checkout "${MERGE_BASE_MAIN}" --quiet

echo "Generating Hashes for merge base ${MERGE_BASE_MAIN}"

git ls-files -s "${workspace_path}/ci" | git hash-object --stdin >"${ci_hash_file}"
git ls-files -s "${workspace_path}/ci" "${workspace_path}/bazel" | git hash-object --stdin >"${ci_hash_file_base}"

$"${bazel_diff}" generate-hashes -w "${workspace_path}" -b "${bazel}" -s "${seed_file}" "${starting_hashes_json}"
"${bazel}" run --config=pre_build :bazel-diff -- generate-hashes -w "${workspace_path}" -b "${bazel}" "${starting_hashes_json}"

git -C "${workspace_path}" checkout "${pr_revision}" --quiet
echo "Determining Impacted Targets and output to ${output_path}"
$"${bazel_diff}" get-impacted-targets -sh "${starting_hashes_json}" -fh "${final_hashes_json}" -o "${impacted_targets_path}"
"${bazel}" run --config=pre_build :bazel-diff -- get-impacted-targets -sh "${starting_hashes_json}" -fh "${final_hashes_json}" -o "${impacted_targets_path}"

if ! cmp -s "$ci_hash_file_pr" "$ci_hash_file_base"; then
echo '//...' >> "${impacted_targets_path}"
fi

filter_query_rules_file="${working_dir}/filter_query_rules"

Expand Down
2 changes: 1 addition & 1 deletion bazel/requirements/templates/meta.tpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ requirements:
- python
- bazel >=6.0.0
run:
- python>=3.8,<3.11
- python>=3.8,<3.12
run_constrained:
- pytorch<2.1.0 # [win]

Expand Down
3 changes: 2 additions & 1 deletion bazel/requirements/templates/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@ classifiers = [
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Topic :: Database",
"Topic :: Software Development",
"Topic :: Software Development :: Libraries",
"Topic :: Software Development :: Libraries :: Application Frameworks",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Scientific/Engineering :: Information Analysis"
]
requires-python = ">=3.8, <4"
requires-python = ">=3.8, <3.12"
dynamic = ["version", "readme"]

[project.urls]
Expand Down
106 changes: 64 additions & 42 deletions ci/build_and_run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ WITH_SNOWPARK=false
MODE="continuous_run"
PYTHON_VERSION=3.8
PYTHON_JENKINS_ENABLE="/opt/rh/rh-python38/enable"
PYTHON_ENABLE_SCRIPT="bin/activate"
SNOWML_DIR="snowml"
SNOWPARK_DIR="snowpark-python"
IS_NT=false
Expand Down Expand Up @@ -96,21 +97,6 @@ while (($#)); do
shift
done

case ${PYTHON_VERSION} in
3.8)
PYTHON_EXECUTABLE="python3.8"
PYTHON_JENKINS_ENABLE="/opt/rh/rh-python38/enable"
;;
3.9)
PYTHON_EXECUTABLE="python3.9"
PYTHON_JENKINS_ENABLE="/opt/rh/rh-python39/enable"
;;
3.10)
PYTHON_EXECUTABLE="python3.10"
PYTHON_JENKINS_ENABLE="/opt/rh/rh-python310/enable"
;;
esac

echo "Running build_and_run_tests with PYTHON_VERSION ${PYTHON_VERSION}"

EXT=""
Expand Down Expand Up @@ -148,9 +134,53 @@ case "${PLATFORM}_${ARCH}" in
;;
esac

# Verify that the requested python version exists
# TODO(SNOW-845592): ideally we should download python from conda if it's not present. Currently we just fail.
if [ "${ENV}" = "pip" ]; then
if [ ${IS_NT} = true ]; then
EXT=".exe"
PYTHON_ENABLE_SCRIPT="Scripts/activate"
BAZEL_ADDITIONAL_BUILD_FLAGS+=(--nobuild_python_zip)
BAZEL_ADDITIONAL_BUILD_FLAGS+=(--enable_runfiles)
BAZEL_ADDITIONAL_BUILD_FLAGS+=(--action_env="USERPROFILE=${USERPROFILE}")
BAZEL_ADDITIONAL_BUILD_FLAGS+=(--host_action_env="USERPROFILE=${USERPROFILE}")
BAZEL_ADDITIONAL_STARTUP_FLAGS+=(--output_user_root=C:/broot)
fi

case ${PYTHON_VERSION} in
3.8)
if [ ${IS_NT} = true ]; then
PYTHON_EXECUTABLE="py -3.8"
else
PYTHON_EXECUTABLE="python3.8"
fi
PYTHON_JENKINS_ENABLE="/opt/rh/rh-python38/enable"
;;
3.9)
if [ ${IS_NT} = true ]; then
PYTHON_EXECUTABLE="py -3.9"
else
PYTHON_EXECUTABLE="python3.9"
fi
PYTHON_JENKINS_ENABLE="/opt/rh/rh-python39/enable"
;;
3.10)
if [ ${IS_NT} = true ]; then
PYTHON_EXECUTABLE="py -3.10"
else
PYTHON_EXECUTABLE="python3.10"
fi
PYTHON_JENKINS_ENABLE="/opt/rh/rh-python310/enable"
;;
3.11)
if [ ${IS_NT} = true ]; then
PYTHON_EXECUTABLE="py -3.11"
else
PYTHON_EXECUTABLE="python3.11"
fi
PYTHON_JENKINS_ENABLE="/opt/rh/rh-python311/enable"
;;
esac

# TODO(SNOW-901629): Use native python provided in the node once SNOW-1046060 resolved
if [[ "${ENV}" = "pip" && ${IS_NT} = false ]]; then
set +eu
# shellcheck source=/dev/null
source ${PYTHON_JENKINS_ENABLE}
Expand All @@ -163,13 +193,6 @@ if [ "${ENV}" = "pip" ]; then
set -eu
fi

if [ ${IS_NT} = true ]; then
EXT=".exe"
BAZEL_ADDITIONAL_BUILD_FLAGS+=(--nobuild_python_zip)
BAZEL_ADDITIONAL_BUILD_FLAGS+=(--enable_runfiles)
BAZEL_ADDITIONAL_STARTUP_FLAGS+=(--output_user_root=D:/broot)
fi

cd "${WORKSPACE}"

# Check and download yq if not presented.
Expand Down Expand Up @@ -210,12 +233,7 @@ pushd "${TEMP_TEST_DIR}"
rsync -av --exclude-from "${EXCLUDE_TESTS}" "../${SNOWML_DIR}/tests" .
popd

# Bazel on windows is consuming a lot of memory, let's clean it before proceed to avoid OOM.
if [ ${IS_NT} = true ]; then
"${BAZEL}" "${BAZEL_ADDITIONAL_STARTUP_FLAGS[@]+"${BAZEL_ADDITIONAL_STARTUP_FLAGS[@]}"}" clean --expunge
"${BAZEL}" "${BAZEL_ADDITIONAL_STARTUP_FLAGS[@]+"${BAZEL_ADDITIONAL_STARTUP_FLAGS[@]}"}" shutdown
fi

"${BAZEL}" "${BAZEL_ADDITIONAL_STARTUP_FLAGS[@]+"${BAZEL_ADDITIONAL_STARTUP_FLAGS[@]}"}" clean --expunge
popd

# Build snowml package
Expand All @@ -228,10 +246,12 @@ if [ "${ENV}" = "pip" ]; then
pushd ${SNOWPARK_DIR}
rm -rf venv
${PYTHON_EXECUTABLE} -m venv venv
source venv/bin/activate
${PYTHON_EXECUTABLE} -m pip install -U pip setuptools wheel
# shellcheck disable=SC1090
source "venv/${PYTHON_ENABLE_SCRIPT}"
python --version
python -m pip install -U pip setuptools wheel
echo "Building snowpark wheel from main:$(git rev-parse HEAD)."
pip wheel . --no-deps
python -m pip wheel . --no-deps
cp "$(find . -maxdepth 1 -iname 'snowflake_snowpark_python-*.whl')" "${WORKSPACE}"
deactivate
popd
Expand All @@ -240,7 +260,7 @@ if [ "${ENV}" = "pip" ]; then
# Build SnowML
pushd ${SNOWML_DIR}
"${BAZEL}" "${BAZEL_ADDITIONAL_STARTUP_FLAGS[@]+"${BAZEL_ADDITIONAL_STARTUP_FLAGS[@]}"}" build "${BAZEL_ADDITIONAL_BUILD_FLAGS[@]+"${BAZEL_ADDITIONAL_BUILD_FLAGS[@]}"}" //:wheel
cp "$(${BAZEL} info bazel-bin)/dist/snowflake_ml_python-${VERSION}-py3-none-any.whl" "${WORKSPACE}"
cp "$("${BAZEL}" "${BAZEL_ADDITIONAL_STARTUP_FLAGS[@]+"${BAZEL_ADDITIONAL_STARTUP_FLAGS[@]}"}" info bazel-bin)/dist/snowflake_ml_python-${VERSION}-py3-none-any.whl" "${WORKSPACE}"
popd
else
# Clean conda cache
Expand Down Expand Up @@ -284,21 +304,23 @@ if [ "${ENV}" = "pip" ]; then

# Create testing env
${PYTHON_EXECUTABLE} -m venv testenv
source testenv/bin/activate
# shellcheck disable=SC1090
source "testenv/${PYTHON_ENABLE_SCRIPT}"
# Install all of the packages in single line,
# otherwise it will fail in dependency resolution.
${PYTHON_EXECUTABLE} -m pip install --upgrade pip
${PYTHON_EXECUTABLE} -m pip list
${PYTHON_EXECUTABLE} -m pip install "snowflake_ml_python-${VERSION}-py3-none-any.whl[all]" "pytest-xdist[psutil]==2.5.0" -r "${WORKSPACE}/${SNOWML_DIR}/requirements.txt" --no-cache-dir --force-reinstall
python --version
python -m pip install --upgrade pip
python -m pip list
python -m pip install "snowflake_ml_python-${VERSION}-py3-none-any.whl[all]" "pytest-xdist[psutil]==2.5.0" -r "${WORKSPACE}/${SNOWML_DIR}/requirements.txt" --no-cache-dir --force-reinstall
if [ "${WITH_SNOWPARK}" = true ]; then
cp "$(find "${WORKSPACE}" -maxdepth 1 -iname 'snowflake_snowpark_python-*.whl')" "${TEMP_TEST_DIR}"
${PYTHON_EXECUTABLE} -m pip install "$(find . -maxdepth 1 -iname 'snowflake_snowpark_python-*.whl')" --no-deps --force-reinstall
python -m pip install "$(find . -maxdepth 1 -iname 'snowflake_snowpark_python-*.whl')" --no-deps --force-reinstall
fi
${PYTHON_EXECUTABLE} -m pip list
python -m pip list

# Run the tests
set +e
TEST_SRCDIR="${TEMP_TEST_DIR}" ${PYTHON_EXECUTABLE} -m pytest "${COMMON_PYTEST_FLAG[@]}" -m "not pip_incompatible" tests/integ/
TEST_SRCDIR="${TEMP_TEST_DIR}" python -m pytest "${COMMON_PYTEST_FLAG[@]}" -m "not pip_incompatible" tests/integ/
TEST_RETCODE=$?
set -e
else
Expand Down
2 changes: 1 addition & 1 deletion ci/conda_recipe/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Conda's guide on building a conda package from a wheel:
To invoke conda build:

```sh
conda build --prefix-length=0 --python=[3.8|3.9|3.10] ci/conda_recipe
conda build --prefix-length=0 --python=[3.8|3.9|3.10|3.11] ci/conda_recipe
```

- `--prefix-length=0`: prevent the conda build environment from being created in
Expand Down
1 change: 1 addition & 0 deletions ci/conda_recipe/conda_build_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ python:
- 3.8
- 3.9
- 3.10
- 3.11
6 changes: 3 additions & 3 deletions ci/conda_recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ build:
noarch: python
package:
name: snowflake-ml-python
version: 1.2.2
version: 1.2.3
requirements:
build:
- python
Expand All @@ -26,7 +26,7 @@ requirements:
- absl-py>=0.15,<2
- aiohttp!=4.0.0a0, !=4.0.0a1
- anyio>=3.5.0,<4
- cachetools>=3.1.1,<5
- cachetools>=3.1.1,<6
- cloudpickle>=2.0.0
- fsspec>=2022.11,<2024
- importlib_resources>=5.1.4, <6
Expand All @@ -46,7 +46,7 @@ requirements:
- sqlparse>=0.4,<1
- typing-extensions>=4.1.0,<5
- xgboost>=1.7.3,<2
- python>=3.8,<3.11
- python>=3.8,<3.12
run_constrained:
- lightgbm==3.3.5
- mlflow>=2.1.0,<2.4
Expand Down
3 changes: 3 additions & 0 deletions codegen/sklearn_wrapper_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,7 @@ def __init__(self, module_name: str, class_object: Tuple[str, type]) -> None:
self.fit_predict_docstring = ""
self.fit_transform_docstring = ""
self.predict_proba_docstring = ""
self.score_samples_docstring = ""
self.score_docstring = ""
self.predict_log_proba_docstring = ""
self.decision_function_docstring = ""
Expand Down Expand Up @@ -728,6 +729,7 @@ def _populate_function_doc_fields(self) -> None:
"transform",
"score",
"kneighbors",
"score_samples",
]
_CLASS_FUNC = {name: func for name, func in inspect.getmembers(self.class_object[1])}
for _each_method in _METHODS:
Expand Down Expand Up @@ -757,6 +759,7 @@ def _populate_function_doc_fields(self) -> None:
self.predict_docstring = self.estimator_function_docstring["predict"]
self.fit_predict_docstring = self.estimator_function_docstring["fit_predict"]
self.predict_proba_docstring = self.estimator_function_docstring["predict_proba"]
self.score_samples_docstring = self.estimator_function_docstring["score_samples"]
self.predict_log_proba_docstring = self.estimator_function_docstring["predict_log_proba"]
self.decision_function_docstring = self.estimator_function_docstring["decision_function"]
self.score_docstring = self.estimator_function_docstring["score"]
Expand Down
Loading

0 comments on commit de45707

Please sign in to comment.