datamint 2.3.3__py3-none-any.whl → 2.3.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of datamint might be problematic. Click here for more details.

datamint/api/base_api.py CHANGED
@@ -121,11 +121,12 @@ class BaseApi:
121
121
  url = endpoint.lstrip('/') # Remove leading slash for httpx
122
122
 
123
123
  try:
124
- curl_command = self._generate_curl_command({"method": method,
125
- "url": url,
126
- "headers": self.client.headers,
127
- **kwargs}, fail_silently=True)
128
- logger.debug(f'Equivalent curl command: "{curl_command}"')
124
+ if logger.isEnabledFor(logging.DEBUG):
125
+ curl_command = self._generate_curl_command({"method": method,
126
+ "url": url,
127
+ "headers": self.client.headers,
128
+ **kwargs}, fail_silently=True)
129
+ logger.debug(f'Equivalent curl command: "{curl_command}"')
129
130
  response = self.client.request(method, url, **kwargs)
130
131
  response.raise_for_status()
131
132
  return response
@@ -1,8 +1,10 @@
1
- from typing import Sequence, Literal
1
+ from typing import Sequence, Literal, TYPE_CHECKING
2
2
  from ..entity_base_api import ApiConfig, CRUDEntityApi
3
3
  from datamint.entities.project import Project
4
- from datamint.entities.resource import Resource
5
4
  import httpx
5
+ from datamint.entities.resource import Resource
6
+ if TYPE_CHECKING:
7
+ from .resources_api import ResourcesApi
6
8
 
7
9
 
8
10
  class ProjectsApi(CRUDEntityApi[Project]):
@@ -10,14 +12,17 @@ class ProjectsApi(CRUDEntityApi[Project]):
10
12
 
11
13
  def __init__(self,
12
14
  config: ApiConfig,
13
- client: httpx.Client | None = None) -> None:
15
+ client: httpx.Client | None = None,
16
+ resources_api: 'ResourcesApi | None' = None) -> None:
14
17
  """Initialize the projects API handler.
15
18
 
16
19
  Args:
17
20
  config: API configuration containing base URL, API key, etc.
18
21
  client: Optional HTTP client instance. If None, a new one will be created.
19
22
  """
23
+ from .resources_api import ResourcesApi
20
24
  super().__init__(config, Project, 'projects', client)
25
+ self.resources_api = resources_api or ResourcesApi(config, client, projects_api=self)
21
26
 
22
27
  def get_project_resources(self, project: Project | str) -> list[Resource]:
23
28
  """Get resources associated with a specific project.
@@ -30,7 +35,7 @@ class ProjectsApi(CRUDEntityApi[Project]):
30
35
  """
31
36
  response = self._get_child_entities(project, 'resources')
32
37
  resources_data = response.json()
33
- resources = [Resource(**item) for item in resources_data]
38
+ resources = [self.resources_api._init_entity_obj(**item) for item in resources_data]
34
39
  return resources
35
40
 
