Skip to content

Commit 279ab7a

Browse files
author
Songki Choi
authored
Fix packaging errors including cython module build / import issues (#1936)
* Avoid cychon compile on Windows * Fix packaging errors * Fix pre-commit * Remove use_develop option from tox tests * Fix pre-commit * Fix tox -e -> -re for clean build * Fix import error * Add missing __init__.py * Fix relative -> absolute import * Revert to editable package in tox tests --------- Signed-off-by: Songki Choi <[email protected]>
1 parent 46c786a commit 279ab7a

File tree

10 files changed

+29
-28
lines changed

10 files changed

+29
-28
lines changed

.github/workflows/pre_merge.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
- name: Install dependencies
4444
run: python -m pip install -r requirements/dev.txt
4545
- name: Unit-testing
46-
run: tox -re pre-merge -- tests/unit
46+
run: tox -e pre-merge -- tests/unit
4747
- name: Upload coverage reports to Codecov
4848
run: |
4949
# If the workflow is triggered from PR then it gets the commit id from the PR.
@@ -72,7 +72,7 @@ jobs:
7272
- name: Install dependencies
7373
run: python -m pip install -r requirements/dev.txt
7474
- name: Integration-testing
75-
run: tox -re pre-merge -- tests/integration/cli/test_cli.py
75+
run: tox -e pre-merge -- tests/integration/cli/test_cli.py
7676
Pre-Merge-Integration-Cls-Test:
7777
runs-on: [self-hosted, linux, x64, dev]
7878
needs: Pre-Merge-Unit-Test
@@ -83,7 +83,7 @@ jobs:
8383
- name: Install dependencies
8484
run: python -m pip install -r requirements/dev.txt
8585
- name: Integration-testing
86-
run: tox -re pre-merge-cls
86+
run: tox -e pre-merge-cls
8787
Pre-Merge-Integration-Det-Test:
8888
runs-on: [self-hosted, linux, x64, dev]
8989
needs: Pre-Merge-Unit-Test
@@ -94,7 +94,7 @@ jobs:
9494
- name: Install dependencies
9595
run: python -m pip install -r requirements/dev.txt
9696
- name: Integration-testing
97-
run: tox -re pre-merge-det
97+
run: tox -e pre-merge-det
9898
Pre-Merge-Integration-Seg-Test:
9999
runs-on: [self-hosted, linux, x64, dev]
100100
needs: Pre-Merge-Unit-Test
@@ -105,7 +105,7 @@ jobs:
105105
- name: Install dependencies
106106
run: python -m pip install -r requirements/dev.txt
107107
- name: Integration-testing
108-
run: tox -re pre-merge-seg
108+
run: tox -e pre-merge-seg
109109
Pre-Merge-Integration-Action-Test:
110110
runs-on: [self-hosted, linux, x64, dev]
111111
needs: Pre-Merge-Unit-Test
@@ -116,7 +116,7 @@ jobs:
116116
- name: Install dependencies
117117
run: python -m pip install -r requirements/dev.txt
118118
- name: Integration-testing
119-
run: tox -re pre-merge-action
119+
run: tox -e pre-merge-action
120120
Pre-Merge-Integration-Anomaly-Test:
121121
runs-on: [self-hosted, linux, x64, dev]
122122
needs: Pre-Merge-Unit-Test
@@ -127,4 +127,4 @@ jobs:
127127
- name: Install dependencies
128128
run: python -m pip install -r requirements/dev.txt
129129
- name: Integration-testing
130-
run: tox -re pre-merge-anomaly
130+
run: tox -e pre-merge-anomaly

MANIFEST.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@ recursive-include requirements *
22
recursive-include otx *.pyx
33
recursive-include otx *.yaml
44
recursive-include otx *.json
5+
recursive-exclude otx *.c
6+
graft tests
7+
global-exclude *.py[cod]

otx/algorithms/common/adapters/mmcv/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
)
3535
from .nncf.hooks import CompressionHook
3636
from .nncf.runners import AccuracyAwareRunner
37-
from .pipelines.transforms import pil_augment
3837
from .runner import EpochRunnerWithCancel, IterBasedRunnerWithCancel
3938

