Skip to content

Commit 385b1a8

Browse files
authored
Support for python 3.12 (#182)
1 parent b23b808 commit 385b1a8

File tree

11 files changed

+716
-716
lines changed

11 files changed

+716
-716
lines changed

.github/workflows/bandit.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
- uses: actions/checkout@v4
1414
- uses: actions/setup-python@v5
1515
with:
16-
python-version: "3.8"
16+
python-version: "3.9"
1717
- uses: snok/install-poetry@v1
1818
with:
1919
virtualenvs-create: true

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
fetch-depth: 0 # Necessary to get tags
2020
- uses: actions/setup-python@v5
2121
with:
22-
python-version: "3.8"
22+
python-version: "3.9"
2323
- uses: snok/install-poetry@v1
2424
with:
2525
virtualenvs-create: true

.github/workflows/mypy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
- uses: actions/checkout@v4
1414
- uses: actions/setup-python@v5
1515
with:
16-
python-version: "3.8"
16+
python-version: "3.9"
1717
- uses: snok/install-poetry@v1
1818
with:
1919
virtualenvs-create: true

.github/workflows/publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
fetch-depth: 0 # Necessary to get tags
2020
- uses: actions/setup-python@v5
2121
with:
22-
python-version: "3.8"
22+
python-version: "3.9"
2323
- uses: snok/install-poetry@v1
2424
with:
2525
virtualenvs-create: true

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
runs-on: ubuntu-latest
1212
strategy:
1313
matrix:
14-
python-version: ["3.8", "3.9", "3.10", "3.11"]
14+
python-version: ["3.9", "3.10", "3.11", "3.12"]
1515

1616
steps:
1717
- uses: actions/checkout@v4

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Welcome! We're glad to have you. If you would like to report a bug, request a ne
66

77
1. Python
88

9-
`modelscan` requires python version `>=3.8` and `<3.11`
9+
`modelscan` requires python version `>=3.9` and `<3.13`
1010

1111
2. Poetry
1212

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ At present, ModelScan supports any Pickle derived format and many others:
9191
| Classic ML Libraries (Sklearn, XGBoost etc.) | pickle.dump(), dill.dump(), joblib.dump(), cloudpickle.dump() | Pickle, Cloudpickle, Dill, Joblib | Yes |
9292

9393
### Installation
94-
ModelScan is installed on your systems as a Python package(Python 3.8 to 3.11 supported). As shown from above you can install
94+
ModelScan is installed on your systems as a Python package(Python 3.9 to 3.12 supported). As shown from above you can install
9595
it by running this in your terminal:
9696

9797
```bash

poetry.lock

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

pyproject.toml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,18 @@ exclude = ["tests/*", "Makefile"]
1212
modelscan = "modelscan.cli:main"
1313

1414
[tool.poetry.dependencies]
15-
python = ">=3.8,<3.13"
15+
python = ">=3.9,<3.13"
1616
click = "^8.1.3"
17-
numpy = "1.24.3"
17+
numpy = ">=1.24.3"
1818
rich = "^13.4.2"
1919
tomlkit = ">=0.12.3,<0.14.0"
2020
h5py = { version = "^3.9.0", optional = true }
2121

2222
# TODO: Add py3.12 once TF release supports
23-
tensorflow = { version = "^2.13.0", optional = true, python = "<3.12" }
24-
tensorflow-macos = { version = "^2.13.0", platform = "darwin", optional = true, python = "<3.12" }
25-
tensorflow-io-gcs-filesystem = { version = ">=0.23.1,<0.35", optional = true, python = "<3.12" }
23+
tensorflow = { version = "^2.17", optional = true }
2624

2725
[tool.poetry.extras]
28-
tensorflow = ["tensorflow", "tensorflow-macos"]
26+
tensorflow = ["tensorflow"]
2927
h5py = ["h5py"]
3028

3129
[tool.poetry.group.test.dependencies]
@@ -36,7 +34,8 @@ requests = "^2.31.0"
3634
aiohttp = "^3.8.5"
3735
dill = "^0.3.7"
3836
types-requests = ">1.26"
39-
torch = "^2.1.2"
37+
torch = "^2.2"
38+
tf-keras = "^2.16.0"
4039

4140

4241
[tool.poetry.group.dev.dependencies]

tests/test_modelscan.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import sys
1515
import torch
1616
import tensorflow as tf
17-
from tensorflow import keras
17+
import tf_keras as keras
1818
from typing import Any, List, Set, Dict
1919
from test_utils import (
2020
generate_dill_unsafe_file,
@@ -362,6 +362,9 @@ def keras_file_extensions() -> List[str]:
362362

363363
@pytest.fixture(scope="session")
364364
def keras_file_path(tmp_path_factory: Any, keras_file_extensions: List[str]) -> Any:
365+
# Use Keras 2.0
366+
os.environ["TF_USE_LEGACY_KERAS"] = "1"
367+
365368
# Create a simple model.
366369

367370
inputs = keras.Input(shape=(32,))
@@ -403,7 +406,7 @@ def keras_file_path(tmp_path_factory: Any, keras_file_extensions: List[str]) ->
403406
first_lambda_layer = keras.layers.Lambda(attack)(input_to_new_layer)
404407
second_lambda_layer = keras.layers.Lambda(attack)(first_lambda_layer)
405408

406-
malicious_model = tf.keras.Model(
409+
malicious_model = keras.Model(
407410
inputs=keras_model.inputs, outputs=[second_lambda_layer]
408411
)
409412
malicious_model.compile(optimizer="adam", loss="mean_squared_error")

0 commit comments

Comments
 (0)