36
41
  def create(self,
@@ -70,7 +70,7 @@ class ResourcesApi(CreatableEntityApi[Resource], DeletableEntityApi[Resource]):
70
70
  nest_asyncio.apply()
71
71
  self.annotations_api = AnnotationsApi(
72
72
  config, client, resources_api=self) if annotations_api is None else annotations_api
73
- self.projects_api = ProjectsApi(config, client) if projects_api is None else projects_api
73
+ self.projects_api = projects_api or ProjectsApi(config, client, resources_api=self)
74
74
 
75
75
  def get_list(self,
76
76
  status: Optional[ResourceStatus] = None,
@@ -433,8 +433,14 @@ class ResourcesApi(CreatableEntityApi[Resource], DeletableEntityApi[Resource]):
433
433
  )
434
434
  return rid
435
435
 
436
- tasks = [__upload_single_resource(f, segfiles, metadata_file)
437
- for f, segfiles, metadata_file in zip(files_path, segmentation_files, metadata_files)]
436
+ try:
437
+ tasks = [__upload_single_resource(f, segfiles, metadata_file)
438
+ for f, segfiles, metadata_file in zip(files_path, segmentation_files, metadata_files)]
439
+ except ValueError:
440
+ msg = f"Error preparing upload tasks. Try `assemble_dicom=False`."
441
+ _LOGGER.error(msg)
442
+ _USER_LOGGER.error(msg)
443
+ raise
438
444
  return await asyncio.gather(*tasks, return_exceptions=on_error == 'skip')
439
445
 
440
446
  def upload_resources(self,
@@ -574,6 +574,8 @@ def _parse_args() -> tuple[Any, list[str], Optional[list[dict]], Optional[list[s
574
574
  help='Automatically detect and include JSON metadata files with the same base name as NIFTI files')
575
575
  parser.add_argument('--no-auto-detect-json', dest='auto_detect_json', action='store_false',
576
576
  help='Disable automatic detection of JSON metadata files (default behavior)')
577
+ parser.add_argument('--no-assemble-dicoms', dest='assemble_dicoms', action='store_false', default=True,
578
+ help='Do not assemble DICOM files into series (default: assemble them)')
577
579
  parser.add_argument('--version', action='version', version=f'%(prog)s {datamint_version}')
578
580
  parser.add_argument('--verbose', action='store_true', help='Print debug messages', default=False)
579
581
  args = parser.parse_args()
@@ -797,7 +799,7 @@ def main():
797
799
  publish_to=args.project,
798
800
  segmentation_files=segfiles,
799
801
  transpose_segmentation=args.transpose_segmentation,
800
- assemble_dicoms=True,
802
+ assemble_dicoms=args.assemble_dicoms,
801
803
  metadata=metadata_files,
802
804
  progress_bar=True
803
805
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: datamint
3
- Version: 2.3.3
3
+ Version: 2.3.4
4
4
  Summary: A library for interacting with the Datamint API, designed for efficient data management, processing and Deep Learning workflows.
5
5
  Requires-Python: >=3.10
6
6
  Classifier: Programming Language :: Python :: 3
@@ -1,6 +1,6 @@
1
1
  datamint/__init__.py,sha256=ucsnxrYClh6pdy7psRJXWam_9rjAQB4NXzvy7xLovmo,824
2
2
  datamint/api/__init__.py,sha256=7QYkmDBXbKh8-zchV7k6Lpolaw6h-IK6ezfXROIWh2A,43
3
- datamint/api/base_api.py,sha256=UmNEgcFt1czkqyVCM3t5P9UvA1F9AEZITPqdakojvJs,18810
3
+ datamint/api/base_api.py,sha256=RUtiTMy0h6LV-nXKfRdQ9FDJzwLf6k2RCCMytacB2AU,18881
4
4
  datamint/api/client.py,sha256=ndKSj2QnveRNOtaQhE9qM4tCGtgrTxfInDy9FhdReCo,3922
5
5
  datamint/api/dto/__init__.py,sha256=fUi901Zs-q5XHyWwZ4dMi2fEO8-CUEVEdYbpd17lahc,416
6
6
  datamint/api/endpoints/__init__.py,sha256=wi4liAb5-wOohwyzKUD6TxHGeZmUPaZerFUGa2IUju4,529
@@ -9,8 +9,8 @@ datamint/api/endpoints/annotationsets_api.py,sha256=NIsPIjGGptiUBxHft-EhOMRG-DsQ
9
9
  datamint/api/endpoints/channels_api.py,sha256=oQqxSw9DJzAqtVQI7-tc1llTdnsm-URx8jwtXNXnhio,867
10
10
  datamint/api/endpoints/datasetsinfo_api.py,sha256=WdzrUzK63w9gvAP6U--P65FbD-3X-jm9TPCcYnRNjas,597
11
11
  datamint/api/endpoints/models_api.py,sha256=tbVuajc-mCsIp5AKSCoq3uQRDWgKnJaIA6tf_ck8-XY,1502
12
- datamint/api/endpoints/projects_api.py,sha256=C5IqKXaYRrg5LDBjIRSo4NBCvbN2619X3SSgKqGe8pc,7929
13
- datamint/api/endpoints/resources_api.py,sha256=Ez-mGYElCpwHZ8T8NlqXH188mCFBZGfs8b320xa43tc,50142
12
+ datamint/api/endpoints/projects_api.py,sha256=Pfr3fEiMw_aRzoGtcVXHJQ68leVoPAghw23L4ZIglno,8237
13
+ datamint/api/endpoints/resources_api.py,sha256=nEPDT5EjSw7-vXahR2sfvMeQDClE4Q71qYFUCABqPq8,50372
14
14
  datamint/api/endpoints/users_api.py,sha256=pnkuTZ1B9Y0FtwwvXO8J64e02RSkRxnBmTl9UGSuC5I,1186
15
15
  datamint/api/entity_base_api.py,sha256=-8SIt4M8P9G2b8SQznuWpFuFE8zEQjQxkRkw0s_w0Y4,11692
16
16
  datamint/apihandler/annotation_api_handler.py,sha256=W3vV4z3BqX1OQe1r7zr8dI-IVu4zUDxED4QttdiWV-E,57098
@@ -22,7 +22,7 @@ datamint/apihandler/exp_api_handler.py,sha256=hFUgUgBc5rL7odK7gTW3MnrvMY1pVfJUpU
22
22
  datamint/apihandler/root_api_handler.py,sha256=jBof_XPTeq4o41CW-l-I5GHQKVa76kaX75RovS_qAM4,63384
23
23
  datamint/client_cmd_tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
24
24
  datamint/client_cmd_tools/datamint_config.py,sha256=MpR5UHv_xpElOOYyEESBkDg2n3JjP_PNLI2jqmZgYQ8,16222
25
- datamint/client_cmd_tools/datamint_upload.py,sha256=rZEqBRZZDBFSlwMvIg_DbipqgBtQD31v7DC1C6tysqA,36058
25
+ datamint/client_cmd_tools/datamint_upload.py,sha256=zGNEylfS2P5XUyzBz44ruHjoyAoKZFwZbw4wRVANEL8,36279
26
26
  datamint/configs.py,sha256=ArVD5QxuohLcM6NB0dMxcEfrD1-x5lPRDLcBdY8jhMU,1625
27
27
  datamint/dataset/__init__.py,sha256=4PlUKSvVhdfQvvuq8jQXrkdqnot-iTTizM3aM1vgSwg,47
28
28
  datamint/dataset/annotation.py,sha256=qN1IMjdfLD2ceQ6va3l76jOXA8Vb_c-eBk1oWQu6hW0,7994
@@ -48,7 +48,7 @@ datamint/types.py,sha256=2OaY5QJvQIJKxyMNJYzxBksKCa9ZS2gb_ayJrByvu2Y,410
48
48
  datamint/utils/logging_utils.py,sha256=9pRoaPrWu2jOdDCiAoUsjEdP5ZwaealWL3hjUqFvx9g,4022
49
49
  datamint/utils/torchmetrics.py,sha256=lwU0nOtsSWfebyp7dvjlAggaqXtj5ohSEUXOg3L0hJE,2837
50
50
  datamint/utils/visualization.py,sha256=yaUVAOHar59VrGUjpAWv5eVvQSfztFG0eP9p5Vt3l-M,4470
51
- datamint-2.3.3.dist-info/METADATA,sha256=Cl4QTN2lWp65r0Sot2NP-n5h0A-1B-PqH0l_gT94XUY,4262
52
- datamint-2.3.3.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
53
- datamint-2.3.3.dist-info/entry_points.txt,sha256=mn5H6jPjO-rY0W0CAZ6Z_KKWhMLvyVaSpoqk77jlTI4,145
54
- datamint-2.3.3.dist-info/RECORD,,
51
+ datamint-2.3.4.dist-info/METADATA,sha256=Kz2iS6lI3cmVlpCA-d4AMrTfr77CcuXpO7kt65LoZHk,4262
52
+ datamint-2.3.4.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
53
+ datamint-2.3.4.dist-info/entry_points.txt,sha256=mn5H6jPjO-rY0W0CAZ6Z_KKWhMLvyVaSpoqk77jlTI4,145
54
+ datamint-2.3.4.dist-info/RECORD,,