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

Support for python 3.12 #182

Merged
merged 5 commits into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from all 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/bandit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.8"
python-version: "3.9"
- uses: snok/install-poetry@v1
with:
virtualenvs-create: true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
fetch-depth: 0 # Necessary to get tags
- uses: actions/setup-python@v5
with:
python-version: "3.8"
python-version: "3.9"
- uses: snok/install-poetry@v1
with:
virtualenvs-create: true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/mypy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.8"
python-version: "3.9"
- uses: snok/install-poetry@v1
with:
virtualenvs-create: true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
fetch-depth: 0 # Necessary to get tags
- uses: actions/setup-python@v5
with:
python-version: "3.8"
python-version: "3.9"
- uses: snok/install-poetry@v1
with:
virtualenvs-create: true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Welcome! We're glad to have you. If you would like to report a bug, request a ne

1. Python

`modelscan` requires python version `>=3.8` and `<3.11`
`modelscan` requires python version `>=3.9` and `<3.13`

2. Poetry

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ At present, ModelScan supports any Pickle derived format and many others:
| Classic ML Libraries (Sklearn, XGBoost etc.) | pickle.dump(), dill.dump(), joblib.dump(), cloudpickle.dump() | Pickle, Cloudpickle, Dill, Joblib | Yes |

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

```bash
Expand Down
1,396 changes: 697 additions & 699 deletions poetry.lock

Large diffs are not rendered by default.

13 changes: 6 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,18 @@ exclude = ["tests/*", "Makefile"]
modelscan = "modelscan.cli:main"

[tool.poetry.dependencies]
python = ">=3.8,<3.13"
python = ">=3.9,<3.13"
click = "^8.1.3"
numpy = "1.24.3"
numpy = ">=1.24.3"
rich = "^13.4.2"
tomlkit = ">=0.12.3,<0.14.0"
h5py = { version = "^3.9.0", optional = true }

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

[tool.poetry.extras]
tensorflow = ["tensorflow", "tensorflow-macos"]
tensorflow = ["tensorflow"]
h5py = ["h5py"]

[tool.poetry.group.test.dependencies]
Expand All @@ -36,7 +34,8 @@ requests = "^2.31.0"
aiohttp = "^3.8.5"
dill = "^0.3.7"
types-requests = ">1.26"
torch = "^2.1.2"
torch = "^2.2"
tf-keras = "^2.16.0"


[tool.poetry.group.dev.dependencies]
Expand Down
7 changes: 5 additions & 2 deletions tests/test_modelscan.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import sys
import torch
import tensorflow as tf
from tensorflow import keras
import tf_keras as keras
from typing import Any, List, Set, Dict
from test_utils import (
generate_dill_unsafe_file,
Expand Down Expand Up @@ -362,6 +362,9 @@ def keras_file_extensions() -> List[str]:

@pytest.fixture(scope="session")
def keras_file_path(tmp_path_factory: Any, keras_file_extensions: List[str]) -> Any:
# Use Keras 2.0
os.environ["TF_USE_LEGACY_KERAS"] = "1"

# Create a simple model.

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

malicious_model = tf.keras.Model(
malicious_model = keras.Model(
inputs=keras_model.inputs, outputs=[second_lambda_layer]
)
malicious_model.compile(optimizer="adam", loss="mean_squared_error")
Expand Down
2 changes: 1 addition & 1 deletion tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import torch
import torch.nn as nn
import tensorflow as tf
from tensorflow import keras
import tf_keras as keras


class MaliciousModule(keras.Model): # type: ignore
Expand Down