Skip to content

Commit

Permalink
Update python version metadata (remove 3.7, 3.8, 3.9; add 3.13). (#23067
Browse files Browse the repository at this point in the history
)

### Description

* Update python version metadata to be in sync with latest python
packages (onnxruntime, onnxruntime-gpu and onnxruntime-qnn).
* Update black format target-version to 3.10, and use lintrunner to
format all files.
* Update the lintrunner installation command line to be consistent.
* Include `requirements-lintrunner.txt` in `requirements-dev.txt` to
avoid duplicated settings.

### Motivation and Context

#22993

Python support by numpy:
https://numpy.org/neps/nep-0029-deprecation_policy.html#drop-schedule
```
On Apr 05, 2024 drop support for Python 3.9
On Apr 04, 2025 drop support for Python 3.10
```
  • Loading branch information
tianleiwu authored Dec 17, 2024
1 parent 0981bbf commit 5afab78
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 39 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v5
with:
# Version range or exact version of Python to use, using SemVer's version range syntax. Reads from .python-version if unset.
# Use the version configured in target-version of [tool.black] section in pyproject.toml.
python-version: "3.10"
- name: Setup Rust
uses: actions-rs/toolchain@v1
Expand All @@ -55,12 +55,10 @@ jobs:
- name: Update PATH
run: |
echo "$HOME/.local/bin" >> "$GITHUB_PATH"
- name: Install dependencies
run: |
set -e -x
python -m pip install --user -r requirements-dev.txt
python -m pip install --user lintrunner lintrunner-adapters
lintrunner init
- name: Run lintrunner on all files
run: |
Expand Down
18 changes: 5 additions & 13 deletions .lintrunner.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,23 @@
# You can install the dependencies and initialize with
#
# ```sh
# pip install lintrunner lintrunner-adapters
# pip install -r requirements-lintrunner.txt
# lintrunner init
# ```
#
# This will install lintrunner on your system and download all the necessary
# dependencies to run linters locally.
# If you want to see what lintrunner init will install, run
# `lintrunner init --dry-run`.
#
# To lint local changes:
# To format local changes:
#
# ```bash
# lintrunner
# lintrunner -a
# ```
#
# To lint all files:
# To format all files:
#
# ```bash
# lintrunner --all-files
# ```
#
# To format files:
#
# ```bash
# lintrunner f --all-files
# lintrunner -a --all-files
# ```
#
# To read more about lintrunner, see [wiki](https://github.com/pytorch/pytorch/wiki/lintrunner).
Expand Down
12 changes: 3 additions & 9 deletions docs/Coding_Conventions_and_Standards.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,22 +164,16 @@ dependencies to run linters locally.
If you want to see what lintrunner init will install, run
`lintrunner init --dry-run`.

To lint local changes:

```bash
lintrunner
```

To format files and apply suggestions:
To format local changes:

```bash
lintrunner -a
```

To lint all files:
To format all files:

```bash
lintrunner --all-files
lintrunner -a --all-files
```

To show help text:
Expand Down
11 changes: 7 additions & 4 deletions orttraining/orttraining/python/training/artifacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,13 @@ def build(self, *inputs_to_loss):
logging.info("Custom op library provided: %s", custom_op_library)
custom_op_library_path = pathlib.Path(custom_op_library)

with onnxblock.base(loaded_model, model_path), (
onnxblock.custom_op_library(custom_op_library_path)
if custom_op_library is not None
else contextlib.nullcontext()
with (
onnxblock.base(loaded_model, model_path),
(
onnxblock.custom_op_library(custom_op_library_path)
if custom_op_library is not None
else contextlib.nullcontext()
),
):
_ = training_block(*[output.name for output in loaded_model.graph.output])
training_model, eval_model = training_block.to_model_proto()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -867,8 +867,9 @@ def _get_exported_model(
assert model_info_for_export.export_mode is not None, "Please use a concrete instance of ExecutionManager"

try:
with torch.no_grad(), stage3_export_context(
enable_zero_stage3_support, stage3_param_handle, flattened_module
with (
torch.no_grad(),
stage3_export_context(enable_zero_stage3_support, stage3_param_handle, flattened_module),
):
required_export_kwargs = {
"input_names": model_info_for_export.onnx_graph_input_names, # did not contains parameters as its input yet
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
line-length = 120
# NOTE: Do not extend the exclude list. Edit .lintrunner.toml instead
extend-exclude = "cmake|onnxruntime/core/flatbuffers/"
target-version = ["py37", "py38", "py39", "py310", "py311"]
# NOTE: use the minimum supported python version as target-version
target-version = ["py310"]

[tool.isort]
# NOTE: Do not extend the exclude list. Edit .lintrunner.toml instead
Expand Down
3 changes: 1 addition & 2 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
black>=22.3
-r requirements-lintrunner.txt
cerberus
flatbuffers
isort
jinja2
numpy
onnx
Expand Down
8 changes: 3 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,8 @@ def finalize_options(self):
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Operating System :: POSIX :: Linux",
"Operating System :: Microsoft :: Windows",
"Operating System :: MacOS",
"Topic :: Scientific/Engineering",
"Topic :: Scientific/Engineering :: Mathematics",
"Topic :: Scientific/Engineering :: Artificial Intelligence",
Expand All @@ -537,14 +539,10 @@ def finalize_options(self):
"Topic :: Software Development :: Libraries :: Python Modules",
"Programming Language :: Python",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Operating System :: Microsoft :: Windows",
"Operating System :: MacOS",
"Programming Language :: Python :: 3.13",
]

if enable_training or enable_training_apis:
Expand Down

0 comments on commit 5afab78

Please sign in to comment.