Skip to content

Commit 38e8bba

Browse files
committed
[GSK-1763] Adding python 3.11 support
Contributes to GSK-1762
1 parent b42ff78 commit 38e8bba

7 files changed

Lines changed: 5932 additions & 68 deletions

File tree

.github/workflows/build_backend.yml

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -123,30 +123,30 @@ jobs:
123123
run: ./gradlew :backend:integrationTest --info -Ptestcontainers
124124

125125
build-python:
126-
name: "Python ${{ matrix.python-version }}${{ matrix.pydantic_v1 && ' (Pydantic V1)' || ''}} on ${{ matrix.os }}${{matrix.experimental && ' (Non failing)' || '' }}"
126+
name: "Python ${{ matrix.python-version }}${{ matrix.pydantic_v2 && ' (Pydantic V2)' || ''}} on ${{ matrix.os }}${{matrix.experimental && ' (Non failing)' || '' }}"
127127
runs-on: ${{ matrix.os }}
128128
strategy:
129129
fail-fast: false # Do not stop when any job fails
130130
matrix:
131-
python-version: [ "3.8", "3.9", "3.10" ]
131+
python-version: [ "3.8", "3.9", "3.10", "3.11" ]
132132
os: [ubuntu-latest]
133-
experimental: [false]
134-
pydantic_v1: [false]
133+
pydantic_v2: [false]
135134
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources
136135
include:
137136
- python-version: "3.10"
138137
os: windows-2019
139-
experimental: false
140-
pydantic_v1: false
138+
pydantic_v2: false
141139
- python-version: "3.10"
142-
os: ubuntu-latest
143-
experimental: false
144-
pydantic_v1: true
140+
os: windows-2022
141+
pydantic_v2: false
145142
- python-version: "3.10"
146143
os: macos-latest
147-
experimental: false
148-
pydantic_v1: false
149-
continue-on-error: ${{ matrix.experimental }} # https://ncorti.com/blog/howto-github-actions-build-matrix
144+
pydantic_v2: false
145+
- python-version: "3.10"
146+
os: ubuntu-latest
147+
pydantic_v2: true
148+
149+
continue-on-error: false # https://ncorti.com/blog/howto-github-actions-build-matrix
150150
steps:
151151
- name: Checkout code
152152
uses: actions/checkout@v3.3.0
@@ -184,18 +184,18 @@ jobs:
184184
working-directory: python-client
185185
run: pdm run lint
186186

187-
- name: Install pydantic v1
188-
if: ${{ matrix.pydantic_v1 }}
187+
- name: Install pydantic v2
188+
if: ${{ matrix.pydantic_v2 }}
189189
working-directory: python-client
190190
run: |
191191
pdm run pip uninstall pydantic pydantic_core -y
192-
pdm run pip install "pydantic<2"
192+
pdm run pip install "pydantic>=2<3"
193193
194194
- name: Check Pydantic installed version
195195
working-directory: python-client
196196
run: |
197197
pdm run pip freeze | grep '^pydantic'
198-
pdm run pip freeze | grep -q '^pydantic==${{ matrix.pydantic_v1 && '1' || '2' }}\.'
198+
pdm run pip freeze | grep -q '^pydantic==${{ matrix.pydantic_v2 && '2' || '1' }}\.'
199199
200200
- name: Test code
201201
working-directory: python-client

python-client/giskard/ml_worker/websocket/listener.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ def on_message(self, frame):
218218
def on_ml_worker_get_info(ml_worker: MLWorker, params: GetInfoParam, *args, **kwargs) -> websocket.GetInfo:
219219
logger.info("Collecting ML Worker info from WebSocket")
220220

221+
# TODO(Bazire): seems to be deprecated https://setuptools.pypa.io/en/latest/pkg_resources.html#workingset-objects
221222
installed_packages = (
222223
{p.project_name: p.version for p in pkg_resources.working_set} if params.list_packages else None
223224
)

python-client/pdm.lock

Lines changed: 5875 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

python-client/pyproject.toml

Lines changed: 39 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[build-system]
2-
requires = ["setuptools>=61", "wheel"]
3-
build-backend = "setuptools.build_meta"
2+
requires = ["pdm-backend"]
3+
build-backend = "pdm.backend"
44

