Skip to content

Commit

Permalink
Merge branch 'main' into sw_fastedit
Browse files Browse the repository at this point in the history
  • Loading branch information
diazandr3s authored Jul 7, 2024
2 parents b592a89 + fc9b567 commit 415c551
Show file tree
Hide file tree
Showing 12 changed files with 56 additions and 34 deletions.
18 changes: 10 additions & 8 deletions .github/workflows/blossom-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,16 @@ jobs:
args: ${{ env.args }}

# This job only runs for pull request comments
if: contains('\
Nic-Ma,\
SachidanandAlle,\
diazandr3s,\
tangy5,\
wyli,\
YanxuanLiu,\
', format('{0},', github.actor)) && github.event.comment.body == '/build'
if: |
github.event.comment.body == '/build' &&
(
github.actor == 'Nic-Ma' ||
github.actor == 'SachidanandAlle' ||
github.actor == 'diazandr3s' ||
github.actor == 'tangy5' ||
github.actor == 'wyli' ||
github.actor == 'YanxuanLiu'
)
steps:
- name: Check if comment is issued by authorized person
run: blossom-ci
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# please run `./runtests.sh --clean && DOCKER_BUILDKIT=1 docker build -t projectmonai/monailabel:latest .`
# to use different version of MONAI pass `--build-arg MONAI_IMAGE=...`

ARG MONAI_IMAGE=projectmonai/monai:1.3.0
ARG MONAI_IMAGE=projectmonai/monai:1.3.1
ARG NODE_IMAGE=node:slim

FROM ${NODE_IMAGE} as ohifbuild
Expand Down
43 changes: 31 additions & 12 deletions monailabel/datastore/dsa.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def get_label_by_image_id(self, image_id: str, tag: str) -> str:
def get_annotations_by_image_id(self, image_id: str) -> Dict[str, Dict[str, List]]:
image_id, name = self._name_to_id(image_id)

data = self.gc.get("annotation", parameters={"limit": 0})
data = self.gc.get(f"annotation/item/{image_id}", parameters={"limit": 0})
result: Dict[str, Dict[str, List]] = {}

# TODO(avirodov): probably can request only annotation for a given image_id, need to check how.
Expand Down Expand Up @@ -136,26 +136,40 @@ def get_image(self, image_id: str, params=None) -> Any:
def _name_to_id(self, name):
folders = self.folders if self.folders else self._get_all_folders()
for folder in folders:
# First check if the name is directly present
data = self.gc.get("item", parameters={"folderId": folder, "name": name, "limit": 0})
for d in data:
if d.get("largeImage"):
return d["_id"], d["name"]
# next check if the name is present in a stem form
data = self.gc.get("item", parameters={"folderId": folder, "limit": 0})
for d in data:
if d.get("largeImage") and d["name"] == name or Path(d["name"]).stem == name:
return d["_id"], d["name"]
return name
# Next check if the name is anywhere in the system
data = self.gc.get("item", parameters={"text": f'"{name}"' if '"' not in name else name, "limit": 0})
for d in data:
if d.get("largeImage") and d["name"] == name or Path(d["name"]).stem == name:
return d["_id"], d["name"]
# If we fail to find the item, the best we can do is return the name
return name, name

def get_image_uri(self, image_id: str) -> str:
try:
name = self.get_image_info(image_id)["name"]
info = self.get_image_info(image_id)
name = info["name"]
file_id = info.get("largeImage", {}).get("fileId")
except girder_client.HttpError:
image_id, name = self._name_to_id(image_id)
file_id = None

if self.asset_store_path:
data = self.gc.get(f"item/{image_id}/files", parameters={"limit": 0})
assets = [d["assetstoreId"] for d in data]
for asset in assets:
files = self.gc.get(f"assetstore/{asset}/files", parameters={"limit": 0})
for f in files:
if f["itemId"] == image_id:
return str(os.path.join(self.asset_store_path, f["path"]))
if file_id is None:
data = self.gc.get(f"item/{image_id}/files", parameters={"limit": 0})
file_id = data[0]["_id"]
f = self.gc.get(f"resource/{file_id}?type=file")
if "path" in f and os.path.exists(os.path.join(self.asset_store_path, f["path"])):
return str(os.path.join(self.asset_store_path, f["path"]))
else:
cached = os.path.join(self.cache_path, name)
if os.path.exists(cached):
Expand Down Expand Up @@ -243,9 +257,14 @@ def get_dataset_archive(self, limit_cases: Optional[int]) -> str:
raise NotImplementedError

def status(self) -> Dict[str, Any]:
# This is a very costly query, disable it for now
# return {
# "total": len(self.list_images()),
# "completed": len(self.get_labeled_images()),
# }
return {
"total": len(self.list_images()),
"completed": len(self.get_labeled_images()),
"total": 0,
"completed": 0,
}

def json(self):
Expand Down
5 changes: 3 additions & 2 deletions monailabel/endpoints/user/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@
import logging
from typing import List, Sequence, Union

import jwt
import requests
from cachetools import cached
from fastapi import Depends, HTTPException, Security, status
from fastapi.security import OAuth2PasswordBearer
from jose import JWTError, jwt
from jwt import InvalidTokenError
from passlib.context import CryptContext
from pydantic import BaseModel

Expand Down Expand Up @@ -114,7 +115,7 @@ async def get_current_user(token: str = Depends(oauth2_scheme) if settings.MONAI
)
try:
return from_token(token)
except JWTError as e:
except InvalidTokenError as e:
logger.error(e)
raise credentials_exception

Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

