Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python 3.11 support #887

Merged
merged 24 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/run-operators-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10"]
python-version: ["3.8", "3.9", "3.10", "3.11"]

steps:
- uses: actions/checkout@v4
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/run-unittests-default_setup.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "[Py3.8][Py3.9][Py3.10] tests/unitary/default_setup/**"
name: "[Py3.8-3.11] - Default Tests"

on:
workflow_dispatch:
Expand Down Expand Up @@ -33,7 +33,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10"]
python-version: ["3.8", "3.9", "3.10", "3.11"]

steps:
- uses: actions/checkout@v4
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/run-unittests-py38-cov-report.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "[Py3.8][COV REPORT] tests/unitary/**"
name: "[Py3.8][COV REPORT] - All Unit Tests"

on:
workflow_dispatch:
Expand Down Expand Up @@ -44,6 +44,7 @@ jobs:
ignore-path: |
--ignore tests/unitary/with_extras/model \
--ignore tests/unitary/with_extras/feature_store \
--ignore tests/unitary/with_extras/operator/feature-store \
--ignore tests/unitary/with_extras/operator/forecast \
--ignore tests/unitary/with_extras/hpo
- name: "slow_tests"
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/run-unittests-py39-py310.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "[Py3.9][Py3.10] - tests/unitary/**"
name: "[Py3.9-3.11] - All Unit Tests"

on:
workflow_dispatch:
Expand Down Expand Up @@ -33,7 +33,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10"]
python-version: ["3.9", "3.10", "3.11"]
name: ["unitary", "slow_tests"]
include:
- name: "unitary"
Expand All @@ -46,6 +46,7 @@ jobs:
ignore-path: |
--ignore tests/unitary/with_extras/model \
--ignore tests/unitary/with_extras/feature_store \
--ignore tests/unitary/with_extras/operator/feature-store \
--ignore tests/unitary/with_extras/operator/forecast \
--ignore tests/unitary/with_extras/operator/pii \
--ignore tests/unitary/with_extras/hpo
Expand Down
2 changes: 2 additions & 0 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Do not add test dependencies here. Use pyproject.toml [project.optional-dependencies] 'testsuite' section.
# Reason - it is flexible to specify different version for specific python
-r test-requirements.txt
-e ".[aqua,bds,data,geo,huggingface,llm,notebook,onnx,opctl,optuna,spark,tensorflow,text,torch,viz]"
-e ".[testsuite]"
52 changes: 33 additions & 19 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ classifiers = [
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
]

