datamint 1.9.2__py3-none-any.whl → 2.0.0__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.

Files changed (40) hide show
  1. datamint/__init__.py +2 -0
  2. datamint/api/__init__.py +3 -0
  3. datamint/api/base_api.py +430 -0
  4. datamint/api/client.py +91 -0
  5. datamint/api/dto/__init__.py +10 -0
  6. datamint/api/endpoints/__init__.py +17 -0
  7. datamint/api/endpoints/annotations_api.py +984 -0
  8. datamint/api/endpoints/channels_api.py +28 -0
  9. datamint/api/endpoints/datasetsinfo_api.py +16 -0
  10. datamint/api/endpoints/projects_api.py +203 -0
  11. datamint/api/endpoints/resources_api.py +1013 -0
  12. datamint/api/endpoints/users_api.py +38 -0
  13. datamint/api/entity_base_api.py +347 -0
  14. datamint/apihandler/annotation_api_handler.py +5 -5
  15. datamint/apihandler/api_handler.py +3 -6
  16. datamint/apihandler/base_api_handler.py +6 -28
  17. datamint/apihandler/dto/__init__.py +0 -0
  18. datamint/apihandler/dto/annotation_dto.py +1 -1
  19. datamint/apihandler/root_api_handler.py +53 -28
  20. datamint/client_cmd_tools/datamint_config.py +6 -37
  21. datamint/client_cmd_tools/datamint_upload.py +84 -58
  22. datamint/dataset/base_dataset.py +65 -75
  23. datamint/dataset/dataset.py +2 -2
  24. datamint/entities/__init__.py +20 -0
  25. datamint/entities/annotation.py +178 -0
  26. datamint/entities/base_entity.py +51 -0
  27. datamint/entities/channel.py +46 -0
  28. datamint/entities/datasetinfo.py +22 -0
  29. datamint/entities/project.py +64 -0
  30. datamint/entities/resource.py +130 -0
  31. datamint/entities/user.py +21 -0
  32. datamint/examples/example_projects.py +41 -44
  33. datamint/exceptions.py +27 -1
  34. datamint/logging.yaml +1 -1
  35. datamint/utils/logging_utils.py +75 -0
  36. {datamint-1.9.2.dist-info → datamint-2.0.0.dist-info}/METADATA +13 -9
  37. datamint-2.0.0.dist-info/RECORD +50 -0
  38. {datamint-1.9.2.dist-info → datamint-2.0.0.dist-info}/WHEEL +1 -1
  39. datamint-1.9.2.dist-info/RECORD +0 -29
  40. {datamint-1.9.2.dist-info → datamint-2.0.0.dist-info}/entry_points.txt +0 -0
datamint/exceptions.py CHANGED
@@ -2,4 +2,30 @@ class DatamintException(Exception):
2
2
  """
3
3
  Base class for exceptions in this module.
4
4
  """
5
- pass
5
+ pass
6
+
7
+ class ResourceNotFoundError(DatamintException):
8
+ """
9
+ Exception raised when a resource is not found.
10
+ For instance, when trying to get a resource by a non-existing id.
11
+ """
12
+
13
+ def __init__(self,
14
+ resource_type: str,
15
+ params: dict):
16
+ """ Constructor.
17
+
18
+ Args:
19
+ resource_type (str): A resource type.
20
+ params (dict): Dict of params identifying the sought resource.
21
+ """
22
+ super().__init__()
23
+ self.resource_type = resource_type
24
+ self.params = params
25
+
26
+ def set_params(self, resource_type: str, params: dict):
27
+ self.resource_type = resource_type
28
+ self.params = params
29
+
30
+ def __str__(self):
31
+ return f"Resource '{self.resource_type}' not found for parameters: {self.params}"
datamint/logging.yaml CHANGED
@@ -7,7 +7,7 @@ handlers:
7
7
  level: WARNING
8
8
  show_time: False
9
9
  console_user:
10
- class: datamint.utils.logging_utils.ConditionalRichHandler
10
+ class: datamint.utils.logging_utils.ConsoleWrapperHandler
11
11
  level: INFO
12
12
  show_path: False
13
13
  show_time: False
@@ -1,3 +1,8 @@
1
+ from rich.theme import Theme
2
+ from logging import Logger, DEBUG, INFO, WARNING, ERROR, CRITICAL
3
+ from rich.console import Console
4
+ import platform
5
+ import os
1
6
  import logging
2
7
  import logging.config
3
8
  from rich.console import ConsoleRenderable
@@ -53,3 +58,73 @@ def load_cmdline_logging_config():
53
58
  print(f"Warning: Error loading logging configuration file: {e}")
54
59
  _LOGGER.exception(e)
55
60
  logging.basicConfig(level=logging.INFO)
61
+
62
+
63
+ LEVELS_MAPPING = {
64
+ DEBUG: None,
65
+ INFO: None,
66
+ WARNING: "warning",
67
+ ERROR: "error",
68
+ CRITICAL: "error"
69
+ }
70
+
71
+
72
+ def _create_console_theme() -> Theme:
73
+ """Create a custom Rich theme optimized for cross-platform terminals."""
74
+ # Detect if we're likely on PowerShell (Windows + PowerShell)
75
+ is_powershell = (
76
+ platform.system() == "Windows" and
77
+ os.environ.get("PSModulePath") is not None
78
+ )
79
+
80
+ if is_powershell:
81
+ # PowerShell blue background - use high contrast colors
82
+ return Theme({
83
+ "warning": "bright_yellow",
84
+ "error": "bright_red on white",
85
+ "success": "bright_green",
86
+ "key": "bright_cyan",
87
+ "accent": "bright_cyan",
88
+ "title": "bold"
89
+ })
90
+ else:
91
+ # Linux/Unix terminals - standard colors
92
+ return Theme({
93
+ "warning": "yellow",
94
+ "error": "red",
95
+ "success": "green",
96
+ "key": "cyan",
97
+ "accent": "bright_blue",
98
+ "title": "bold"
99
+ })
100
+
101
+
102
+ class ConsoleWrapperHandler(ConditionalRichHandler):
103
+ """
104
+ A logging handler that uses a rich.console.Console to print log messages.
105
+ """
106
+ def __init__(self, *args, console: Console | None = None, **kwargs):
107
+ """
108
+ Initializes the ConsoleWrapperHandler.
109
+
110
+ Args:
111
+ console (Console | None): A rich Console instance. If None, a new one is created.
112
+ """
113
+ super().__init__(*args, **kwargs)
114
+ if console is None:
115
+ console = Console(theme=_create_console_theme())
116
+ self.console = console
117
+
118
+ def emit(self, record: logging.LogRecord) -> None:
119
+ """
120
+ Emits a log record.
121
+
122
+ Args:
123
+ record (logging.LogRecord): The log record to emit.
124
+ """
125
+ try:
126
+ msg = self.format(record)
127
+ style = LEVELS_MAPPING.get(record.levelno)
128
+ self.console.print(msg, style=style)
129
+ except Exception:
130
+ self.handleError(record)
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.3
1
+ Metadata-Version: 2.4
2
2
  Name: datamint
3
- Version: 1.9.2
3
+ Version: 2.0.0
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
@@ -8,6 +8,7 @@ Classifier: Programming Language :: Python :: 3.10
8
8
  Classifier: Programming Language :: Python :: 3.11
9
9
  Classifier: Programming Language :: Python :: 3.12
10
10
  Classifier: Programming Language :: Python :: 3.13
11
+ Classifier: Programming Language :: Python :: 3.14
11
12
  Provides-Extra: dev
12
13
  Provides-Extra: docs
13
14
  Requires-Dist: Deprecated (>=1.2.0)
@@ -19,13 +20,14 @@ Requires-Dist: humanize (>=4.0.0,<5.0.0)
19
20
  Requires-Dist: lazy-loader (>=0.3.0)
