Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 6 additions & 18 deletions .github/workflows/pr_stage_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,29 +32,17 @@ jobs:
MKL_THREADING_LAYER: GNU
strategy:
matrix:
python-version: ['3.11','3.12', '3.13']
torch: ['2.6.0', '2.7.0', '2.8.0']
python-version: ['3.12', '3.13']
torch: ['2.8.0']
cuda: ['cu126']
steps:
- name: Check out repo
uses: actions/checkout@v4
- name: Setup conda env
uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
miniconda-version: "latest"
use-only-tar-bz2: true
activate-environment: test
python-version: ${{ matrix.python-version }}
- name: Update pip
run: |
python -m pip install --upgrade pip wheel
- name: Setup uv
uses: astral-sh/setup-uv@v6
- name: Install dependencies
run: |
python -m pip install torch==${{matrix.torch}} --index-url https://download.pytorch.org/whl/${{matrix.cuda}}
python -m pip install -e .[tests] -v
python -m pip install mmcv+git@https://github.com/loseall/mmcv.git
run: uv sync --extra=tests
- name: Run unit tests with coverage
run: coverage run --branch --source mmengine -m pytest tests/ --ignore tests/test_dist
run: uv run --extra=tests coverage run --branch --source mmengine -m pytest tests --ignore tests/test_dist
- name: Upload Coverage to Codecov
uses: codecov/codecov-action@v3
11 changes: 5 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,15 @@ repos:
hooks:
- id: validate_manifest
- repo: https://github.com/PyCQA/flake8
rev: 7.1.1
rev: 7.1.2
hooks:
- id: flake8
additional_dependencies: [Flake8-pyproject]
exclude: (examples/|tests/)
- repo: https://github.com/PyCQA/isort
rev: 5.11.5
hooks:
- id: isort
- repo: https://github.com/pre-commit/mirrors-yapf
rev: v0.32.0
hooks:
- id: yapf
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
Expand Down Expand Up @@ -62,5 +60,6 @@ repos:
(?x)(
^examples
| ^docs
)
| ^tests
) | (setup.py) | (^mmengine/utils/package_utils\.py)
additional_dependencies: ["types-setuptools", "types-requests", "types-PyYAML"]
5 changes: 4 additions & 1 deletion mmengine/structures/pixel_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,10 @@ def __getitem__(self, item: Sequence[Union[int, slice]]) -> 'PixelData':
item3 = tuple(tmp_item)
item4 = (slice(None, None, None),) + item3
for k, v in self.items():
assert v.ndim in (3, 4), f"Expected tensor with 3 or 4 dimensions, got {v.ndim}"
assert v.ndim in (
3,
4,
), f'Expected tensor with 3 or 4 dimensions, got {v.ndim}'
setattr(new_data, k, v[item3] if v.ndim == 3 else v[item4])
else:
raise TypeError(
Expand Down
4 changes: 2 additions & 2 deletions mmengine/utils/package_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ def is_installed(package: str) -> bool:
# Therefore, import it in function scope to save time.
import importlib.util

import pkg_resources
from pkg_resources import get_distribution
import pkg_resources # type: ignore
from pkg_resources import get_distribution # type: ignore

# refresh the pkg_resources
# more datails at https://github.com/pypa/setuptools/issues/373
Expand Down
6 changes: 3 additions & 3 deletions mmengine/visualization/visualizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -878,9 +878,9 @@ def draw_binary_masks(
img = self.get_image()
if binary_masks.ndim == 2:
binary_masks = binary_masks[None]
assert img.shape[:2] == binary_masks.shape[
1:], '`binary_masks` must have ' \
'the same shape with image'
assert img.shape[:2] == binary_masks.shape[1:], (
'`binary_masks` must have the same shape with image'
)
binary_mask_len = binary_masks.shape[0]

check_type_and_length('colors', colors, (str, tuple, list),
Expand Down
11 changes: 9 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,13 @@ Docs = "https://mmsegmentation.readthedocs.io/en/main/"

[project.optional-dependencies]
tests = [
"aim<=3.17.5;sys_platform!='win32'",
"bitsandbytes",
"clearml",
"coverage",
"dadaptation",
"dvclive",
"flake8>=7.3.0",
"flake8-pyproject>=1.2.3",
"lion-pytorch",
"lmdb",
"mlflow",
Expand All @@ -55,4 +56,10 @@ tests = [
mmengine-cli = "mmengine.cli.__main__:main"

[tool.uv.sources]
mmengine-config = { git = "https://github.com/llteco/mmengine-config.git", rev="7592bce" }
mmengine-config = { git = "https://github.com/llteco/mmengine-config.git", rev="4b43fc2" }

[tool.flake8]
ignore = ['F824', 'W503', 'W504']
exclude = ["./examples", "./tests"]
max-line-length = 88
max-complexity = 30
Loading
Loading