datamint 2.3.3__py3-none-any.whl → 2.3.5__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 +6 -5
- datamint/api/endpoints/projects_api.py +9 -4
- datamint/api/endpoints/resources_api.py +17 -6
- datamint/client_cmd_tools/datamint_upload.py +3 -1
- {datamint-2.3.3.dist-info → datamint-2.3.5.dist-info}/METADATA +2 -2
- {datamint-2.3.3.dist-info → datamint-2.3.5.dist-info}/RECORD +8 -8
- {datamint-2.3.3.dist-info → datamint-2.3.5.dist-info}/WHEEL +0 -0
- {datamint-2.3.3.dist-info → datamint-2.3.5.dist-info}/entry_points.txt +0 -0
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
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
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
|
|
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 = [
|
|
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)
|
|
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
|
|
267
|
-
mimetype_list, ext = guess_typez(file_path, use_magic=
|
|
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
|
-
|
|
437
|
-
|
|
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=
|
|
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
|
+
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.
|
|
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
|
|
@@ -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=
|
|
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=
|
|
13
|
-
datamint/api/endpoints/resources_api.py,sha256=
|
|
12
|
+
datamint/api/endpoints/projects_api.py,sha256=Pfr3fEiMw_aRzoGtcVXHJQ68leVoPAghw23L4ZIglno,8237
|
|
13
|
+
datamint/api/endpoints/resources_api.py,sha256=ZsGy4xTdLHLkM2z8VyRRLEjB0Rv3kTZFQceYkFYpk7A,50601
|
|
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=
|
|
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.
|
|
52
|
-
datamint-2.3.
|
|
53
|
-
datamint-2.3.
|
|
54
|
-
datamint-2.3.
|
|
51
|
+
datamint-2.3.5.dist-info/METADATA,sha256=Iu3geKgUkPz0cGntOO4i1Kdvf4i0UhAJeoxrNhKbuHs,4262
|
|
52
|
+
datamint-2.3.5.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
|
|
53
|
+
datamint-2.3.5.dist-info/entry_points.txt,sha256=mn5H6jPjO-rY0W0CAZ6Z_KKWhMLvyVaSpoqk77jlTI4,145
|
|
54
|
+
datamint-2.3.5.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|