20
21
  Requires-Dist: lightning
21
22
  Requires-Dist: matplotlib
22
- Requires-Dist: medimgkit (>=0.5.0)
23
+ Requires-Dist: medimgkit (>=0.6.0)
23
24
  Requires-Dist: nest-asyncio (>=1.0.0,<2.0.0)
24
25
  Requires-Dist: nibabel (>=4.0.0)
25
26
  Requires-Dist: numpy
26
27
  Requires-Dist: opencv-python (>=4.0.0)
27
28
  Requires-Dist: pandas (>=2.0.0)
28
29
  Requires-Dist: platformdirs (>=4.0.0,<5.0.0)
30
+ Requires-Dist: pydantic (>=2.6.4)
29
31
  Requires-Dist: pydicom (>=3.0.0,<4.0.0)
30
32
  Requires-Dist: pylibjpeg (>=2.0.0,<3.0.0)
31
33
  Requires-Dist: pylibjpeg-libjpeg (>=2.0.0,<3.0.0)
@@ -42,6 +44,7 @@ Requires-Dist: sphinx_rtd_theme (>=2.0.0) ; extra == "docs"
42
44
  Requires-Dist: torch (>=1.2.0,!=2.3.0)
43
45
  Requires-Dist: torchvision (>=0.18.0)
44
46
  Requires-Dist: tqdm (>=4.0.0,<5.0.0)
47
+ Requires-Dist: typing_extensions (>=4.0.0)
45
48
  Description-Content-Type: text/markdown
46
49
 
47
50
 
@@ -91,13 +94,13 @@ import os
91
94
  os.environ["DATAMINT_API_KEY"] = "my_api_key"
92
95
  ```
93
96
 
94
- ### Method 3: APIHandler constructor
97
+ ### Method 3: Api constructor
95
98
 
96
- Specify API key in the |APIHandlerClass| constructor:
99
+ Specify API key in the Api constructor:
97
100
 
98
101
  ```python