# PEP 508 – Dependency specification for Python Software Packages - https://peps.python.org/pep-0508/
Expand All @@ -61,8 +62,8 @@ dependencies = [
"fsspec>=0.8.7",
"gitpython>=3.1.2",
"jinja2>=2.11.2",
"matplotlib>=3.1.3, <=3.8.4",
"numpy>=1.19.2, <2.0.0",
"matplotlib>=3.1.3,<=3.8.4",
"numpy>=1.19.2,<2.0.0",
"oci>=2.125.3",
"ocifs>=1.1.3",
"pandas>1.2.1; python_version<'3.9'", # starting pandas v2.1.0 requires-python = '>=3.9'
Expand All @@ -79,7 +80,7 @@ dependencies = [
# Copied from extras_require list in setup.py, setup.py got removed in favor of this config file
bds = ["hdfs[kerberos]", "ibis-framework[impala]", "sqlalchemy"]
boosted = [
"lightgbm<4.0.0", # relax when the official releases of skl2onnx (v1.16.0) and onnxmltools (1.11.3), https://github.com/sdpython/mlprodict/issues/488
"lightgbm",
"xgboost",
]
data = [
Expand All @@ -89,18 +90,24 @@ data = [
"openpyxl>=3.0.7",
"oracledb>=1.0",
"pandavro>=1.6.0",
"sqlalchemy>=1.4.1, <=1.4.46",
"sqlalchemy>=1.4.1,<=1.4.46",
]
geo = [
"geopandas<1.0.0", # in v1.0.0 removed the built-in dataset 'naturalearth_lowres', fix when relax version of geopandas needed
"oracle_ads[viz]"
]
huggingface = [
"transformers",
"tf-keras" # Keras 3 installed in py3.11+, but this is not yet supported in Transformers. Need to install the backwards-compatible tf-keras
]
geo = ["geopandas", "oracle_ads[viz]"]
huggingface = ["transformers"]
notebook = ["ipython>=7.23.1, <8.0", "ipywidgets~=7.6.3"]
onnx = [
"lightgbm<4.0.0", # relax when the official releases of skl2onnx (v1.16.0) and onnxmltools (1.11.3), https://github.com/sdpython/mlprodict/issues/488
"onnx>=1.12.0",
"lightgbm",
"onnx>=1.12.0,<=1.15.0", # v 1.15.0 set base on onnxrutime version and onnx opset support - https://onnxruntime.ai/docs/reference/compatibility.html#onnx-opset-support
"onnxmltools>=1.10.0",
"onnxruntime>=1.10.0,<1.16", # v1.16 introduced issues https://github.com/microsoft/onnxruntime/issues/17631, revealed by unit tests
"onnxruntime~=1.17.0,!=1.16.0", # v1.17.0 used in Oracle Database 23ai; avoid v1.16 https://github.com/microsoft/onnxruntime/issues/17631, revealed by unit tests
"oracle_ads[viz]",
"protobuf<=3.20",
"protobuf",
"skl2onnx>=1.10.4",
"tf2onnx",
"xgboost<=1.7",
Expand All @@ -119,11 +126,21 @@ opctl = [
]
optuna = ["optuna==2.9.0", "oracle_ads[viz]"]
spark = ["pyspark>=3.0.0"]
tensorflow = ["oracle_ads[viz]", "tensorflow"]
text = ["spacy", "wordcloud>=1.8.1"]
torch = ["oracle_ads[viz]", "torch", "torchvision"]
tensorflow = [
"oracle_ads[viz]",
"tensorflow<=2.15.1" # v2.16.1 with consequence on tf2onnx v1.16.1 (latest) has an issue with Keras 3 installed in py3.11+ (https://github.com/onnx/tensorflow-onnx/issues/2319)
]
text = [
"spacy>=3.4.2", # the first version of spacy that supports python 3.11 is spacy v3.4.2
"wordcloud>=1.8.1"
]
torch = [
"oracle_ads[viz]",
"torch<2.1.0", # torch > 2.1.0 brings nvidia dependecy by default
"torchvision"
]
viz = [
"bokeh>=3.0.0, <3.2.0", # starting 3.2.0 bokeh not supporting python3.8; relax after ADS will drop py3.8 support
"bokeh>=3.0.0,<3.2.0", # starting 3.2.0 bokeh not supporting python3.8; relax after ADS will drop py3.8 support
"folium>=0.12.1",
"graphviz<0.17",
"scipy>=1.5.4",
Expand Down Expand Up @@ -182,13 +199,9 @@ aqua = ["jupyter_server"]
# trying to use. Ref - https://pip.pypa.io/en/stable/topics/dependency-resolution/#possible-ways-to-reduce-backtracking.
# Revisit this section continuously and update to recent version of libraries. focus on pyt3.9/3.10 versions.
testsuite = [
"dask==2023.5.0; python_version=='3.8'",
"dask==2023.10.1; python_version>='3.9'", # oci-cli depends on click==8.0.4, dask>2023.10.1 depends on "click>=8.1"
"arff",
"category_encoders==2.6.3", # set version to avoid backtracking
"cohere==4.53", # set version to avoid backtracking
"dask==2023.10.1; python_version>='3.9'", # oci-cli depends on click==8.0.4, dask>2023.10.1 depends on "click>=8.1"
"dask==2023.5.0; python_version=='3.8'",
"faiss-cpu",
"fastparquet==2024.2.0", # set version to avoid backtracking
"imbalanced-learn",
Expand All @@ -199,10 +212,11 @@ testsuite = [
"opensearch-py",
"pdfplumber",
"py4j",
"pyarrow",
"pyarrow>=15.0.0",
"statsmodels; python_version=='3.8'",
"statsmodels>=0.14.1; python_version>='3.9'", # cython3.0 compatibility added in v0.14.1
"tables",
"tables>3.9.0; python_version>='3.9'",
"xlrd>=1.2.0",
]

Expand Down
3 changes: 2 additions & 1 deletion test-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Include here only libraries required to run test methods, like mock, pytest, coverage etc.
# Add dependencies for ADS to pyproject.toml [project.optional-dependencies] 'testsuite' section.
-e .
click
coverage
Expand All @@ -8,5 +10,4 @@ pip
pytest
pytest-cov
pytest-xdist
kubernetes
ruff
16 changes: 0 additions & 16 deletions tests/unitary/default_setup/common/test_common_ADSData.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,22 +149,6 @@ def test_ADSData_build_valid_input_using_target_vector(self):
assert expected.y.name == "target"
assert expected.y.shape == (3,)

@pytest.mark.skipif("NoDependency" in os.environ, reason="skip for dependency test")
def test_ADSData_build_valid_input_dask_dataframe(self):
"""
Ensures build method takes dask dataframe
"""
import dask

X = dask.datasets.timeseries().drop("y", axis=1)
y = dask.datasets.timeseries()["y"]
expected = ADSData.build(X, y)
assert sorted(expected.X.columns.tolist()) == sorted(["id", "name", "x"])
assert expected.X.shape[0] == 2592000
assert expected.X.shape[1] == 3
assert expected.y.name == "y"
assert expected.y.shape[0] == 2592000

@pytest.mark.skip("api change. this test should be re-written.")
def test_ADSData_build_with_data(self):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -524,23 +524,6 @@ def test_populate_schema_list(self):
self.model_artifact.populate_schema(X_sample=list(self.X))
mock_warning.assert_called()

@pytest.mark.skipif("NoDependency" in os.environ, reason="skip for dependency test")
def test_populate_schema_dask_tuple(self):
import dask.dataframe as dd

self.model_artifact.populate_schema(
X_sample=dd.from_array(self.X), y_sample=tuple(self.y)
)
assert isinstance(self.model_artifact.schema_input, Schema)
assert isinstance(self.model_artifact.schema_output, Schema)

# Test wide data
with patch.object(Schema, "validate_size", side_effect=SchemaSizeTooLarge(100)):
with patch.object(logger, "warning") as mock_warning:
self.model_artifact.populate_schema(
X_sample=dd.from_array(self.X), y_sample=tuple(self.y)
)
mock_warning.assert_called()

def test_simple_constraint(self):
self.df["sepal length (cm)"].ads.feature_type = ["category"]
Expand Down
Loading