Skip to content

Commit 4a2ff15

Browse files
MMelQingigony
andauthored
Release v0.5.0 (#376)
* Bump version: 0.4.0 → 0.5.0 Signed-off-by: M Q <[email protected]> * Update editable package detection method Signed-off-by: Gigon Bae <[email protected]> * Update module path detection method Signed-off-by: Gigon Bae <[email protected]> * Fix mypy type error Signed-off-by: Gigon Bae <[email protected]> Signed-off-by: M Q <[email protected]> Signed-off-by: Gigon Bae <[email protected]> Co-authored-by: Gigon Bae <[email protected]>
1 parent f7176c0 commit 4a2ff15

File tree

3 files changed

+39
-6
lines changed

3 files changed

+39
-6
lines changed

.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 0.4.0
2+
current_version = 0.5.0
33
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)((?P<release>a|b|rc)(?P<build>\d+))?
44
serialize =
55
{major}.{minor}.{patch}{release}{build}

monai/deploy/operators/dicom_seg_writer_operator.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,9 +306,11 @@ def create_dicom_seg(self, image: np.ndarray, dicom_series: DICOMSeries, output_
306306
if isinstance(k, str) and isinstance(v, str):
307307
try:
308308
if k in seg:
309-
seg.data_element(k).value = v
309+
data_element = seg.data_element(k)
310+
if data_element:
311+
data_element.value = v
310312
else:
311-
seg.update({k: v})
313+
seg.update({k: v}) # type: ignore
312314
except Exception as ex:
313315
# Best effort for now.
314316
logging.warning(f"Tag {k} was not written, due to {ex}")

monai/deploy/utils/importutil.py

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2021 MONAI Consortium
1+
# Copyright 2021-2022 MONAI Consortium
22
# Licensed under the Apache License, Version 2.0 (the "License");
33
# you may not use this file except in compliance with the License.
44
# You may obtain a copy of the License at
@@ -280,14 +280,45 @@ def is_dist_editable(project_name: str) -> bool:
280280
if not hasattr(dist, "egg_info"):
281281
return False
282282
egg_info = Path(dist.egg_info)
283-
if egg_info.is_dir() and egg_info.suffix == ".egg-info":
284-
return True
283+
if egg_info.is_dir():
284+
if egg_info.suffix == ".egg-info":
285+
return True
286+
elif egg_info.suffix == ".dist-info":
287+
if (egg_info / "direct_url.json").exists():
288+
import json
289+
290+
# Check direct_url.json for "editable": true
291+
# (https://packaging.python.org/en/latest/specifications/direct-url/)
292+
with open(egg_info / "direct_url.json", "r") as f:
293+
data = json.load(f)
294+
try:
295+
if data["dir_info"]["editable"]:
296+
return True
297+
except KeyError:
298+
pass
285299
return False
286300

287301

288302
def dist_module_path(project_name: str) -> str:
289303
distributions: Dict = {v.key: v for v in pkg_resources.working_set}
290304
dist: Any = distributions.get(project_name)
305+
if hasattr(dist, "egg_info"):
306+
egg_info = Path(dist.egg_info)
307+
if egg_info.is_dir() and egg_info.suffix == ".dist-info":
308+
if (egg_info / "direct_url.json").exists():
309+
import json
310+
311+
# Check direct_url.json for "url"
312+
# (https://packaging.python.org/en/latest/specifications/direct-url/)
313+
with open(egg_info / "direct_url.json", "r") as f:
314+
data = json.load(f)
315+
try:
316+
file_url = data["url"]
317+
if file_url.startswith("file://"):
318+
return str(file_url[7:])
319+
except KeyError:
320+
pass
321+
291322
if hasattr(dist, "module_path"):
292323
return str(dist.module_path)
293324
return ""

0 commit comments

Comments
 (0)