Skip to content

Commit 5afab78

Browse files
authored
Update python version metadata (remove 3.7, 3.8, 3.9; add 3.13). (microsoft#23067)
### 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 microsoft#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 ```
1 parent 0981bbf commit 5afab78

File tree

8 files changed

+25
-39
lines changed

8 files changed

+25
-39
lines changed

.github/workflows/lint.yml

+1-3
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545
- name: Setup Python
4646
uses: actions/setup-python@v5
4747
with:
48-
# Version range or exact version of Python to use, using SemVer's version range syntax. Reads from .python-version if unset.
48+
# Use the version configured in target-version of [tool.black] section in pyproject.toml.
4949
python-version: "3.10"
5050
- name: Setup Rust
5151
uses: actions-rs/toolchain@v1
@@ -55,12 +55,10 @@ jobs:
5555
- name: Update PATH
5656
run: |
5757
echo "$HOME/.local/bin" >> "$GITHUB_PATH"
58-
5958
- name: Install dependencies
6059
run: |
6160
set -e -x
6261
python -m pip install --user -r requirements-dev.txt
63-
python -m pip install --user lintrunner lintrunner-adapters
6462
lintrunner init
6563
- name: Run lintrunner on all files
6664
run: |

.lintrunner.toml

+5-13
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,23 @@
22
# You can install the dependencies and initialize with
33
#
44
# ```sh
5-
# pip install lintrunner lintrunner-adapters
5+
# pip install -r requirements-lintrunner.txt
66
# lintrunner init
77
# ```
88
#
99
# This will install lintrunner on your system and download all the necessary
1010
# dependencies to run linters locally.
11-
# If you want to see what lintrunner init will install, run
12-
# `lintrunner init --dry-run`.
1311
#
14-
# To lint local changes:
12+
# To format local changes:
1513
#
1614
# ```bash
17-
# lintrunner
15+
# lintrunner -a
1816
# ```
1917
#
20-
# To lint all files:
18+
# To format all files:
2119
#
2220
# ```bash
23-
# lintrunner --all-files
24-
# ```
25-
#
26-
# To format files:
27-
#
28-
# ```bash
29-
# lintrunner f --all-files
21+
# lintrunner -a --all-files
3022
# ```
3123
#
3224
# To read more about lintrunner, see [wiki](https://github.com/pytorch/pytorch/wiki/lintrunner).

docs/Coding_Conventions_and_Standards.md

+3-9
Original file line numberDiff line numberDiff line change
@@ -164,22 +164,16 @@ dependencies to run linters locally.
164164
If you want to see what lintrunner init will install, run
165165
`lintrunner init --dry-run`.
166166

167-
To lint local changes:
168-
169-
```bash
170-
lintrunner
171-
```
172-
173-
To format files and apply suggestions:
167+
To format local changes:
174168

175169
```bash
176170
lintrunner -a
177171
```
178172

179-
To lint all files:
173+
To format all files:
180174

181175
```bash
182-
lintrunner --all-files
176+
lintrunner -a --all-files
183177
```
184178

185179
To show help text:

orttraining/orttraining/python/training/artifacts.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -185,10 +185,13 @@ def build(self, *inputs_to_loss):
185185
logging.info("Custom op library provided: %s", custom_op_library)
186186
custom_op_library_path = pathlib.Path(custom_op_library)
187187

188-
with onnxblock.base(loaded_model, model_path), (
189-
onnxblock.custom_op_library(custom_op_library_path)
190-
if custom_op_library is not None
191-
else contextlib.nullcontext()
188+
with (
189+
onnxblock.base(loaded_model, model_path),
190+
(
191+
onnxblock.custom_op_library(custom_op_library_path)
192+
if custom_op_library is not None
193+
else contextlib.nullcontext()
194+
),
192195
):
193196
_ = training_block(*[output.name for output in loaded_model.graph.output])
194197
training_model, eval_model = training_block.to_model_proto()

orttraining/orttraining/python/training/ortmodule/_graph_transition_manager.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -867,8 +867,9 @@ def _get_exported_model(
867867
assert model_info_for_export.export_mode is not None, "Please use a concrete instance of ExecutionManager"
868868

869869
try:
870-
with torch.no_grad(), stage3_export_context(
871-
enable_zero_stage3_support, stage3_param_handle, flattened_module
870+
with (
871+
torch.no_grad(),
872+
stage3_export_context(enable_zero_stage3_support, stage3_param_handle, flattened_module),
872873
):
873874
required_export_kwargs = {
874875
"input_names": model_info_for_export.onnx_graph_input_names, # did not contains parameters as its input yet

pyproject.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
line-length = 120
33
# NOTE: Do not extend the exclude list. Edit .lintrunner.toml instead
44
extend-exclude = "cmake|onnxruntime/core/flatbuffers/"
5-
target-version = ["py37", "py38", "py39", "py310", "py311"]
5+
# NOTE: use the minimum supported python version as target-version
6+
target-version = ["py310"]
67

78
[tool.isort]
89
# NOTE: Do not extend the exclude list. Edit .lintrunner.toml instead

requirements-dev.txt

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
black>=22.3
1+
-r requirements-lintrunner.txt
22
cerberus
33
flatbuffers
4-
isort
54
jinja2
65
numpy
76
onnx

setup.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,8 @@ def finalize_options(self):
529529
"Intended Audience :: Developers",
530530
"License :: OSI Approved :: MIT License",
531531
"Operating System :: POSIX :: Linux",
532+
"Operating System :: Microsoft :: Windows",
533+
"Operating System :: MacOS",
532534
"Topic :: Scientific/Engineering",
533535
"Topic :: Scientific/Engineering :: Mathematics",
534536
"Topic :: Scientific/Engineering :: Artificial Intelligence",
@@ -537,14 +539,10 @@ def finalize_options(self):
537539
"Topic :: Software Development :: Libraries :: Python Modules",
538540
"Programming Language :: Python",
539541
"Programming Language :: Python :: 3 :: Only",
540-
"Programming Language :: Python :: 3.7",
541-
"Programming Language :: Python :: 3.8",
542-
"Programming Language :: Python :: 3.9",
543542
"Programming Language :: Python :: 3.10",
544543
"Programming Language :: Python :: 3.11",
545544
"Programming Language :: Python :: 3.12",
546-
"Operating System :: Microsoft :: Windows",
547-
"Operating System :: MacOS",
545+
"Programming Language :: Python :: 3.13",
548546
]
549547

550548
if enable_training or enable_training_apis:

0 commit comments

Comments
 (0)