Skip to content

Commit

Permalink
chore: Unbreak Python 3.12 unit tests
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 622300054
  • Loading branch information
happy-qiao authored and Copybara-Service committed Apr 5, 2024
1 parent c881998 commit add2f92
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 11 deletions.
1 change: 1 addition & 0 deletions noxfile.py
Expand Up @@ -180,6 +180,7 @@ def default(session):
"--cov-config=.coveragerc",
"--cov-report=",
"--cov-fail-under=0",
"--ignore=tests/unit/vertex_ray",
os.path.join("tests", "unit"),
*session.posargs,
)
Expand Down
38 changes: 27 additions & 11 deletions setup.py
Expand Up @@ -46,7 +46,9 @@
if package.startswith("google.cloud.aiplatform.preview.vertex_ray")
]

tensorboard_extra_require = ["tensorflow >=2.3.0, <2.15.0"]
# TODO(b/333098166, b/312527978): Add python_version>3.11 when tensorflow>2.16.1
# works for tensorboard.
tensorboard_extra_require = ["tensorflow >=2.3.0, <2.15.0; python_version<='3.11'"]
metadata_extra_require = ["pandas >= 1.0.0", "numpy>=1.15.0"]
xai_extra_require = ["tensorflow >=2.3.0, <3.0.0dev"]
lit_extra_require = [
Expand All @@ -70,7 +72,8 @@
]
datasets_extra_require = [
"pyarrow >= 3.0.0, < 8.0dev; python_version<'3.11'",
"pyarrow >= 10.0.1; python_version>='3.11'",
"pyarrow >= 10.0.1; python_version=='3.11'",
"pyarrow >= 14.0.0; python_version>='3.12'",
]

vizier_extra_require = [
Expand All @@ -87,7 +90,10 @@

endpoint_extra_require = ["requests >= 2.28.1"]

private_endpoints_extra_require = ["urllib3 >=1.21.1, <1.27", "requests >= 2.28.1"]
private_endpoints_extra_require = [
"urllib3 >=1.21.1, <1.27",
"requests >= 2.28.1",
]

autologging_extra_require = ["mlflow>=1.27.0,<=2.1.1"]

Expand All @@ -98,9 +104,12 @@

ray_extra_require = [
# Cluster only supports 2.4.0 and 2.9.3
"ray[default] >= 2.4, <= 2.9.3,!= 2.5.*,!= 2.6.*,!= 2.7.*,!= 2.8.*,!=2.9.0,!=2.9.1,!=2.9.2; python_version<'3.11'",
(
"ray[default] >= 2.4, <= 2.9.3,!= 2.5.*,!= 2.6.*,!= 2.7.*,!="
" 2.8.*,!=2.9.0,!=2.9.1,!=2.9.2; python_version<'3.11'"
),
# Ray Data v2.4 in Python 3.11 is broken, but got fixed in Ray v2.5.
"ray[default] >= 2.5, <= 2.9.3; python_version>='3.11'",
"ray[default] >= 2.5, <= 2.9.3; python_version=='3.11'",
"google-cloud-bigquery-storage",
"google-cloud-bigquery",
"pandas >= 1.0.0, < 2.2.0",
Expand All @@ -119,7 +128,10 @@
ray_testing_extra_require = ray_extra_require + [
"pytest-xdist",
# ray train extras required for prediction tests
"ray[train] >= 2.4, <= 2.9.3,!= 2.5.*,!= 2.6.*,!= 2.7.*,!= 2.8.*,!=2.9.0,!=2.9.1,!=2.9.2",
(
"ray[train] >= 2.4, <= 2.9.3,!= 2.5.*,!= 2.6.*,!= 2.7.*,!="
" 2.8.*,!=2.9.0,!=2.9.1,!=2.9.2"
),
# Framework version constraints copied from testing_extra_require
"scikit-learn",
"tensorflow",
Expand Down Expand Up @@ -167,14 +179,15 @@
"pytest-xdist",
"scikit-learn",
# Lazy import requires > 2.12.0
"tensorflow == 2.13.0",
"tensorflow == 2.13.0; python_version<='3.11'",
"tensorflow == 2.16.1; python_version>'3.11'",
# TODO(jayceeli) torch 2.1.0 has conflict with pyfakefs, will check if
# future versions fix this issue
"torch >= 2.0.0, < 2.1.0",
"xgboost",
"xgboost_ray",
"torch >= 2.0.0, < 2.1.0; python_version<='3.11'",
"torch >= 2.2.0; python_version>'3.11'",
"requests-toolbelt < 1.0.0",
"immutabledict",
"xgboost",
]
)

Expand All @@ -200,7 +213,10 @@
platforms="Posix; MacOS X; Windows",
include_package_data=True,
install_requires=(
"google-api-core[grpc] >= 1.34.1, <3.0.0dev,!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*",
(
"google-api-core[grpc] >= 1.34.1,"
" <3.0.0dev,!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*"
),
"google-auth >= 2.14.1, <3.0.0dev",
"proto-plus >= 1.22.0, <2.0.0dev",
"protobuf>=3.19.5,<5.0.0dev,!=3.20.0,!=3.20.1,!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5",
Expand Down
5 changes: 5 additions & 0 deletions testing/constraints-3.12.txt
Expand Up @@ -4,3 +4,8 @@
google-api-core
proto-plus
protobuf
mock==4.0.2
google-cloud-storage==2.2.1 # Increased for kfp 2.0 compatibility
pytest-xdist==3.3.1 # Pinned to unbreak unit tests
ray==2.5.0 # Pinned until 2.9.3 is verified for Ray tests
ipython==8.22.2 # Pinned to unbreak TypeAliasType import error
40 changes: 40 additions & 0 deletions tests/unit/conftest.py
@@ -0,0 +1,40 @@
# -*- coding: utf-8 -*-

# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

import sys

collect_ignore = []

if sys.version_info > (3, 11):
collect_ignore = [
"aiplatform/test_cloud_profiler.py",
"aiplatform/test_uploader.py",
"aiplatform/test_uploader_main.py",
"aiplatform/test_autologging.py",
"aiplatform/test_explain_lit.py",
"aiplatform/test_explain_saved_model_metadata_builder_tf2_test.py",
"aiplatform/test_metadata_models.py",
"aiplatform/test_endpoints.py",
"aiplatform/test_model_evaluation.py",
"aiplatform/test_models.py",
"aiplatform/test_utils.py",
"vertexai/test_reasoning_engines.py",
"vertexai/test_model_utils.py",
"vertexai/test_remote_training.py",
"vertexai/test_serializers.py",
"vertexai/test_vizier_hyperparameter_tuner.py",
]

0 comments on commit add2f92

Please sign in to comment.