monai[nibabel, skimage, pillow, tensorboard, gdown, ignite, torchvision, itk, tqdm, lmdb, psutil, openslide, fire, mlflow]>=1.3.0
monai[nibabel, skimage, pillow, tensorboard, gdown, ignite, torchvision, itk, tqdm, lmdb, psutil, openslide, fire, mlflow]>=1.3.1
uvicorn==0.29.0
pydantic==2.7.0
pydantic-settings==2.2.1
Expand All @@ -35,7 +35,7 @@ einops==0.7.0
pyyaml==6.0.1
filelock==3.11.0
passlib==1.7.4
python-jose[cryptography]==3.3.0
pyjwt==2.8.0
bcrypt==4.1.2
shapely==2.0.4
requests==2.31.0
Expand Down
2 changes: 1 addition & 1 deletion sample-apps/endoscopy/lib/configs/inbody.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def init(self, name: str, model_dir: str, conf: Dict[str, str], planner: Any, **
super().init(name, model_dir, conf, planner, **kwargs)

bundle_name = "endoscopic_inbody_classification"
version = conf.get("inbody", "0.4.4")
version = conf.get("inbody", "0.4.8")
zoo_source = conf.get("zoo_source", settings.MONAI_ZOO_SOURCE)

self.bundle_path = os.path.join(self.model_dir, bundle_name)
Expand Down
2 changes: 1 addition & 1 deletion sample-apps/endoscopy/lib/configs/tooltracking.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def init(self, name: str, model_dir: str, conf: Dict[str, str], planner: Any, **
super().init(name, model_dir, conf, planner, **kwargs)

bundle_name = "endoscopic_tool_segmentation"
version = conf.get("tooltracking", "0.5.5")
version = conf.get("tooltracking", "0.5.9")
zoo_source = conf.get("zoo_source", settings.MONAI_ZOO_SOURCE)

self.bundle_path = os.path.join(self.model_dir, bundle_name)
Expand Down
4 changes: 2 additions & 2 deletions sample-apps/endoscopy/update_cvat_model.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ fi
if [ $FUNC_NAME == "deepedit" ];then
MODEL_PATH="$APP_ROOT/model/$FUNC_NAME.pt"
# Replace prior pretrained model with lastest model as current pre-trained model
MODEL_CONTAINER="/opt/conda/monailabel/sample-apps/endoscopy/model/pretrained_$FUNC_NAME.pt" # default model path at function container
MODEL_CONTAINER="/usr/local/monailabel/sample-apps/endoscopy/model/pretrained_$FUNC_NAME.pt" # default model path at function container
else
# if bundle is used, get bundle name and fetch the model
BUNDLE_NAME=${BUNDLENAMES[$FUNC_NAME]}
MODEL_PATH="$APP_ROOT/model/$BUNDLE_NAME/models/model.pt"
# Update to bundle nuclio container
MODEL_CONTAINER="/opt/conda/monailabel/sample-apps/endoscopy/model/$BUNDLE_NAME/models/model.pt" # default model path at function container
MODEL_CONTAINER="/usr/local/monailabel/sample-apps/endoscopy/model/$BUNDLE_NAME/models/model.pt" # default model path at function container
fi

# Check if latest model checkpoint is done and saved.
Expand Down
2 changes: 1 addition & 1 deletion sample-apps/pathology/lib/configs/classification_nuclei.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def init(self, name: str, model_dir: str, conf: Dict[str, str], planner: Any, **

bundle_name = "pathology_nuclei_classification"
zoo_source = conf.get("zoo_source", settings.MONAI_ZOO_SOURCE)
version = conf.get("classification_nuclei", "0.1.4")
version = conf.get("classification_nuclei", "0.1.7")

self.bundle_path = os.path.join(self.model_dir, bundle_name)
if not os.path.exists(self.bundle_path):
Expand Down
2 changes: 1 addition & 1 deletion sample-apps/pathology/lib/configs/hovernet_nuclei.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def init(self, name: str, model_dir: str, conf: Dict[str, str], planner: Any, **

bundle_name = "pathology_nuclei_segmentation_classification"
zoo_source = conf.get("zoo_source", settings.MONAI_ZOO_SOURCE)
version = conf.get("hovernet_nuclei", "0.2.1")
version = conf.get("hovernet_nuclei", "0.2.4")

self.bundle_path = os.path.join(self.model_dir, bundle_name)
if not os.path.exists(self.bundle_path):
Expand Down
2 changes: 1 addition & 1 deletion sample-apps/pathology/lib/configs/nuclick.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def init(self, name: str, model_dir: str, conf: Dict[str, str], planner: Any, **

bundle_name = "pathology_nuclick_annotation"
zoo_source = conf.get("zoo_source", settings.MONAI_ZOO_SOURCE)
version = conf.get("nuclick", "0.1.4")
version = conf.get("nuclick", "0.1.9")

self.bundle_path = os.path.join(self.model_dir, bundle_name)
if not os.path.exists(self.bundle_path):
Expand Down
4 changes: 2 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ setup_requires =
torch
ninja
install_requires =
monai[nibabel, skimage, pillow, tensorboard, gdown, ignite, torchvision, itk, tqdm, lmdb, psutil, openslide, fire, mlflow]>=1.3.0
monai[nibabel, skimage, pillow, tensorboard, gdown, ignite, torchvision, itk, tqdm, lmdb, psutil, openslide, fire, mlflow]>=1.3.1
uvicorn==0.29.0
pydantic==2.7.0
pydantic-settings==2.2.1
Expand All @@ -61,7 +61,7 @@ install_requires =
pyyaml==6.0.1
filelock==3.11.0
passlib==1.7.4
python-jose[cryptography]==3.3.0
pyjwt==2.8.0
bcrypt==4.1.2
shapely==2.0.4
requests==2.31.0
Expand Down

0 comments on commit 415c551

Please sign in to comment.