Skip to content

Commit

Permalink
better logs
Browse files Browse the repository at this point in the history
  • Loading branch information
almazgimaev committed Nov 13, 2023
1 parent f0f8429 commit 5e25b66
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ def import_dicom_volumes(
nrrd_paths = sly.volume.inspect_nrrd_series(root_dir=project_dir)

if len(series_infos) == 0 and len(nrrd_paths) == 0:
sly.logger.warn("No volumes were found. Please, check your input directory.")
msg = "No DICOM volumes were found. Please, check your input directory."
description = f"Supported formats: {g.ALLOWED_VOLUME_EXTENSIONS} (in archive or directory)."
sly.logger.warn(f"{msg} {description}")
api.task.set_output_error(task_id, msg, description)
else:
# DICOM
for serie_id, files in series_infos.items():
Expand Down Expand Up @@ -79,6 +82,7 @@ def import_dicom_volumes(
g.api.volume.upload_nrrd_serie_path(
dataset_id=dataset.id, name=name, path=nrrd_path, log_progress=True
)
api.task.set_output_project(task_id, project.id, project.name)

if g.REMOVE_SOURCE and not g.IS_ON_AGENT:
if g.INPUT_DIR is not None:
Expand All @@ -89,7 +93,6 @@ def import_dicom_volumes(
source_dir_name = path_to_remove.lstrip("/").rstrip("/")
sly.logger.info(msg=f"Source directory: '{source_dir_name}' was successfully removed.")

api.task.set_output_project(task_id, project.id, project.name)
g.my_app.stop()


Expand Down
2 changes: 1 addition & 1 deletion src/sly_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def get_project_dir(path: str) -> str:
def _volumes_exists(path: str) -> bool:
"""Returns True if path contains volumes."""
listdir = sly.fs.list_files(path)
if len([f for f in listdir if sly.volume.get_extension(path=f) is not None]) > 0:
if len([f for f in listdir if sly.volume.has_valid_ext(f)]) > 0:
return True
return False

Expand Down
1 change: 1 addition & 0 deletions src/sly_globals.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from dotenv import load_dotenv
from supervisely.app.v1.app_service import AppService
from supervisely.io.fs import mkdir
from supervisely.volume.volume import ALLOWED_VOLUME_EXTENSIONS

if sly.is_development():
load_dotenv("local.env")
Expand Down

0 comments on commit 5e25b66

Please sign in to comment.