Skip to content

Commit

Permalink
feat: support python 3.12 (#630)
Browse files Browse the repository at this point in the history
* support python 3.12

* test

* update

* fix

* test

* fix

* fix

* test

* add restriction to numpy

* test

* test

* test
  • Loading branch information
masanorihirano authored Aug 26, 2024
1 parent c97450d commit 9912f0a
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 59 deletions.
12 changes: 6 additions & 6 deletions .flexci/config.pbtxt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
configs {
key: "pfhedge.python38-linux"
key: "pfhedge.python39-linux"
value {
requirement {
cpu: 2
Expand All @@ -10,12 +10,12 @@ configs {
time_limit: {
seconds: 1200
}
command: "bash .flexci/linux/script.sh python38"
command: "bash .flexci/linux/script.sh python39"
}
}

configs {
key: "pfhedge.python39-linux"
key: "pfhedge.python310-linux"
value {
requirement {
cpu: 2
Expand All @@ -26,12 +26,12 @@ configs {
time_limit: {
seconds: 1200
}
command: "bash .flexci/linux/script.sh python39"
command: "bash .flexci/linux/script.sh python310"
}
}

configs {
key: "pfhedge.python310-linux"
key: "pfhedge.python311-linux"
value {
requirement {
cpu: 2
Expand All @@ -42,6 +42,6 @@ configs {
time_limit: {
seconds: 1200
}
command: "bash .flexci/linux/script.sh python310"
command: "bash .flexci/linux/script.sh python311"
}
}
1 change: 1 addition & 0 deletions .flexci/linux/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ declare -A python_versions=(
["python38"]="3.8.12"
["python39"]="3.9.7"
["python310"]="3.10.4"
["python311"]="3.11.5"
)

################################################################################
Expand Down
102 changes: 51 additions & 51 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,66 +2,69 @@ name: CI

env:
PROJECT_NAME: pfhedge
PYTHON_VERSION: '3.9'
PYTHON_VERSION: "3.9"

on:
push:
branches:
branches:
- main
- develop
- release/*
- hotfix/*
pull_request:
branches:
branches:
- main
- develop
- release/*
- hotfix/*
workflow_dispatch:

jobs:

test:

name: Test

runs-on: ubuntu-latest

strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11']
torch-version: ['1.9.0', '1.13.1', '2.0.0']
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
torch-version: ["1.9.0", "1.13.1", "2.0.0", "2.4.0"]
# pytorch 1.9.0 does not support python 3.10, 3.11
exclude:
- python-version: '3.10'
- python-version: "3.10"
torch-version: "1.9.0"
- python-version: '3.11'
- python-version: "3.11"
torch-version: "1.9.0"
- python-version: "3.12"
torch-version: "1.9.0"
- python-version: "3.12"
torch-version: "1.13.1"
- python-version: "3.12"
torch-version: "2.0.0"

steps:
- uses: actions/checkout@v2

- uses: actions/checkout@v2

- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install
run: |
pip install poetry
poetry install
poetry run pip uninstall -y torch
poetry run pip install torch==${{ matrix.torch-version }}
- name: Install
run: |
pip install poetry
poetry install
poetry run pip uninstall -y torch
poetry run pip install torch==${{ matrix.torch-version }}
- name: Run doctest
run: make doctest
- name: Run doctest
run: make doctest

- name: Run pytest
run: make test-cov
- name: Run pytest
run: make test-cov

- name: Upload codecov report
uses: codecov/codecov-action@v1
if: ${{ matrix.python-version == '3.9' && matrix.torch-version == '1.13.1' }}
- name: Upload codecov report
uses: codecov/codecov-action@v1
if: ${{ matrix.python-version == '3.9' && matrix.torch-version == '1.13.1' }}

lint:
name: Lint (pysen)
Expand All @@ -71,19 +74,17 @@ jobs:
status: ${{ job.status }}

steps:
- uses: actions/checkout@v2

- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: ${{ env.PYTHON_VERSION }}

- uses: actions/setup-python@v2
with:
python-version: ${{ env.PYTHON_VERSION }}
- run: pip install poetry && poetry install

- run: pip install poetry && poetry install

- run: make lint
- run: make lint

format:

name: Format

runs-on: ubuntu-latest
Expand All @@ -93,23 +94,22 @@ jobs:
if: ${{ always() && needs.lint.outputs.status == 'failure' }}

steps:
- uses: actions/checkout@v2

- uses: actions/checkout@v2

- uses: actions/setup-python@v2
with:
python-version: ${{ env.PYTHON_VERSION }}
- uses: actions/setup-python@v2
with:
python-version: ${{ env.PYTHON_VERSION }}

- run: pip install poetry && poetry install
- run: pip install poetry && poetry install

- run: make format
- run: make format

- name: Create pull request
uses: peter-evans/create-pull-request@v3
with:
author: GitHub Actions <[email protected]>
base: ${{ github.event.pull_request.head.ref }}
commit-message: Automated Format
delete-branch: true
branch-suffix: short-commit-hash
title: Automated Format
- name: Create pull request
uses: peter-evans/create-pull-request@v3
with:
author: GitHub Actions <[email protected]>
base: ${{ github.event.pull_request.head.ref }}
commit-message: Automated Format
delete-branch: true
branch-suffix: short-commit-hash
title: Automated Format
5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ license = "MIT"
repository = "https://github.com/pfnet-research/pfhedge"

[tool.poetry.dependencies]
python = "^3.8.1,<3.12"
python = "^3.8.1"
torch = ">=1.9.0,<3.0.0"
tqdm = "^4.62.3"
numpy = [{version = "^1.26", python = ">=3.9"}, {version = "<1.25", python = "=3.8"}]

[tool.poetry.dev-dependencies]
pytest = "^6.2.5"
Expand All @@ -23,7 +24,7 @@ furo = "^2021.9.22"
codecov = "^2.1.12"
click = "8.0.4"
flake8 = "4.0.1"
scipy = "^1.10.1"
scipy = [{ version = "^1.10.1", markers = "python_version < '3.9'" }, { version = "^1.12.0", markers = "python_version >= '3.9'" }]
mypy = "^1.11.1"
pyproject-flake8 = "4.0.1"

Expand Down

0 comments on commit 9912f0a

Please sign in to comment.