Skip to content

Commit

Permalink
Merge branch 'Project-MONAI:dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
ibro45 authored Feb 5, 2024
2 parents ba27569 + 718e4be commit 1b97be1
Show file tree
Hide file tree
Showing 752 changed files with 1,117 additions and 74 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/chatops.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: dispatch
uses: peter-evans/slash-command-dispatch@v3.0.2
uses: peter-evans/slash-command-dispatch@v4.0.0
with:
token: ${{ secrets.PR_MAINTAIN }}
reaction-token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cron-ngc-bundle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
id: pip-cache
run: echo "datew=$(date '+%Y-%V')" >> $GITHUB_OUTPUT
- name: cache for pip
uses: actions/cache@v3
uses: actions/cache@v4
id: cache
with:
path: ~/.cache/pip
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/cron.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:
if pgrep python; then pkill python; fi
shell: bash
- name: Upload coverage
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
fail_ci_if_error: false
files: ./coverage.xml
Expand Down Expand Up @@ -111,7 +111,7 @@ jobs:
if pgrep python; then pkill python; fi
shell: bash
- name: Upload coverage
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
fail_ci_if_error: false
files: ./coverage.xml
Expand Down Expand Up @@ -212,7 +212,7 @@ jobs:
if pgrep python; then pkill python; fi
shell: bash
- name: Upload coverage
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
fail_ci_if_error: false
files: ./coverage.xml
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
- name: docker_build
shell: bash
run: |
rm -rf /opt/hostedtoolcache
find /opt/hostedtoolcache/* -maxdepth 0 ! -name 'Python' -exec rm -rf {} \;
docker --version
# get tag info for versioning
cat _version.py
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
id: pip-cache
run: echo "datew=$(date '+%Y-%V')" >> $GITHUB_OUTPUT
- name: cache for pip
uses: actions/cache@v3
uses: actions/cache@v4
id: cache
with:
path: |
Expand Down Expand Up @@ -71,7 +71,7 @@ jobs:
run: ./runtests.sh --build --net

- name: Add reaction
uses: peter-evans/create-or-update-comment@v3
uses: peter-evans/create-or-update-comment@v4
with:
token: ${{ secrets.PR_MAINTAIN }}
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
Expand All @@ -95,7 +95,7 @@ jobs:
id: pip-cache
run: echo "datew=$(date '+%Y-%V')" >> $GITHUB_OUTPUT
- name: cache for pip
uses: actions/cache@v3
uses: actions/cache@v4
id: cache
with:
path: |
Expand Down Expand Up @@ -151,7 +151,7 @@ jobs:
python -m tests.test_integration_gpu_customization
- name: Add reaction
uses: peter-evans/create-or-update-comment@v3
uses: peter-evans/create-or-update-comment@v4
with:
token: ${{ secrets.PR_MAINTAIN }}
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pythonapp-gpu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,6 @@ jobs:
shell: bash
- name: Upload coverage
if: ${{ github.head_ref != 'dev' && github.event.pull_request.merged != true }}
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
files: ./coverage.xml
6 changes: 3 additions & 3 deletions .github/workflows/pythonapp-min.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
shell: bash
- name: cache for pip
uses: actions/cache@v3
uses: actions/cache@v4
id: cache
with:
path: ${{ steps.pip-cache.outputs.dir }}
Expand Down Expand Up @@ -90,7 +90,7 @@ jobs:
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
shell: bash
- name: cache for pip
uses: actions/cache@v3
uses: actions/cache@v4
id: cache
with:
path: ${{ steps.pip-cache.outputs.dir }}
Expand Down Expand Up @@ -135,7 +135,7 @@ jobs:
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
shell: bash
- name: cache for pip
uses: actions/cache@v3
uses: actions/cache@v4
id: cache
with:
path: ${{ steps.pip-cache.outputs.dir }}
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/pythonapp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
run: |
echo "datew=$(date '+%Y-%V')" >> $GITHUB_OUTPUT
- name: cache for pip
uses: actions/cache@v3
uses: actions/cache@v4
id: cache
with:
path: ~/.cache/pip
Expand Down Expand Up @@ -83,7 +83,7 @@ jobs:
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
shell: bash
- name: cache for pip
uses: actions/cache@v3
uses: actions/cache@v4
id: cache
with:
path: ${{ steps.pip-cache.outputs.dir }}
Expand Down Expand Up @@ -136,7 +136,7 @@ jobs:
run: |
echo "datew=$(date '+%Y-%V')" >> $GITHUB_OUTPUT
- name: cache for pip
uses: actions/cache@v3
uses: actions/cache@v4
id: cache
with:
path: |
Expand Down Expand Up @@ -217,7 +217,7 @@ jobs:
run: |
echo "datew=$(date '+%Y-%V')" >> $GITHUB_OUTPUT
- name: cache for pip
uses: actions/cache@v3
uses: actions/cache@v4
id: cache
with:
path: |
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
python -m pip install --user --upgrade setuptools wheel
- name: Build and test source archive and wheel file
run: |
rm -rf /opt/hostedtoolcache
find /opt/hostedtoolcache/* -maxdepth 0 ! -name 'Python' -exec rm -rf {} \;
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
root_dir=$PWD
echo "$root_dir"
Expand Down Expand Up @@ -102,7 +102,7 @@ jobs:
python-version: '3.9'
- shell: bash
run: |
rm -rf /opt/hostedtoolcache
find /opt/hostedtoolcache/* -maxdepth 0 ! -name 'Python' -exec rm -rf {} \;
git describe
python -m pip install --user --upgrade setuptools wheel
python setup.py build
Expand Down Expand Up @@ -143,7 +143,7 @@ jobs:
RELEASE_VERSION: ${{ steps.versioning.outputs.tag }}
shell: bash
run: |
rm -rf /opt/hostedtoolcache
find /opt/hostedtoolcache/* -maxdepth 0 ! -name 'Python' -exec rm -rf {} \;
# get tag info for versioning
mv _version.py monai/
# version checks
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/setupapp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
echo "datew=$(date '+%Y-%V')" >> $GITHUB_OUTPUT
- name: cache for pip
if: ${{ startsWith(github.ref, 'refs/heads/dev') }}
uses: actions/cache@v3
uses: actions/cache@v4
id: cache
with:
path: |
Expand Down Expand Up @@ -68,7 +68,7 @@ jobs:
if pgrep python; then pkill python; fi
shell: bash
- name: Upload coverage
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
fail_ci_if_error: false
files: ./coverage.xml
Expand All @@ -91,7 +91,7 @@ jobs:
run: |
echo "datew=$(date '+%Y-%V')" >> $GITHUB_OUTPUT
- name: cache for pip
uses: actions/cache@v3
uses: actions/cache@v4
id: cache
with:
path: |
Expand All @@ -100,7 +100,7 @@ jobs:
key: ${{ runner.os }}-${{ matrix.python-version }}-pip-${{ steps.pip-cache.outputs.datew }}
- name: Install the dependencies
run: |
rm -rf /opt/hostedtoolcache
find /opt/hostedtoolcache/* -maxdepth 0 ! -name 'Python' -exec rm -rf {} \;
python -m pip install --upgrade pip wheel
python -m pip install -r requirements-dev.txt
- name: Run quick tests CPU ubuntu
Expand All @@ -111,7 +111,7 @@ jobs:
BUILD_MONAI=1 ./runtests.sh --build --quick --min
coverage xml --ignore-errors
- name: Upload coverage
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
fail_ci_if_error: false
files: ./coverage.xml
Expand All @@ -128,7 +128,7 @@ jobs:
run: |
echo "datew=$(date '+%Y-%V')" >> $GITHUB_OUTPUT
- name: cache for pip
uses: actions/cache@v3
uses: actions/cache@v4
id: cache
with:
path: |
Expand All @@ -146,7 +146,7 @@ jobs:
- name: Install the default branch with build (dev branch only)
if: github.ref == 'refs/heads/dev'
run: |
rm -rf /opt/hostedtoolcache
find /opt/hostedtoolcache/* -maxdepth 0 ! -name 'Python' -exec rm -rf {} \;
BUILD_MONAI=1 pip install git+https://github.com/Project-MONAI/MONAI#egg=MONAI
python -c 'import monai; monai.config.print_config()'
- name: Get the test cases (dev branch only)
Expand Down
1 change: 1 addition & 0 deletions monai/apps/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,7 @@ def get_dataset(self, folds: Sequence[int] | int, **dataset_params: Any) -> obje
dataset_params_.update(dataset_params)

class _NsplitsDataset(self.dataset_cls): # type: ignore

def _split_datalist(self, datalist: list[dict]) -> list[dict]:
data = partition_dataset(data=datalist, num_partitions=nfolds, shuffle=True, seed=seed)
return select_cross_validation_folds(partitions=data, folds=folds)
Expand Down
3 changes: 3 additions & 0 deletions monai/apps/deepedit/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@


class DiscardAddGuidanced(MapTransform):

def __init__(
self,
keys: KeysCollection,
Expand Down Expand Up @@ -84,6 +85,7 @@ def __call__(self, data: Mapping[Hashable, np.ndarray]) -> dict[Hashable, np.nda


class NormalizeLabelsInDatasetd(MapTransform):

def __init__(
self, keys: KeysCollection, label_names: dict[str, int] | None = None, allow_missing_keys: bool = False
):
Expand Down Expand Up @@ -121,6 +123,7 @@ def __call__(self, data: Mapping[Hashable, np.ndarray]) -> dict[Hashable, np.nda


class SingleLabelSelectiond(MapTransform):

def __init__(
self, keys: KeysCollection, label_names: Sequence[str] | None = None, allow_missing_keys: bool = False
):
Expand Down
1 change: 1 addition & 0 deletions monai/apps/detection/metrics/coco.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@


class COCOMetric:

def __init__(
self,
classes: Sequence[str],
Expand Down
1 change: 1 addition & 0 deletions monai/apps/detection/utils/ATSS_matcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ def compute_matches(


class ATSSMatcher(Matcher):

def __init__(
self,
num_candidates: int = 4,
Expand Down
8 changes: 6 additions & 2 deletions monai/apps/detection/utils/anchor_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,8 +369,12 @@ class AnchorGeneratorWithAnchorShape(AnchorGenerator):
def __init__(
self,
feature_map_scales: Sequence[int] | Sequence[float] = (1, 2, 4, 8),
base_anchor_shapes: Sequence[Sequence[int]]
| Sequence[Sequence[float]] = ((32, 32, 32), (48, 20, 20), (20, 48, 20), (20, 20, 48)),
base_anchor_shapes: Sequence[Sequence[int]] | Sequence[Sequence[float]] = (
(32, 32, 32),
(48, 20, 20),
(20, 48, 20),
(20, 20, 48),
),
indexing: str = "ij",
) -> None:
nn.Module.__init__(self)
Expand Down
6 changes: 3 additions & 3 deletions monai/apps/pathology/transforms/post/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def __call__(self, prob_map: NdarrayOrTensor) -> NdarrayOrTensor:
pred = label(pred)[0]
if self.remove_small_objects is not None:
pred = self.remove_small_objects(pred)
pred[pred > 0] = 1 # type: ignore
pred[pred > 0] = 1

return convert_to_dst_type(pred, prob_map, dtype=self.dtype)[0]

Expand Down Expand Up @@ -338,7 +338,7 @@ def __call__(self, mask: NdarrayOrTensor, instance_border: NdarrayOrTensor) -> N
instance_border = instance_border >= self.threshold # uncertain area

marker = mask - convert_to_dst_type(instance_border, mask)[0] # certain foreground
marker[marker < 0] = 0 # type: ignore
marker[marker < 0] = 0
marker = self.postprocess_fn(marker)
marker = convert_to_numpy(marker)

Expand Down Expand Up @@ -634,7 +634,7 @@ def __call__( # type: ignore

seg_map_crop = convert_to_dst_type(seg_map_crop == instance_id, type_map_crop, dtype=bool)[0]

inst_type = type_map_crop[seg_map_crop] # type: ignore
inst_type = type_map_crop[seg_map_crop]
type_list, type_pixels = unique(inst_type, return_counts=True)
type_list = list(zip(type_list, type_pixels))
type_list = sorted(type_list, key=lambda x: x[1], reverse=True)
Expand Down
1 change: 1 addition & 0 deletions monai/data/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -1275,6 +1275,7 @@ def __len__(self) -> int:
return min(len(dataset) for dataset in self.data)

def _transform(self, index: int):

def to_list(x):
return list(x) if isinstance(x, (tuple, list)) else [x]

Expand Down
6 changes: 2 additions & 4 deletions monai/data/decathlon_datalist.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,11 @@


@overload
def _compute_path(base_dir: PathLike, element: PathLike, check_path: bool = False) -> str:
...
def _compute_path(base_dir: PathLike, element: PathLike, check_path: bool = False) -> str: ...


@overload
def _compute_path(base_dir: PathLike, element: list[PathLike], check_path: bool = False) -> list[str]:
...
def _compute_path(base_dir: PathLike, element: list[PathLike], check_path: bool = False) -> list[str]: ...


def _compute_path(base_dir, element, check_path=False):
Expand Down
Loading

0 comments on commit 1b97be1

Please sign in to comment.