datamint 2.3.3__tar.gz → 2.3.5__tar.gz

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.

Files changed (53) hide show
  1. {datamint-2.3.3 → datamint-2.3.5}/PKG-INFO +2 -2
  2. {datamint-2.3.3 → datamint-2.3.5}/datamint/api/base_api.py +6 -5
  3. {datamint-2.3.3 → datamint-2.3.5}/datamint/api/endpoints/projects_api.py +9 -4
  4. {datamint-2.3.3 → datamint-2.3.5}/datamint/api/endpoints/resources_api.py +17 -6
  5. {datamint-2.3.3 → datamint-2.3.5}/datamint/client_cmd_tools/datamint_upload.py +3 -1
  6. {datamint-2.3.3 → datamint-2.3.5}/pyproject.toml +2 -2
  7. {datamint-2.3.3 → datamint-2.3.5}/README.md +0 -0
  8. {datamint-2.3.3 → datamint-2.3.5}/datamint/__init__.py +0 -0
  9. {datamint-2.3.3 → datamint-2.3.5}/datamint/api/__init__.py +0 -0
  10. {datamint-2.3.3 → datamint-2.3.5}/datamint/api/client.py +0 -0
  11. {datamint-2.3.3 → datamint-2.3.5}/datamint/api/dto/__init__.py +0 -0
  12. {datamint-2.3.3 → datamint-2.3.5}/datamint/api/endpoints/__init__.py +0 -0
  13. {datamint-2.3.3 → datamint-2.3.5}/datamint/api/endpoints/annotations_api.py +0 -0
  14. {datamint-2.3.3 → datamint-2.3.5}/datamint/api/endpoints/annotationsets_api.py +0 -0
  15. {datamint-2.3.3 → datamint-2.3.5}/datamint/api/endpoints/channels_api.py +0 -0
  16. {datamint-2.3.3 → datamint-2.3.5}/datamint/api/endpoints/datasetsinfo_api.py +0 -0
  17. {datamint-2.3.3 → datamint-2.3.5}/datamint/api/endpoints/models_api.py +0 -0
  18. {datamint-2.3.3 → datamint-2.3.5}/datamint/api/endpoints/users_api.py +0 -0
  19. {datamint-2.3.3 → datamint-2.3.5}/datamint/api/entity_base_api.py +0 -0
  20. {datamint-2.3.3 → datamint-2.3.5}/datamint/apihandler/annotation_api_handler.py +0 -0
  21. {datamint-2.3.3 → datamint-2.3.5}/datamint/apihandler/api_handler.py +0 -0
  22. {datamint-2.3.3 → datamint-2.3.5}/datamint/apihandler/base_api_handler.py +0 -0
  23. {datamint-2.3.3 → datamint-2.3.5}/datamint/apihandler/dto/__init__.py +0 -0
  24. {datamint-2.3.3 → datamint-2.3.5}/datamint/apihandler/dto/annotation_dto.py +0 -0
  25. {datamint-2.3.3 → datamint-2.3.5}/datamint/apihandler/exp_api_handler.py +0 -0
  26. {datamint-2.3.3 → datamint-2.3.5}/datamint/apihandler/root_api_handler.py +0 -0
  27. {datamint-2.3.3 → datamint-2.3.5}/datamint/client_cmd_tools/__init__.py +0 -0
  28. {datamint-2.3.3 → datamint-2.3.5}/datamint/client_cmd_tools/datamint_config.py +0 -0
  29. {datamint-2.3.3 → datamint-2.3.5}/datamint/configs.py +0 -0
  30. {datamint-2.3.3 → datamint-2.3.5}/datamint/dataset/__init__.py +0 -0
  31. {datamint-2.3.3 → datamint-2.3.5}/datamint/dataset/annotation.py +0 -0
  32. {datamint-2.3.3 → datamint-2.3.5}/datamint/dataset/base_dataset.py +0 -0
  33. {datamint-2.3.3 → datamint-2.3.5}/datamint/dataset/dataset.py +0 -0
  34. {datamint-2.3.3 → datamint-2.3.5}/datamint/entities/__init__.py +0 -0
  35. {datamint-2.3.3 → datamint-2.3.5}/datamint/entities/annotation.py +0 -0
  36. {datamint-2.3.3 → datamint-2.3.5}/datamint/entities/base_entity.py +0 -0
  37. {datamint-2.3.3 → datamint-2.3.5}/datamint/entities/cache_manager.py +0 -0
  38. {datamint-2.3.3 → datamint-2.3.5}/datamint/entities/channel.py +0 -0
  39. {datamint-2.3.3 → datamint-2.3.5}/datamint/entities/datasetinfo.py +0 -0
  40. {datamint-2.3.3 → datamint-2.3.5}/datamint/entities/project.py +0 -0
  41. {datamint-2.3.3 → datamint-2.3.5}/datamint/entities/resource.py +0 -0
  42. {datamint-2.3.3 → datamint-2.3.5}/datamint/entities/user.py +0 -0
  43. {datamint-2.3.3 → datamint-2.3.5}/datamint/examples/__init__.py +0 -0
  44. {datamint-2.3.3 → datamint-2.3.5}/datamint/examples/example_projects.py +0 -0
  45. {datamint-2.3.3 → datamint-2.3.5}/datamint/exceptions.py +0 -0
  46. {datamint-2.3.3 → datamint-2.3.5}/datamint/experiment/__init__.py +0 -0
  47. {datamint-2.3.3 → datamint-2.3.5}/datamint/experiment/_patcher.py +0 -0
  48. {datamint-2.3.3 → datamint-2.3.5}/datamint/experiment/experiment.py +0 -0
  49. {datamint-2.3.3 → datamint-2.3.5}/datamint/logging.yaml +0 -0
  50. {datamint-2.3.3 → datamint-2.3.5}/datamint/types.py +0 -0
  51. {datamint-2.3.3 → datamint-2.3.5}/datamint/utils/logging_utils.py +0 -0
  52. {datamint-2.3.3 → datamint-2.3.5}/datamint/utils/torchmetrics.py +0 -0
  53. {datamint-2.3.3 → datamint-2.3.5}/datamint/utils/visualization.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: datamint
