Skip to content

Commit

Permalink
chore: support Python 3.12
Browse files Browse the repository at this point in the history
Signed-off-by: SdgJlbl <sarah.diot-girard@owkin.com>
  • Loading branch information
SdgJlbl committed Jul 23, 2024
1 parent dd01b9b commit 8072bb1
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 8 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Set up python
uses: actions/setup-python@v5
with:
python-version: "3.11"
python-version: "3.12"
- name: Install tools
run: pip install flake8 black isort wheel docstring-parser
- name: Lint
Expand Down Expand Up @@ -45,7 +45,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11"]
python-version: ["3.9", "3.10", "3.11", "3.12"]
name: Tests on Python ${{ matrix.python-version }}
steps:
- name: Set up python
Expand Down
1 change: 1 addition & 0 deletions changes/418.added
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Python 3.12 support
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ classifiers = [
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
]
license = { file = "LICENSE" }
authors = [{ name = "Owkin, Inc." }]
Expand Down
4 changes: 2 additions & 2 deletions substra/sdk/backends/local/compute/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,15 +150,15 @@ def _prepare_artifact_input(self, task_input, task_key, input_volume, multiple):
assert output.kind == schemas.AssetKind.model, "The task_input value must be an artifact, not a performance"
filename = _generate_filename()
path_to_input = input_volume / filename
Path(output.asset.address.storage_address).link_to(path_to_input)
Path(path_to_input).hardlink_to(output.asset.address.storage_address)

return TaskResource(id=task_input.identifier, value=f"{TPL_VOLUME_INPUTS}/{filename}", multiple=multiple)

def _prepare_dataset_input(
self, dataset: models.Dataset, task_input: models.InputRef, input_volume: str, multiple: bool
):
path_to_opener = input_volume / Filenames.OPENER.value
Path(dataset.opener.storage_address).link_to(path_to_opener)
Path(path_to_opener).hardlink_to(dataset.opener.storage_address)
return TaskResource(
id=task_input.identifier,
value=f"{TPL_VOLUME_INPUTS}/{Filenames.OPENER.value}",
Expand Down
8 changes: 4 additions & 4 deletions tests/data_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@

DEFAULT_DATA_SAMPLE_FILENAME = "data.csv"

DEFAULT_SUBSTRATOOLS_VERSION = (
f"latest-nvidiacuda11.8.0-base-ubuntu22.04-python{sys.version_info.major}.{sys.version_info.minor}"
)
DEFAULT_SUBSTRATOOLS_VERSION = f"{sys.version_info.major}.{sys.version_info.minor}-slim"

DEFAULT_SUBSTRATOOLS_DOCKER_IMAGE = f"ghcr.io/substra/substra-tools:{DEFAULT_SUBSTRATOOLS_VERSION}"
DEFAULT_SUBSTRATOOLS_DOCKER_IMAGE = f"python:{DEFAULT_SUBSTRATOOLS_VERSION}"

DEFAULT_OPENER_SCRIPT = f"""
import csv
Expand Down Expand Up @@ -246,6 +244,8 @@ def _save_predictions(y_pred, path):
DEFAULT_FUNCTION_DOCKERFILE = f"""
FROM {DEFAULT_SUBSTRATOOLS_DOCKER_IMAGE}
COPY function.py .
RUN apt-get update && apt-get install -y git
RUN python3 -m pip install git+https://github.com/Substra/substra-tools.git@main
ENTRYPOINT ["python3", "function.py", "--function-name", "{{function_name}}"]
"""

Expand Down

0 comments on commit 8072bb1

Please sign in to comment.