99
- from datamint import APIHandler
100
- api = APIHandler(api_key='my_api_key')
102
+ from datamint import Api
103
+ api = Api(api_key='my_api_key')
101
104
  ```
102
105
 
103
106
  ## Tutorials
@@ -110,8 +113,9 @@ You can find example notebooks in the `notebooks` folder:
110
113
 
111
114
  and example scripts in [examples](examples) folder:
112
115
 
113
- - [Running an experiment for classification](examples/experiment_traintest_classifier.py)
114
- - [Running an experiment for segmentation](examples/experiment_traintest_segmentation.py)
116
+ - [API usage examples](examples/api_usage.ipynb)
117
+ - [Project and entity usage](examples/project_entity_usage.ipynb)
118
+ - [Channels example](examples/channels_example.ipynb)
115
119
 
116
120
  ## Full documentation
117
121
 
@@ -0,0 +1,50 @@
1
+ datamint/__init__.py,sha256=ucsnxrYClh6pdy7psRJXWam_9rjAQB4NXzvy7xLovmo,824
2
+ datamint/api/__init__.py,sha256=7QYkmDBXbKh8-zchV7k6Lpolaw6h-IK6ezfXROIWh2A,43
3
+ datamint/api/base_api.py,sha256=MIq1sQA4mD9_SWxAEDjxtxm3Q-tj6kZ05KRnNoLPM7E,16576
4
+ datamint/api/client.py,sha256=1XTZUlbAISe0jwug1rrANgWJToXxYeXx8_HD-ZWJurU,3354
5
+ datamint/api/dto/__init__.py,sha256=KOSNl1axDDE5eBt68MmsgkyE0Ds_1DDzWUg73iyoWvc,281
6
+ datamint/api/endpoints/__init__.py,sha256=S46nVAlXgGe8wNcBEhW8ffGJjGNAmhhRTDTsvG9fWBE,402
7
+ datamint/api/endpoints/annotations_api.py,sha256=zzCiL2z7czB1ojU3CCM5QgeOuDoNB_2D3Fc8NPc41HM,46240
8
+ datamint/api/endpoints/channels_api.py,sha256=oQqxSw9DJzAqtVQI7-tc1llTdnsm-URx8jwtXNXnhio,867
9
+ datamint/api/endpoints/datasetsinfo_api.py,sha256=WdzrUzK63w9gvAP6U--P65FbD-3X-jm9TPCcYnRNjas,597
10
+ datamint/api/endpoints/projects_api.py,sha256=9tYIQsnMFOGTXrsoizweoWNqNue5907nbI6G9PAcYcA,7784
11
+ datamint/api/endpoints/resources_api.py,sha256=jlap40_wpzz8L8a-sX9tNGxsgPgP2_hv8kdb3g75-NU,48455
12
+ datamint/api/endpoints/users_api.py,sha256=pnkuTZ1B9Y0FtwwvXO8J64e02RSkRxnBmTl9UGSuC5I,1186
13
+ datamint/api/entity_base_api.py,sha256=gPE28bwv7B6JngMk9szD2XwaVhB8OwB1HJjaMYD354k,12935
14
+ datamint/apihandler/annotation_api_handler.py,sha256=W3vV4z3BqX1OQe1r7zr8dI-IVu4zUDxED4QttdiWV-E,57098
15
+ datamint/apihandler/api_handler.py,sha256=mL0gMaWePYa7zwkw92E-VMK2WjpcPt7au0KqnmsWSYw,439
16
+ datamint/apihandler/base_api_handler.py,sha256=Hqt3oUvXfEqF25DJkk0WOWAtNLnKaZRGtnCchKFA1ag,11669
17
+ datamint/apihandler/dto/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
18
+ datamint/apihandler/dto/annotation_dto.py,sha256=KUeHbxLYols16q-ANNxC48eH4EA8Tc-nKmW_8xrqhy4,7119
19
+ datamint/apihandler/exp_api_handler.py,sha256=hFUgUgBc5rL7odK7gTW3MnrvMY1pVfJUpUdzRNobMQE,6226
20
+ datamint/apihandler/root_api_handler.py,sha256=jBof_XPTeq4o41CW-l-I5GHQKVa76kaX75RovS_qAM4,63384
21
+ datamint/client_cmd_tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
22
+ datamint/client_cmd_tools/datamint_config.py,sha256=5S9sgS64F141ZcvvjCHEEgfNKwhGt4g2oJQaJqeiugA,7228
23
+ datamint/client_cmd_tools/datamint_upload.py,sha256=jPzvlNeBZfOOxuG6ryswJ8OG4jXuTrPtArUetoKVGj0,36073
24
+ datamint/configs.py,sha256=Bdp6NydYwyCJ2dk19_gf_o3M2ZyQOmMHpLi8wEWNHUk,1426
25
+ datamint/dataset/__init__.py,sha256=4PlUKSvVhdfQvvuq8jQXrkdqnot-iTTizM3aM1vgSwg,47
26
+ datamint/dataset/annotation.py,sha256=qN1IMjdfLD2ceQ6va3l76jOXA8Vb_c-eBk1oWQu6hW0,7994
27
+ datamint/dataset/base_dataset.py,sha256=ghVfy_WB3sZD29J5rWQhccEi1DD_qsif5B4gcPlhepU,49285
28
+ datamint/dataset/dataset.py,sha256=It-HOTi83ls4ww2qCAvFYU0_OLLrFclj0QQapMYgDAE,27333
29
+ datamint/entities/__init__.py,sha256=tbHE7rZb0R9Hm-Dc8VWEq3PlRl7BYOzffumrV0ZdsMs,444
30
+ datamint/entities/annotation.py,sha256=ochAEh_JqxAe_FyYTNUfPT47KiIAG7CkBTim52bu7M8,6636
31
+ datamint/entities/base_entity.py,sha256=DniakCgJ-gV7Hz8VKQA_dRYTp4DU5rcjLBVOuD1aZuA,1902
32
+ datamint/entities/channel.py,sha256=9fl22eSx_ng98NosfQGs18cdaRdbeC3wXL61KhSg4Zo,1601
33
+ datamint/entities/datasetinfo.py,sha256=O73Aq0tLflQomFzseful8a_cXqKdO9w2yP0p3zBcA-s,489
34
+ datamint/entities/project.py,sha256=cK03qfVBVUTFJF0IZQCGfjX-ivzDytySakKoVbjfnz0,2588
35
+ datamint/entities/resource.py,sha256=7YCVihswd-bH-2AH4aMPIddt5ejwRqRFQAszI_sTWaU,4882
36
+ datamint/entities/user.py,sha256=MREHDOsV9NOBEbXqiQ2ww6DmetN07CELId-ZQVpZCb8,620
37
+ datamint/examples/__init__.py,sha256=zcYnd5nLVme9GCTPYH-1JpGo8xXK2WEYvhzcy_2alZc,39
38
+ datamint/examples/example_projects.py,sha256=sU-Gxy7PPqA0WUfN-ZmXV-0YnwrnzpJ79lMXTJp2DzU,2804
39
+ datamint/exceptions.py,sha256=jjtoc5EUbGZhAhaoIbnRrolV7O8jRerYdjzeFwx1fmA,909
40
+ datamint/experiment/__init__.py,sha256=5qQOMzoG17DEd1YnTF-vS0qiM-DGdbNh42EUo91CRhQ,34
41
+ datamint/experiment/_patcher.py,sha256=ZgbezoevAYhJsbiJTvWPALGTcUiMT371xddcTllt3H4,23296
42
+ datamint/experiment/experiment.py,sha256=aHK9dRFdQTi569xgUg1KqlCZLHZpDmSH3g3ndPIZvXw,44546
43
+ datamint/logging.yaml,sha256=tOMxtc2UmwlIMTK6ljtnBwTco1PNrPeq3mx2iMuSbiw,482
44
+ datamint/utils/logging_utils.py,sha256=9pRoaPrWu2jOdDCiAoUsjEdP5ZwaealWL3hjUqFvx9g,4022
45
+ datamint/utils/torchmetrics.py,sha256=lwU0nOtsSWfebyp7dvjlAggaqXtj5ohSEUXOg3L0hJE,2837
46
+ datamint/utils/visualization.py,sha256=yaUVAOHar59VrGUjpAWv5eVvQSfztFG0eP9p5Vt3l-M,4470
47
+ datamint-2.0.0.dist-info/METADATA,sha256=38a-ojBv46DcXTJx8IQiE_DgOyWjela2l1S-ikBHHgs,4182
48
+ datamint-2.0.0.dist-info/WHEEL,sha256=M5asmiAlL6HEcOq52Yi5mmk9KmTVjY2RDPtO4p9DMrc,88
49
+ datamint-2.0.0.dist-info/entry_points.txt,sha256=mn5H6jPjO-rY0W0CAZ6Z_KKWhMLvyVaSpoqk77jlTI4,145
50
+ datamint-2.0.0.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 2.1.3
2
+ Generator: poetry-core 2.2.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -1,29 +0,0 @@
1
- datamint/__init__.py,sha256=7rKCCsaa4RBRTIfuHB708rai1xwDHLtkFNFJGKYG5D4,757
2
- datamint/apihandler/annotation_api_handler.py,sha256=ZJJD_Op8eDtGcpDZOS1DRjqyDUdD3UxvtuNJK9FaPOk,57063
3
- datamint/apihandler/api_handler.py,sha256=cdVSddrFCKlF_BJ81LO1aJ0OP49rssjpNEFzJ6Q7YyY,384
4
- datamint/apihandler/base_api_handler.py,sha256=An9chkUcq_v2_Tkr9TbwI_lnsXCyNYgugxK9nRu4oG8,12126
5
- datamint/apihandler/dto/annotation_dto.py,sha256=qId1RK1VO7dXrvGJ7dqJ31jBQB7Z8yy5x0tLSiMxTB4,7105
6
- datamint/apihandler/exp_api_handler.py,sha256=hFUgUgBc5rL7odK7gTW3MnrvMY1pVfJUpUdzRNobMQE,6226
7
- datamint/apihandler/root_api_handler.py,sha256=8kanwP89ubRZjhXy1ZOUAeW67oyiEEsImjTecixuPNA,62413
8
- datamint/client_cmd_tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
- datamint/client_cmd_tools/datamint_config.py,sha256=pNmczVexsSPO8DKBGEPLuMOp3jIQwVkcPsm8KqFldjw,8164
10
- datamint/client_cmd_tools/datamint_upload.py,sha256=pWsF7QdjZ3qWbxCQG-oJqUoosFD8UgBg08UiuZEE01c,34393
11
- datamint/configs.py,sha256=Bdp6NydYwyCJ2dk19_gf_o3M2ZyQOmMHpLi8wEWNHUk,1426
12
- datamint/dataset/__init__.py,sha256=4PlUKSvVhdfQvvuq8jQXrkdqnot-iTTizM3aM1vgSwg,47
13
- datamint/dataset/annotation.py,sha256=qN1IMjdfLD2ceQ6va3l76jOXA8Vb_c-eBk1oWQu6hW0,7994
14
- datamint/dataset/base_dataset.py,sha256=S0pboog2yB2LCBGOocBIlOU8to7Wgov3gXTOJ9gbvz0,49697
15
- datamint/dataset/dataset.py,sha256=8e0MFgINgbw6_UJh7pNQIREp2XxstIVCupyduW05Nfw,27321
16
- datamint/examples/__init__.py,sha256=zcYnd5nLVme9GCTPYH-1JpGo8xXK2WEYvhzcy_2alZc,39
17
- datamint/examples/example_projects.py,sha256=7Nb_EaIdzJTQa9zopqc-WhTBQWQJSoQZ_KjRS4PB4FI,2931
18
- datamint/exceptions.py,sha256=AdpAC528xrml7LfWt04zQK8pONoDBx8WmXSvzRGi52o,106
19
- datamint/experiment/__init__.py,sha256=5qQOMzoG17DEd1YnTF-vS0qiM-DGdbNh42EUo91CRhQ,34
20
- datamint/experiment/_patcher.py,sha256=ZgbezoevAYhJsbiJTvWPALGTcUiMT371xddcTllt3H4,23296
21
- datamint/experiment/experiment.py,sha256=aHK9dRFdQTi569xgUg1KqlCZLHZpDmSH3g3ndPIZvXw,44546
22
- datamint/logging.yaml,sha256=a5dsATpul7QHeUHB2TjABFjWaPXBMbO--dgn8GlRqwk,483
23
- datamint/utils/logging_utils.py,sha256=DvoA35ATYG3JTwfXEXYawDyKRfHeCrH0a9czfkmz8kM,1851
24
- datamint/utils/torchmetrics.py,sha256=lwU0nOtsSWfebyp7dvjlAggaqXtj5ohSEUXOg3L0hJE,2837
25
- datamint/utils/visualization.py,sha256=yaUVAOHar59VrGUjpAWv5eVvQSfztFG0eP9p5Vt3l-M,4470
26
- datamint-1.9.2.dist-info/METADATA,sha256=2Zx8udYytzc3cZiQmjG5LWquRESp9c_9KmV-YptaeUU,4100
27
- datamint-1.9.2.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
28
- datamint-1.9.2.dist-info/entry_points.txt,sha256=mn5H6jPjO-rY0W0CAZ6Z_KKWhMLvyVaSpoqk77jlTI4,145
29
- datamint-1.9.2.dist-info/RECORD,,