3
- Version: 2.3.3
3
+ Version: 2.3.5
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
@@ -22,7 +22,7 @@ Requires-Dist: humanize (>=4.0.0,<5.0.0)
22
22
  Requires-Dist: lazy-loader (>=0.3.0)
23
23
  Requires-Dist: lightning
24
24
  Requires-Dist: matplotlib
25
- Requires-Dist: medimgkit (>=0.7.2)
25
+ Requires-Dist: medimgkit (>=0.7.3)
26
26
  Requires-Dist: nest-asyncio (>=1.0.0,<2.0.0)
27
27
  Requires-Dist: nibabel (>=4.0.0)
28
28
  Requires-Dist: numpy
@@ -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,
@@ -263,8 +263,8 @@ class ResourcesApi(CreatableEntityApi[Resource], DeletableEntityApi[Resource]):
263
263
  filename = new_filename
264
264
 
265
265
  is_a_dicom_file = None
266
- if mimetype is None:
267
- mimetype_list, ext = guess_typez(file_path, use_magic=True)
266
+ if not mimetype:
267
+ mimetype_list, ext = guess_typez(file_path, use_magic=False)
268
268
  for mime in mimetype_list:
269
269
  if mime in NIFTI_MIMES:
270
270
  mimetype = DEFAULT_NIFTI_MIME
@@ -273,7 +273,12 @@ class ResourcesApi(CreatableEntityApi[Resource], DeletableEntityApi[Resource]):
273
273
  if ext == '.nii.gz' or filename.lower().endswith('nii.gz'):
274
274
  mimetype = DEFAULT_NIFTI_MIME
275
275
  else:
276
- mimetype = mimetype_list[-1] if mimetype_list else DEFAULT_MIME_TYPE
276
+ mimetype = mimetype_list[-1] if mimetype_list and mimetype_list[-1] else DEFAULT_MIME_TYPE
277
+ if (not mimetype) or mimetype == DEFAULT_MIME_TYPE:
278
+ msg = f"Could not determine mimetype for file {source_filepath}."
279
+ _LOGGER.warning(msg)
280
+ _USER_LOGGER.warning(msg)
281
+
277
282
 
278
283
  mimetype = standardize_mimetype(mimetype)
279
284
 
@@ -433,8 +438,14 @@ class ResourcesApi(CreatableEntityApi[Resource], DeletableEntityApi[Resource]):
433
438
  )
434
439
  return rid
435
440
 
436
- tasks = [__upload_single_resource(f, segfiles, metadata_file)
437
- for f, segfiles, metadata_file in zip(files_path, segmentation_files, metadata_files)]
441
+ try:
442
+ tasks = [__upload_single_resource(f, segfiles, metadata_file)
443
+ for f, segfiles, metadata_file in zip(files_path, segmentation_files, metadata_files)]
444
+ except ValueError:
445
+ msg = f"Error preparing upload tasks. Try `assemble_dicom=False`."
446
+ _LOGGER.error(msg)
447
+ _USER_LOGGER.error(msg)
448
+ raise
438
449
  return await asyncio.gather(*tasks, return_exceptions=on_error == 'skip')
439
450
 
440
451
  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,7 +1,7 @@
1
1
  [project]
2
2
  name = "datamint"
3
3
  description = "A library for interacting with the Datamint API, designed for efficient data management, processing and Deep Learning workflows."
4
- version = "2.3.3"
4
+ version = "2.3.5"
5
5
  dynamic = ["dependencies"]
6
6
  requires-python = ">=3.10"
7
7
  readme = "README.md"
@@ -40,7 +40,7 @@ matplotlib = "*"
40
40
  lightning = "*"
41
41
  albumentations = ">=2.0.0"
42
42
  lazy-loader = ">=0.3.0"
43
- medimgkit = ">=0.7.2"
43
+ medimgkit = ">=0.7.3"
44
44
  typing_extensions = ">=4.0.0"
45
45
  pydantic = ">=2.6.4"
46
46
  httpx = "*"
File without changes
File without changes
File without changes
File without changes
File without changes