Skip to content
Draft
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
6 changes: 3 additions & 3 deletions .github/workflows/pythonapp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
strategy:
matrix:
os: [windows-latest, ubuntu-latest]
python-version: ["3.9", "3.10", "3.11", "3.12"]
python-version: ["3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v6
- name: Set up Python
Expand All @@ -54,7 +54,7 @@ jobs:
MONAI_ZOO_AUTH_TOKEN: ${{ github.token }}
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]
python-version: ["3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v6
- name: Set up Python
Expand Down Expand Up @@ -88,7 +88,7 @@ jobs:
MONAI_ZOO_AUTH_TOKEN: ${{ github.token }}
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]
python-version: ["3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v6
with:
Expand Down
3 changes: 2 additions & 1 deletion monailabel/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import os
from distutils.util import strtobool
from importlib.metadata import distributions
from typing import Any, Dict, List, Optional

from pydantic import AnyHttpUrl
from pydantic_settings import BaseSettings, SettingsConfigDict

from monailabel.utils.others.strtobool import strtobool


def is_package_installed(name):
return name in (x.metadata.get("Name") for x in distributions() if x.metadata is not None)
Expand Down
2 changes: 1 addition & 1 deletion monailabel/utils/others/class_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
import logging
import os
import sys
from distutils.util import strtobool
from typing import List

from monailabel.interfaces.exception import MONAILabelError, MONAILabelException
from monailabel.utils.others.strtobool import strtobool

logger = logging.getLogger(__name__)

Expand Down
6 changes: 1 addition & 5 deletions monailabel/utils/others/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import distutils.util
import hashlib
import json
import logging
Expand All @@ -31,6 +30,7 @@

from monailabel.config import settings
from monailabel.utils.others.modelzoo_list import MAINTAINED_BUNDLES
from monailabel.utils.others.strtobool import strtobool # noqa: F401

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -241,10 +241,6 @@ def _list_files(d, ext):
]


def strtobool(s):
return False if s is None else s if isinstance(s, bool) else bool(distutils.util.strtobool(s))


def is_openslide_supported(name):
ext = file_ext(name)
supported_ext = (".bif", ".mrxs", ".ndpi", ".scn", ".svs", ".svslide", ".tif", ".tiff", ".vms", ".vmu")
Expand Down
38 changes: 38 additions & 0 deletions monailabel/utils/others/strtobool.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Copyright (c) MONAI Consortium
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Standalone utility function for string to boolean conversion.

This module exists separately to avoid circular import dependencies.
"""


def strtobool(s):
"""Convert a string representation of truth to true or false.

True values are 'y', 'yes', 't', 'true', 'on', and '1'; false values
are 'n', 'no', 'f', 'false', 'off', and '0'. Returns the input if
already a bool. Returns False if None.
"""
if s is None:
return False
if isinstance(s, bool):
return s
if not isinstance(s, str):
raise TypeError(f"strtobool expects a string or bool, got {type(s).__name__}: {s!r}")

val = s.lower()
if val in ('y', 'yes', 't', 'true', 'on', '1'):
return True
elif val in ('n', 'no', 'f', 'false', 'off', '0'):
return False
else:
raise ValueError(f"invalid truth value {s!r}")
2 changes: 1 addition & 1 deletion plugins/cvat/endoscopy/deepedit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ metadata:

spec:
description: A pre-trained DeepEdit model for interactive model for Endoscopy
runtime: 'python:3.8'
runtime: 'python:3.10'
handler: interactor:handler
eventTimeout: 30s

Expand Down
2 changes: 1 addition & 1 deletion plugins/cvat/endoscopy/inbody.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ metadata:

spec:
description: A pre-trained classification model for Endoscopy to flag if image follows InBody or OutBody
runtime: 'python:3.8'
runtime: 'python:3.10'
handler: detector:handler
eventTimeout: 30s

Expand Down
2 changes: 1 addition & 1 deletion plugins/cvat/endoscopy/tooltracking.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ metadata:

spec:
description: A pre-trained tool tracking model for Endoscopy
runtime: 'python:3.8'
runtime: 'python:3.10'
handler: detector:handler
eventTimeout: 30s

Expand Down
2 changes: 1 addition & 1 deletion plugins/cvat/pathology/deepedit_nuclei.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ metadata:

spec:
description: A pre-trained interaction/deepedit model for Pathology
runtime: 'python:3.8'
runtime: 'python:3.10'
handler: detector:handler
eventTimeout: 30s

Expand Down
2 changes: 1 addition & 1 deletion plugins/cvat/pathology/nuclick.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ metadata:

spec:
description: A pre-trained NuClick model for interactive cell segmentation for Pathology
runtime: 'python:3.8'
runtime: 'python:3.10'
handler: interactor:handler
eventTimeout: 30s

Expand Down
2 changes: 1 addition & 1 deletion plugins/cvat/pathology/segmentation_nuclei.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ metadata:

spec:
description: A pre-trained semantic segmentation model for Pathology
runtime: 'python:3.8'
runtime: 'python:3.10'
handler: detector:handler
eventTimeout: 30s

Expand Down
2 changes: 1 addition & 1 deletion plugins/cvat/sam2/interactor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ metadata:

spec:
description: A pre-trained SAM2 model for interactive model
runtime: 'python:3.8'
runtime: 'python:3.10'
handler: interactor:handler
eventTimeout: 30s

Expand Down
2 changes: 1 addition & 1 deletion plugins/cvat/sam2/tracker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ metadata:

spec:
description: A pre-trained SAM2 model for tracking model
runtime: 'python:3.8'
runtime: 'python:3.10'
handler: tracker:handler
eventTimeout: 30s

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ requires = [

[tool.black]
line-length = 120
target-version = ['py36', 'py37', 'py38']
target-version = ['py310', 'py311', 'py312']
include = '\.pyi?$'
exclude = '''
(
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ urllib3==2.6.0
scikit-learn
scipy
google-auth==2.29.0
SimpleITK>=2.2.0
SAM-2 @ git+https://github.com/facebookresearch/sam2.git@c2ec8e14a185632b0a5d8b161928ceb50197eddc ; python_version >= '3.10'
#sam2>=0.4.1; python_version >= '3.10'

Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ install_requires =
scikit-learn
scipy
google-auth>=2.29.0
SimpleITK>=2.2.0
sam2>=0.4.1; python_version >= '3.10'
#SAM-2 @ git+https://github.com/facebookresearch/sam2.git@c2ec8e14a185632b0a5d8b161928ceb50197eddc ; python_version >= '3.10'

Expand Down
19 changes: 18 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,30 @@
import os
import platform
import subprocess
from distutils.util import strtobool

from setuptools import find_packages, setup

import versioneer


def strtobool(val):
"""Convert a string representation of truth to true (1) or false (0).

True values are 'y', 'yes', 't', 'true', 'on', and '1'; false values
are 'n', 'no', 'f', 'false', 'off', and '0'. Raises ValueError if
'val' is anything else.
"""
if not isinstance(val, str):
raise TypeError(f"strtobool expects a string, got {type(val).__name__}")
val = val.lower()
if val in ('y', 'yes', 't', 'true', 'on', '1'):
return 1
elif val in ('n', 'no', 'f', 'false', 'off', '0'):
return 0
else:
raise ValueError(f"invalid truth value {val!r}")


def recursive_files(directory, prefix):
paths = []
for path, _, filenames in os.walk(directory):
Expand Down
Loading