4039
__all__ = [
@@ -56,7 +55,6 @@
5655
"StopLossNanTrainingHook",
5756
"EMAMomentumUpdateHook",
5857
"CompressionHook",
59-
"pil_augment",
6058
"AccuracyAwareRunner",
6159
"TwoCropTransformHook",
6260
]
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
"""Pipelines for mmcv."""
2+
# Copyright (C) 2023 Intel Corporation
3+
# SPDX-License-Identifier: Apache-2.0
4+
#

otx/algorithms/common/adapters/mmcv/pipelines/transforms/__init__.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,3 @@
22
# Copyright (C) 2023 Intel Corporation
33
# SPDX-License-Identifier: Apache-2.0
44
#
5-
6-
# flake8: noqa
7-
8-
from .cython_augments import pil_augment
9-
10-
__all__ = ["pil_augment"]

otx/algorithms/common/adapters/mmcv/pipelines/transforms/augments.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
from PIL.Image import Image as PILImage
1212
from PIL.Image import Resampling
1313

14-
from otx.algorithms.common.adapters.mmcv.pipelines.transforms.cython_augments import (
15-
pil_augment as pil_aug,
16-
)
14+
# type: ignore[attr-defined]
15+
# pylint: disable = no-name-in-module
16+
import otx.algorithms.common.adapters.mmcv.pipelines.transforms.cython_augments.pil_augment as pil_aug
1717

1818
ImgTypes = Union[PILImage, CvImage]
1919

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
11
"""Module to init cython augments."""
22
# Copyright (C) 2023 Intel Corporation
33
# SPDX-License-Identifier: Apache-2.0
4-
# ignore mypy attr-defined error by cython modules
5-
# pylint: disable=import-self
6-
7-
from . import pil_augment # type: ignore[attr-defined]
8-
9-
__all__ = ["pil_augment"]
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
"""Adapters for OTX Common Algorithms."""
2+
# Copyright (C) 2023 Intel Corporation
3+
# SPDX-License-Identifier: Apache-2.0
4+
#

setup.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# SPDX-License-Identifier: Apache-2.0
55

66
import os
7+
import platform
78
import subprocess
89
import sys
910
import warnings
@@ -100,6 +101,9 @@ def get_requirements(requirement_files: Union[str, List[str]]) -> List[str]:
100101

101102

102103
def get_extensions():
104+
if platform.system() == "Windows":
105+
return []
106+
103107
def _cython_modules():
104108
package_root = os.path.dirname(__file__)
105109

@@ -111,14 +115,14 @@ def _cython_modules():
111115
ext_modules = [
112116
Extension(
113117
cython_file.rstrip(".pyx").replace("/", "."),
114-
[os.path.join(package_root, cython_file)],
118+
[cython_file],
115119
include_dirs=[numpy.get_include()],
116120
extra_compile_args=["-O3"],
117121
)
118122
for cython_file in cython_files
119123
]
120124

121-
return cythonize(ext_modules, annotate=True)
125+
return cythonize(ext_modules)
122126

123127
extensions = []
124128
extensions.extend(_cython_modules())

tox.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,11 +173,11 @@ deps =
173173
skip_install = true
174174
allowlist_externals =
175175
rm
176+
find
176177
commands =
177178
rm -rf ./dist
178179
python -m build --sdist
179-
python -m pip install dist/otx-1.1.0rc1.tar.gz[full]
180-
# python -m pip install otx[full]==1.1.0rc1
180+
find ./dist -type f -name *.tar.gz -exec pip install {}[full] \;
181181
pytest {posargs:tests/unit tests/integration/cli}
182182

183183

0 commit comments

Comments
 (0)