Skip to content

Commit 3dde7f3

Browse files
Native namespace packages (PEP 420) (#2361)
* native namespace packages * docstring * test * style * test cli exprters and pipelines * specify folder * path :/ * fixes * fix * extend * fix * final fix * only keep one way for registering commands * remove print * revert load_subpackages * style * trigger * pip uninstall optimum optimum-onnx * try using less of macos 15 (because of provisions) * test provision issue with macos 14 * fix node version for docs * use one macos 15 * use macos 14 * no need to test macos everywhere * better command registration that avoids importing the subpackages and only import the commands
1 parent 17f767f commit 3dde7f3

20 files changed

Lines changed: 187 additions & 187 deletions

.github/workflows/build_main_documentation.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
steps:
2020
- uses: actions/setup-node@v4
2121
with:
22-
node-version: "18"
22+
node-version: "20"
2323
cache-dependency-path: "kit/package-lock.json"
2424

2525
- name: Set up Python

.github/workflows/build_pr_documentation.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
steps:
3131
- uses: actions/setup-node@v4
3232
with:
33-
node-version: "18"
33+
node-version: "20"
3434
cache-dependency-path: "kit/package-lock.json"
3535

3636
- name: Set up Python

.github/workflows/test_cli.yml

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Optimum CLI / Python - Test
1+
name: Optimum CLI / Python - Test - Subpackage (ONNX)
22

33
on:
44
push:
@@ -11,21 +11,35 @@ concurrency:
1111
cancel-in-progress: true
1212

1313
env:
14+
UV_SYSTEM_PYTHON: 1
15+
UV_TORCH_BACKEND: cpu
16+
OPTIMUM_ONNX_REF: main
1417
TRANSFORMERS_IS_CI: true
1518

1619
jobs:
1720
build:
1821
strategy:
1922
fail-fast: false
2023
matrix:
21-
os: [ubuntu-22.04, macos-13, windows-2022]
22-
python-version: ["3.9"]
24+
python-version: [3.9]
25+
runs-on: [ubuntu-22.04, windows-2022]
2326

2427
runs-on: ${{ matrix.runs-on }}
2528

2629
steps:
27-
- name: Checkout code
30+
- name: Checkout optimum
2831
uses: actions/checkout@v4
32+
with:
33+
path: optimum
34+
fetch-depth: 0
35+
36+
- name: checkout optimum-onnx
37+
uses: actions/checkout@v4
38+
with:
39+
repository: huggingface/optimum-onnx
40+
ref: ${{ env.OPTIMUM_ONNX_REF }}
41+
path: optimum-onnx
42+
fetch-depth: 0
2943

3044
- name: Setup Python ${{ matrix.python-version }}
3145
uses: actions/setup-python@v5
@@ -34,10 +48,22 @@ jobs:
3448

3549
- name: Install dependencies
3650
run: |
37-
pip install --upgrade pip
38-
pip install --no-cache-dir torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
39-
pip install .[tests,exporters]
51+
pip install --upgrade pip uv
52+
uv pip install ./optimum-onnx[onnxruntime]
53+
uv pip install ./optimum[tests]
4054
4155
- name: Test with pytest
4256
run: |
4357
pytest tests/cli -vvvv --durations=0
58+
working-directory: optimum
59+
60+
- name: Install dependencies (editable mode)
61+
run: |
62+
uv pip uninstall optimum-onnx optimum
63+
uv pip install -e ./optimum-onnx[onnxruntime]
64+
uv pip install -e ./optimum[tests]
65+
66+
- name: Test with pytest (editable mode)
67+
run: |
68+
pytest tests/cli -vvvv --durations=0
69+
working-directory: optimum

.github/workflows/test_common.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ concurrency:
1111
cancel-in-progress: true
1212

1313
env:
14+
UV_SYSTEM_PYTHON: 1
15+
UV_TORCH_BACKEND: cpu
1416
TRANSFORMERS_IS_CI: true
1517

1618
jobs:
@@ -19,7 +21,7 @@ jobs:
1921
fail-fast: false
2022
matrix:
2123
python-version: [3.9]
22-
runs-on: [ubuntu-22.04, windows-2022, macos-14]
24+
runs-on: [ubuntu-22.04, macos-14, windows-2022]
2325

2426
runs-on: ${{ matrix.runs-on }}
2527

@@ -34,9 +36,8 @@ jobs:
3436

3537
- name: Install dependencies
3638
run: |
37-
pip install --upgrade pip
38-
pip install --no-cache-dir torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
39-
pip install .[tests]
39+
pip install --upgrade pip uv
40+
uv pip install .[tests]
4041
4142
- name: Test with pytest
4243
run: |
Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Exporters Common / Python - Test
1+
name: Exporters Common / Python - Test - Subpackage (ONNX)
22

33
on:
44
push:
@@ -11,21 +11,35 @@ concurrency:
1111
cancel-in-progress: true
1212

1313
env:
14+
UV_SYSTEM_PYTHON: 1
15+
UV_TORCH_BACKEND: cpu
16+
OPTIMUM_ONNX_REF: main
1417
TRANSFORMERS_IS_CI: true
1518

1619
jobs:
1720
build:
1821
strategy:
1922
fail-fast: false
2023
matrix:
21-
runs-on: [ubuntu-22.04]
2224
python-version: [3.9]
25+
runs-on: [ubuntu-22.04, windows-2022]
2326

2427
runs-on: ${{ matrix.runs-on }}
2528

2629
steps:
27-
- name: Checkout code
30+
- name: Checkout optimum
2831
uses: actions/checkout@v4
32+
with:
33+
path: optimum
34+
fetch-depth: 0
35+
36+
- name: checkout optimum-onnx
37+
uses: actions/checkout@v4
38+
with:
39+
repository: huggingface/optimum-onnx
40+
ref: ${{ env.OPTIMUM_ONNX_REF }}
41+
path: optimum-onnx
42+
fetch-depth: 0
2943

3044
- name: Setup Python ${{ matrix.python-version }}
3145
uses: actions/setup-python@v5
@@ -34,11 +48,22 @@ jobs:
3448

3549
- name: Install dependencies
3650
run: |
37-
pip install --upgrade pip
38-
pip install --no-cache-dir torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
39-
pip install optimum-onnx@git+https://github.com/huggingface/optimum-onnx.git
40-
pip install .[tests]
51+
pip install --upgrade pip uv
52+
uv pip install ./optimum-onnx
53+
uv pip install ./optimum[tests]
4154
4255
- name: Test with pytest
4356
run: |
4457
pytest tests/exporters/common -vvvv --durations=0 -n auto
58+
working-directory: optimum
59+
60+
- name: Install dependencies (editable mode)
61+
run: |
62+
uv pip uninstall optimum-onnx optimum
63+
uv pip install -e ./optimum-onnx
64+
uv pip install -e ./optimum[tests]
65+
66+
- name: Test with pytest (editable mode)
67+
run: |
68+
pytest tests/exporters/common -vvvv --durations=0 -n auto
69+
working-directory: optimum

.github/workflows/test_pipelines.yml

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Optimum Pipelines / Python - Test
1+
name: Optimum Pipelines / Python - Test - Subpackage (ONNX)
22

33
on:
44
push:
@@ -12,7 +12,8 @@ concurrency:
1212

1313
env:
1414
UV_SYSTEM_PYTHON: 1
15-
UV_TORCH_BACKEND: auto
15+
UV_TORCH_BACKEND: cpu
16+
OPTIMUM_ONNX_REF: main
1617
TRANSFORMERS_IS_CI: true
1718

1819
jobs:
@@ -21,13 +22,24 @@ jobs:
2122
fail-fast: false
2223
matrix:
2324
python-version: [3.9]
24-
runs-on: [ubuntu-22.04]
25+
runs-on: [ubuntu-22.04, windows-2022]
2526

2627
runs-on: ${{ matrix.runs-on }}
2728

2829
steps:
29-
- name: Checkout code
30+
- name: Checkout optimum
3031
uses: actions/checkout@v4
32+
with:
33+
path: optimum
34+
fetch-depth: 0
35+
36+
- name: checkout optimum-onnx
37+
uses: actions/checkout@v4
38+
with:
39+
repository: huggingface/optimum-onnx
40+
ref: ${{ env.OPTIMUM_ONNX_REF }}
41+
path: optimum-onnx
42+
fetch-depth: 0
3143

3244
- name: Setup Python ${{ matrix.python-version }}
3345
uses: actions/setup-python@v5
@@ -37,9 +49,21 @@ jobs:
3749
- name: Install dependencies
3850
run: |
3951
pip install --upgrade pip uv
40-
uv pip install --no-cache-dir optimum-onnx[onnxruntime]@git+https://github.com/huggingface/optimum-onnx.git
41-
uv pip install --no-cache-dir .[tests]
52+
uv pip install ./optimum-onnx[onnxruntime]
53+
uv pip install ./optimum[tests]
4254
4355
- name: Test with pytest
4456
run: |
4557
pytest tests/pipelines -vvvv --durations=0
58+
working-directory: optimum
59+
60+
- name: Install dependencies (editable mode)
61+
run: |
62+
uv pip uninstall optimum-onnx optimum
63+
uv pip install -e ./optimum-onnx[onnxruntime]
64+
uv pip install -e ./optimum[tests]
65+
66+
- name: Test with pytest (editable mode)
67+
run: |
68+
pytest tests/pipelines -vvvv --durations=0
69+
working-directory: optimum

.github/workflows/test_utils.yml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,20 @@ concurrency:
1111
cancel-in-progress: true
1212

1313
env:
14+
UV_SYSTEM_PYTHON: 1
15+
UV_TORCH_BACKEND: cpu
1416
TRANSFORMERS_IS_CI: true
1517

1618
jobs:
1719
build:
1820
strategy:
1921
fail-fast: false
2022
matrix:
21-
os: [ubuntu-22.04, macos-13, windows-2022]
22-
python-version: ["3.9"]
23+
python-version: [3.9]
24+
runs-on: [ubuntu-22.04, macos-14, windows-2022]
25+
26+
runs-on: ${{ matrix.runs-on }}
2327

24-
runs-on: ${{ matrix.os }}
2528
steps:
2629
- name: Checkout code
2730
uses: actions/checkout@v4
@@ -33,10 +36,9 @@ jobs:
3336

3437
- name: Install dependencies
3538
run: |
36-
pip install --upgrade pip
37-
pip install --no-cache-dir torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
38-
pip install .[tests]
39+
pip install --upgrade pip uv
40+
uv pip install .[tests]
3941
4042
- name: Tests needing datasets
4143
run: |
42-
pytest tests/utils -n auto -vvvv --durations=0
44+
pytest tests/utils -n auto -vvvv --durations=0

optimum/__init__.py

Lines changed: 0 additions & 15 deletions
This file was deleted.

optimum/commands/__init__.py

Lines changed: 0 additions & 19 deletions
This file was deleted.

optimum/commands/env.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from transformers.utils import is_tf_available, is_torch_available
2020

2121
from ..version import __version__ as version
22-
from . import BaseOptimumCLICommand, CommandInfo
22+
from .base import BaseOptimumCLICommand, CommandInfo
2323

2424

2525
class EnvironmentCommand(BaseOptimumCLICommand):

0 commit comments

Comments
 (0)