Skip to content

Commit b9ec17a

Browse files
committed
Prettier message on project not found when running cmd-line
1 parent 3981504 commit b9ec17a

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

datamint/client_cmd_tools/datamint_upload.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from datamint.exceptions import DatamintException
1+
from datamint.exceptions import DatamintException, ItemNotFoundError
22
import argparse
33
# from datamint.apihandler.api_handler import APIHandler
44
from datamint import Api
@@ -806,7 +806,6 @@ def main():
806806

807807
has_a_dicom_file = any(is_dicom(f) for f in files_path)
808808

809-
810809
try:
811810
results = api.resources.upload_resources(channel=args.channel,
812811
files_path=files_path,
@@ -827,6 +826,16 @@ def main():
827826
except pydicom.errors.InvalidDicomError as e:
828827
_USER_LOGGER.error(f'❌ Invalid DICOM file: {e}')
829828
return
829+
except ItemNotFoundError as e:
830+
if e.item_type == 'Project' and isinstance(e.params, dict) and 'name_or_id' in e.params:
831+
available_projects = api.projects.get_all()
832+
project_names = [proj.name for proj in available_projects]
833+
_USER_LOGGER.error(
834+
f'❌ Project "{e.params["name_or_id"]}" not found. Available projects: {project_names}')
835+
else:
836+
_USER_LOGGER.error(f'❌ {e}')
837+
return
838+
830839
_USER_LOGGER.info('Upload finished!')
831840
_LOGGER.debug(f"Number of results: {len(results)}")
832841

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[project]
22
name = "datamint"
33
description = "A library for interacting with the Datamint API, designed for efficient data management, processing and Deep Learning workflows."
4-
version = "2.13.0"
4+
version = "2.13.1"
55
dynamic = ["dependencies"]
66
requires-python = ">=3.10"
77
readme = "README.md"

0 commit comments

Comments
 (0)