55
[tool.setuptools.packages.find]
66
include = ["giskard*"]
@@ -18,7 +18,6 @@ url = "https://download.pytorch.org/whl/cpu/torch_stable.html"
1818
name = "torch"
1919

2020

21-
2221
[tool.pdm.scripts]
2322
_.env = { GSK_DISABLE_ANALYTICS = "True" }
2423
# add "-n auto" to the pytest command to parallelize the execution
@@ -28,8 +27,9 @@ test-fast.cmd = "pytest -n auto -m 'not slow' -c pyproject.toml tests --cov=gisk
2827
lint = "ruff giskard tests"
2928
doc = "sphinx-build docs docs/_build/html"
3029
watch-doc = "python -m sphinx_autobuild --watch giskard docs docs/_build/html"
31-
clean = "rm -rf .venv coverage.xml coverage* .coverage*"
30+
clean = "rm -rf coverage.xml coverage* .coverage*"
3231
notebook = "jupyter notebook --ip 0.0.0.0 --port 8888 --no-browser --notebook-dir ./notebooks --NotebookApp.token=''"
32+
check-deps = "deptry ."
3333

3434
[tool.pdm.dev-dependencies]
3535
dev = [
@@ -39,39 +39,35 @@ dev = [
3939
"pre-commit>=2.19.0",
4040
"mypy>=0.982",
4141
"deptry>=0.5.13",
42-
"httpretty>=1.1.4",
42+
"ruff>=0.0.271",
43+
"mlflow>2",
44+
"black[d]>=22.12.0",
4345
"pip>=23.1.2",
46+
]
47+
ml_runtime = [
4448
"langchain>=0.0.187",
4549
"nltk>=3.8.1",
4650
"xgboost>=1.7.5",
4751
"lightgbm>=3.3.5",
4852
"imbalanced-learn>=0.10.1",
49-
"pytest-xdist>=3.3.1",
50-
"ruff>=0.0.271",
51-
"mlflow>2",
52-
"black[d]>=22.12.0",
53-
]
54-
test = [
55-
"pytest-cov>=4.0.0",
56-
"pytest>=7.1.2",
5753
"catboost>=1.1.1",
5854
"requests-mock>=1.10.0",
5955
"tensorflow-hub>=0.12.0",
60-
"transformers>=4.33, <4.34", # https://github.com/huggingface/transformers/issues/23352
61-
"sentencepiece", # needed for some transformers stuff with tokenizer
56+
"transformers>=4.33, <4.34", # https://github.com/huggingface/transformers/issues/23352
57+
"sentencepiece", # needed for some transformers stuff with tokenizer
6258
"torch>=2.0.0",
6359
"torchdata>=0.6.0",
60+
"portalocker>=2.0.0", # Needed by torchdata for test_newspaper_classification_pytorch_dataset
6461
"torchtext>=0.15.1",
65-
"portalocker>=2.0.0",
66-
"scikit-learn==1.0.2",
6762
"tensorflow-macos>=2.13.0, <2.14; sys_platform == 'darwin' and platform_machine == 'arm64'",
6863
"tensorflow>=2.13, <2.14",
69-
# tensorflow-text is only available on linux, and neither on arm64 nor windows
70-
"tensorflow-text>=2.13, <2.14; sys_platform == 'linux' and (platform_machine == 'amd64' or platform_machine == 'x86_64')",
64+
# tensorflow-text is only available on linux or mac, but not for arm64 nor windows
65+
"tensorflow-text>=2.13, <2.14; python_version < '3.11' and (sys_platform == 'linux' or sys_platform == 'darwin') and platform_machine == 'x86_64'",
7166
"mlflow>2",
7267
"wandb",
73-
"tensorflow-io-gcs-filesystem<0.32; platform_machine != 'arm64'", # Tensorflow io does not work for windows from 0.32, but does not work for arm64 before...
68+
"tensorflow-io-gcs-filesystem<0.32; platform_machine != 'arm64'", # Tensorflow io does not work for windows from 0.32, but does not work for arm64 before...
7469
]
70+
test = ["pytest-cov>=4.0.0", "pytest>=7.1.2", "pytest-xdist>=3.3.1"]
7571
doc = [
7672
"furo>=2023.5.20",
7773
"myst-parser>=1.0.0",
@@ -85,7 +81,7 @@ doc = [
8581
"sphinx-copybutton>=0.5.2",
8682
"sphinx-click>=4.4.0",
8783
"nbsphinx>=0.9.2",
88-
"ipython==8.12.0"
84+
"ipython==8.12.0",
8985
]
9086

9187
[project.scripts]
@@ -134,42 +130,43 @@ classifiers = [
134130
"Programming Language :: Python :: 3.10",
135131
]
136132

137-
requires-python = ">=3.8.1, <3.11"
133+
requires-python = ">=3.8.1, <3.12"
138134
dependencies = [
139135
"cloudpickle>=1.1.1",
140-
"zstandard>=0.10.0 ",
136+
"zstandard>=0.10.0",
141137
"mlflow-skinny>=2",
142-
"protobuf<3.21", # Not compatible with transformers/tensorflow
143-
"numpy>=1.22.0,<1.24.0", # shap doesn't work with numpy>1.24.0: module 'numpy' has no attribute 'int'
138+
"gitpython",
139+
"protobuf<3.21", # Not compatible with transformers/tensorflow
140+
"numpy>=1.22.0",
144141
"scikit-learn>=1.0",
145142
"scipy>=1.7.3",
146143
"mixpanel>=4.4.0",
147144
"requests>=2.19",
148145
"pydantic<3,>1",
149-
"tqdm>=4.42.0",
150-
"setuptools>=39.1.0,<68.0.0",
151146
"pandas>=1.3.4,<2",
152147
"xxhash>=3.2.0",
153148
"langdetect>=1.0.9",
154-
"chardet", # text metadata
155-
"jinja2>=3", # scan template
156-
"markdown",
149+
"chardet", # text metadata
150+
"jinja2>=3", # scan template
157151
"requests-toolbelt>=0.9.1",
158152
"stomp-py>=8.1.0",
159-
"pyyaml", # cli_server
160-
"packaging", # cli_server
153+
"setuptools", # used in ml worker for pkg_resources
154+
"typing_extensions", # used in registry/decorators, for python <3.10
155+
"websocket-client", # used in worker, to get exception from stomp
156+
"pyyaml", # cli_server
157+
"packaging", # cli_server
161158
]
162159

163160
[project.optional-dependencies]
164161
llm = [
165162
"transformers",
166-
"torch",
167-
"langchain",
168-
"evaluate",
169-
# pdm lock -G:all doesn't work without fixing these two versions
170-
"datasets>=2.13.0",
171-
"bert-score>=0.3.13",
163+
"torch",
164+
"langchain",
165+
"evaluate",
166+
"bert-score",
167+
"datasets"
172168
]
169+
173170
server = [
174171
"tenacity>=4.11.0",
175172
"psutil>=5.4.6",
@@ -267,3 +264,7 @@ addopts = [
267264
"--doctest-modules",
268265
"--doctest-continue-on-failure",
269266
]
267+
268+
[tool.deptry]
269+
extend_exclude = [".history"]
270+
ignore_notebooks = true

python-client/setup.py

Lines changed: 0 additions & 12 deletions
This file was deleted.

python-client/tests/scan/test_scanner.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ def test_default_dataset_is_used_with_generative_model():
110110

111111

112112
@pytest.mark.slow
113-
@pytest.mark.skip("Crashing test for docker")
114113
def test_generative_model_dataset():
115114
llm = FakeListLLM(responses=["Are you dumb or what?", "I don't know and I don't want to know."] * 100)
116115
prompt = PromptTemplate(template="{instruct}: {question}", input_variables=["instruct", "question"])

python-client/tests/test_performance.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ def test_mse(model, data, threshold, expected_metric, actual_slices_size, reques
149149
).execute()
150150

151151
assert results.actual_slices_size[0] == actual_slices_size
152-
assert results.metric == pytest.approx(expected_metric)
152+
assert results.metric == pytest.approx(expected_metric, abs=1e-2)
153153
assert results.passed
154154

155155

0 commit comments

Comments
 (0)