logs-py 4.0.7__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.
Files changed (251) hide show
  1. LOGS/Auxiliary/CheckClassName.py +1075 -0
  2. LOGS/Auxiliary/Constants.py +99 -0
  3. LOGS/Auxiliary/CustomEntityClassGenerator.py +254 -0
  4. LOGS/Auxiliary/CustomFieldClassGenerator.py +115 -0
  5. LOGS/Auxiliary/CustomFieldValueTypeChecker.py +168 -0
  6. LOGS/Auxiliary/CustomSectionClassGenerator.py +113 -0
  7. LOGS/Auxiliary/CustomTypeClassGenerator.py +147 -0
  8. LOGS/Auxiliary/DateTimeConverter.py +66 -0
  9. LOGS/Auxiliary/Decorators.py +109 -0
  10. LOGS/Auxiliary/Exceptions.py +341 -0
  11. LOGS/Auxiliary/LOGSErrorResponse.py +89 -0
  12. LOGS/Auxiliary/MinimalModelGenerator.py +236 -0
  13. LOGS/Auxiliary/ParameterHelper.py +56 -0
  14. LOGS/Auxiliary/ReplaceMessage.py +13 -0
  15. LOGS/Auxiliary/Tools.py +432 -0
  16. LOGS/Auxiliary/__init__.py +15 -0
  17. LOGS/Converter/Conversion.py +248 -0
  18. LOGS/Converter/Converter.py +96 -0
  19. LOGS/Converter/ConverterParameter.py +88 -0
  20. LOGS/Converter/DateTimeRange.py +58 -0
  21. LOGS/Converter/ExportParameters.py +89 -0
  22. LOGS/Converter/__init__.py +13 -0
  23. LOGS/Entities/Attachment.py +84 -0
  24. LOGS/Entities/AttachmentMinimal.py +8 -0
  25. LOGS/Entities/AttachmentRequestParameter.py +42 -0
  26. LOGS/Entities/Attachments.py +53 -0
  27. LOGS/Entities/AutoloadFileInfo.py +12 -0
  28. LOGS/Entities/AutoloadStatusError.py +7 -0
  29. LOGS/Entities/AxisNaming.py +33 -0
  30. LOGS/Entities/AxisZoom.py +33 -0
  31. LOGS/Entities/Bridge.py +165 -0
  32. LOGS/Entities/BridgeClientInfo.py +93 -0
  33. LOGS/Entities/BridgeMinimal.py +8 -0
  34. LOGS/Entities/BridgeRequestParameter.py +49 -0
  35. LOGS/Entities/BridgeType.py +7 -0
  36. LOGS/Entities/Bridges.py +12 -0
  37. LOGS/Entities/CustomField.py +243 -0
  38. LOGS/Entities/CustomFieldMinimal.py +8 -0
  39. LOGS/Entities/CustomFieldModels.py +111 -0
  40. LOGS/Entities/CustomFieldRequestParameter.py +69 -0
  41. LOGS/Entities/CustomFieldSearchQuery.py +40 -0
  42. LOGS/Entities/CustomFields.py +12 -0
  43. LOGS/Entities/CustomType.py +212 -0
  44. LOGS/Entities/CustomTypeMinimal.py +8 -0
  45. LOGS/Entities/CustomTypeRequestParameter.py +60 -0
  46. LOGS/Entities/CustomTypeSection.py +63 -0
  47. LOGS/Entities/CustomTypes.py +12 -0
  48. LOGS/Entities/DataFormat.py +97 -0
  49. LOGS/Entities/DataFormatInstrument.py +18 -0
  50. LOGS/Entities/DataFormatInstrumentMinimal.py +8 -0
  51. LOGS/Entities/DataFormatInstrumentRequestParameter.py +17 -0
  52. LOGS/Entities/DataFormatInstruments.py +16 -0
  53. LOGS/Entities/DataFormatMinimal.py +18 -0
  54. LOGS/Entities/DataFormatRequestParameter.py +21 -0
  55. LOGS/Entities/DataFormats.py +12 -0
  56. LOGS/Entities/DataSource.py +218 -0
  57. LOGS/Entities/DataSourceConnectionStatus.py +12 -0
  58. LOGS/Entities/DataSourceMinimal.py +8 -0
  59. LOGS/Entities/DataSourceRequestParameter.py +57 -0
  60. LOGS/Entities/DataSourceStatus.py +108 -0
  61. LOGS/Entities/DataSourceStatusIterator.py +16 -0
  62. LOGS/Entities/DataSourceStatusRequestParameter.py +31 -0
  63. LOGS/Entities/DataSources.py +12 -0
  64. LOGS/Entities/Dataset.py +439 -0
  65. LOGS/Entities/DatasetBase.py +196 -0
  66. LOGS/Entities/DatasetCreator.py +148 -0
  67. LOGS/Entities/DatasetInfo.py +147 -0
  68. LOGS/Entities/DatasetMatchTypes.py +157 -0
  69. LOGS/Entities/DatasetMatching.py +196 -0
  70. LOGS/Entities/DatasetMinimal.py +8 -0
  71. LOGS/Entities/DatasetModels.py +33 -0
  72. LOGS/Entities/DatasetRequestParameter.py +92 -0
  73. LOGS/Entities/DatasetTemplate.py +23 -0
  74. LOGS/Entities/DatasetUploadParameter.py +14 -0
  75. LOGS/Entities/Datasets.py +142 -0
  76. LOGS/Entities/Datatrack.py +179 -0
  77. LOGS/Entities/DatatrackFormattedTable.py +25 -0
  78. LOGS/Entities/DatatrackGeneric.py +34 -0
  79. LOGS/Entities/DatatrackImage.py +25 -0
  80. LOGS/Entities/DatatrackNumericArray.py +30 -0
  81. LOGS/Entities/DatatrackNumericMatrix.py +98 -0
  82. LOGS/Entities/Entities.py +71 -0
  83. LOGS/Entities/EntitiesRequestParameter.py +18 -0
  84. LOGS/Entities/EntityOriginWriteModelWithId.py +15 -0
  85. LOGS/Entities/FileEntry.py +138 -0
  86. LOGS/Entities/FileExcludePattern.py +8 -0
  87. LOGS/Entities/FormatMetaData.py +56 -0
  88. LOGS/Entities/FormattedTable/DatatypeFormattedTable.py +135 -0
  89. LOGS/Entities/FormattedTable/DatatypeFormattedTableCell.py +108 -0
  90. LOGS/Entities/FormattedTable/DatatypeFormattedTableSettings.py +11 -0
  91. LOGS/Entities/FormattedTable/__init__.py +9 -0
  92. LOGS/Entities/HierarchyLeaf.py +15 -0
  93. LOGS/Entities/HierarchyNode.py +40 -0
  94. LOGS/Entities/ILiteraryTypedEntity.py +19 -0
  95. LOGS/Entities/InventoryItem.py +102 -0
  96. LOGS/Entities/InventoryItemMinimal.py +25 -0
  97. LOGS/Entities/InventoryItemRequestParameter.py +58 -0
  98. LOGS/Entities/InventoryItems.py +12 -0
  99. LOGS/Entities/LabNotebook.py +33 -0
  100. LOGS/Entities/LabNotebookEntries.py +16 -0
  101. LOGS/Entities/LabNotebookEntry.py +106 -0
  102. LOGS/Entities/LabNotebookEntryContent/BasicAttribute.py +15 -0
  103. LOGS/Entities/LabNotebookEntryContent/EntityAttribute.py +85 -0
  104. LOGS/Entities/LabNotebookEntryContent/EntryContentBlockquote.py +13 -0
  105. LOGS/Entities/LabNotebookEntryContent/EntryContentBulletList.py +17 -0
  106. LOGS/Entities/LabNotebookEntryContent/EntryContentCallout.py +40 -0
  107. LOGS/Entities/LabNotebookEntryContent/EntryContentContentPlaceholderNode.py +31 -0
  108. LOGS/Entities/LabNotebookEntryContent/EntryContentConverter.py +207 -0
  109. LOGS/Entities/LabNotebookEntryContent/EntryContentDocument.py +8 -0
  110. LOGS/Entities/LabNotebookEntryContent/EntryContentEntity.py +13 -0
  111. LOGS/Entities/LabNotebookEntryContent/EntryContentEntityMention.py +31 -0
  112. LOGS/Entities/LabNotebookEntryContent/EntryContentHeading.py +33 -0
  113. LOGS/Entities/LabNotebookEntryContent/EntryContentHorizontalRule.py +12 -0
  114. LOGS/Entities/LabNotebookEntryContent/EntryContentItem.py +37 -0
  115. LOGS/Entities/LabNotebookEntryContent/EntryContentListItem.py +49 -0
  116. LOGS/Entities/LabNotebookEntryContent/EntryContentOrderedList.py +31 -0
  117. LOGS/Entities/LabNotebookEntryContent/EntryContentParagraph.py +13 -0
  118. LOGS/Entities/LabNotebookEntryContent/EntryContentTable.py +17 -0
  119. LOGS/Entities/LabNotebookEntryContent/EntryContentTableCell.py +40 -0
  120. LOGS/Entities/LabNotebookEntryContent/EntryContentTableRow.py +8 -0
  121. LOGS/Entities/LabNotebookEntryContent/EntryContentTaskList.py +17 -0
  122. LOGS/Entities/LabNotebookEntryContent/EntryContentTaskListItem.py +31 -0
  123. LOGS/Entities/LabNotebookEntryContent/EntryContentText.py +33 -0
  124. LOGS/Entities/LabNotebookEntryContent/IEntryContentWithAttribute.py +23 -0
  125. LOGS/Entities/LabNotebookEntryContent/IEntryContentWithContent.py +38 -0
  126. LOGS/Entities/LabNotebookEntryContent/IEntryContentWithTextAttribute.py +16 -0
  127. LOGS/Entities/LabNotebookEntryContent/TextAttribute.py +46 -0
  128. LOGS/Entities/LabNotebookEntryContent/TextMarkAtributes.py +64 -0
  129. LOGS/Entities/LabNotebookEntryContent/TextMarkConverter.py +45 -0
  130. LOGS/Entities/LabNotebookEntryContent/TextMarks.py +71 -0
  131. LOGS/Entities/LabNotebookEntryContent/__init__.py +34 -0
  132. LOGS/Entities/LabNotebookEntryMinimal.py +8 -0
  133. LOGS/Entities/LabNotebookEntryRequestParameter.py +59 -0
  134. LOGS/Entities/LabNotebookExperiment.py +58 -0
  135. LOGS/Entities/LabNotebookExperimentMinimal.py +8 -0
  136. LOGS/Entities/LabNotebookExperimentRequestParameter.py +52 -0
  137. LOGS/Entities/LabNotebookExperiments.py +16 -0
  138. LOGS/Entities/LabNotebookMinimal.py +8 -0
  139. LOGS/Entities/LabNotebookModels.py +14 -0
  140. LOGS/Entities/LabNotebookRequestParameter.py +42 -0
  141. LOGS/Entities/LabNotebookTemplate.py +42 -0
  142. LOGS/Entities/LabNotebookTemplateMinimal.py +8 -0
  143. LOGS/Entities/LabNotebookTemplateRequestParameter.py +38 -0
  144. LOGS/Entities/LabNotebookTemplates.py +16 -0
  145. LOGS/Entities/LabNotebooks.py +12 -0
  146. LOGS/Entities/Method.py +66 -0
  147. LOGS/Entities/MethodMinimal.py +8 -0
  148. LOGS/Entities/MethodRequestParameter.py +16 -0
  149. LOGS/Entities/Methods.py +12 -0
  150. LOGS/Entities/Origin.py +53 -0
  151. LOGS/Entities/OriginMinimal.py +8 -0
  152. LOGS/Entities/OriginRequestParameter.py +28 -0
  153. LOGS/Entities/Origins.py +12 -0
  154. LOGS/Entities/ParserLog.py +49 -0
  155. LOGS/Entities/Permission.py +9 -0
  156. LOGS/Entities/Person.py +145 -0
  157. LOGS/Entities/PersonCategory.py +12 -0
  158. LOGS/Entities/PersonMinimal.py +8 -0
  159. LOGS/Entities/PersonRequestParameter.py +58 -0
  160. LOGS/Entities/Persons.py +12 -0
  161. LOGS/Entities/Project.py +52 -0
  162. LOGS/Entities/ProjectMinimal.py +8 -0
  163. LOGS/Entities/ProjectPersonPermission.py +102 -0
  164. LOGS/Entities/ProjectRequestParameter.py +58 -0
  165. LOGS/Entities/Projects.py +12 -0
  166. LOGS/Entities/Role.py +94 -0
  167. LOGS/Entities/RoleMinimal.py +8 -0
  168. LOGS/Entities/RoleRequestParameter.py +40 -0
  169. LOGS/Entities/Roles.py +12 -0
  170. LOGS/Entities/RunState.py +9 -0
  171. LOGS/Entities/Sample.py +53 -0
  172. LOGS/Entities/SampleMinimal.py +8 -0
  173. LOGS/Entities/SampleRequestParameter.py +54 -0
  174. LOGS/Entities/Samples.py +12 -0
  175. LOGS/Entities/SharedContent.py +87 -0
  176. LOGS/Entities/SharedContentMinimal.py +8 -0
  177. LOGS/Entities/SharedContentRequestParameter.py +38 -0
  178. LOGS/Entities/SharedContents.py +12 -0
  179. LOGS/Entities/Signature.py +60 -0
  180. LOGS/Entities/Track.py +93 -0
  181. LOGS/Entities/TrackData.py +20 -0
  182. LOGS/Entities/TrackImage.py +21 -0
  183. LOGS/Entities/TrackImageData.py +20 -0
  184. LOGS/Entities/TrackMatrix.py +28 -0
  185. LOGS/Entities/TrackMatrixData.py +22 -0
  186. LOGS/Entities/TrackSettings.py +55 -0
  187. LOGS/Entities/TrackTable.py +21 -0
  188. LOGS/Entities/TrackTableData.py +22 -0
  189. LOGS/Entities/TrackXY.py +40 -0
  190. LOGS/Entities/TrackXYComplex.py +51 -0
  191. LOGS/Entities/TrackXYComplexData.py +50 -0
  192. LOGS/Entities/TrackXYData.py +31 -0
  193. LOGS/Entities/Vendor.py +40 -0
  194. LOGS/Entities/VendorMinimal.py +8 -0
  195. LOGS/Entities/VendorRequestParameter.py +17 -0
  196. LOGS/Entities/Vendors.py +12 -0
  197. LOGS/Entities/__init__.py +118 -0
  198. LOGS/Entity/ConnectedEntity.py +170 -0
  199. LOGS/Entity/Entity.py +203 -0
  200. LOGS/Entity/EntityConnector.py +70 -0
  201. LOGS/Entity/EntityIterator.py +263 -0
  202. LOGS/Entity/EntityMinimal.py +141 -0
  203. LOGS/Entity/EntityMinimalWithIntId.py +36 -0
  204. LOGS/Entity/EntityMinimalWithStrId.py +36 -0
  205. LOGS/Entity/EntityMinimalWithType.py +47 -0
  206. LOGS/Entity/EntityRequestParameter.py +104 -0
  207. LOGS/Entity/EntitySortBy.py +69 -0
  208. LOGS/Entity/EntityWithIntId.py +26 -0
  209. LOGS/Entity/EntityWithStrId.py +26 -0
  210. LOGS/Entity/IGenericEntityOrderBy.py +55 -0
  211. LOGS/Entity/IdIterator.py +207 -0
  212. LOGS/Entity/SerializableContent.py +834 -0
  213. LOGS/Entity/__init__.py +23 -0
  214. LOGS/Interfaces/ICustomFieldValue.py +92 -0
  215. LOGS/Interfaces/ICustomSectionValue.py +161 -0
  216. LOGS/Interfaces/ICustomTypeValue.py +152 -0
  217. LOGS/Interfaces/ICustomValue.py +28 -0
  218. LOGS/Interfaces/IEntityInterface.py +7 -0
  219. LOGS/Interfaces/IEntryRecord.py +57 -0
  220. LOGS/Interfaces/IHierarchicalEntity.py +41 -0
  221. LOGS/Interfaces/IHierarchyType.py +63 -0
  222. LOGS/Interfaces/ILockableEntity.py +52 -0
  223. LOGS/Interfaces/IModificationRecord.py +56 -0
  224. LOGS/Interfaces/INamedEntity.py +25 -0
  225. LOGS/Interfaces/IOwnedEntity.py +27 -0
  226. LOGS/Interfaces/IPaginationRequest.py +11 -0
  227. LOGS/Interfaces/IPermissionedEntity.py +72 -0
  228. LOGS/Interfaces/IProjectBased.py +27 -0
  229. LOGS/Interfaces/ISessionedEntity.py +59 -0
  230. LOGS/Interfaces/ISignableEntity.py +49 -0
  231. LOGS/Interfaces/ISoftDeletable.py +28 -0
  232. LOGS/Interfaces/ITypedEntity.py +129 -0
  233. LOGS/Interfaces/IUniqueEntity.py +61 -0
  234. LOGS/Interfaces/IVersionedEntity.py +39 -0
  235. LOGS/Interfaces/__init__.py +7 -0
  236. LOGS/LOGS.py +1436 -0
  237. LOGS/LOGSConnection.py +647 -0
  238. LOGS/LOGSOptions.py +11 -0
  239. LOGS/Parameters/Color.py +92 -0
  240. LOGS/Parameters/ParameterBase.py +55 -0
  241. LOGS/Parameters/ParameterConverter.py +24 -0
  242. LOGS/Parameters/ParameterElement.py +99 -0
  243. LOGS/Parameters/ParameterList.py +52 -0
  244. LOGS/Parameters/ParameterTable.py +64 -0
  245. LOGS/Parameters/__init__.py +13 -0
  246. LOGS/ServerMetaData.py +120 -0
  247. LOGS/__init__.py +12 -0
  248. logs_py-4.0.7.dist-info/METADATA +51 -0
  249. logs_py-4.0.7.dist-info/RECORD +251 -0
  250. logs_py-4.0.7.dist-info/WHEEL +5 -0
  251. logs_py-4.0.7.dist-info/top_level.txt +1 -0
@@ -0,0 +1,108 @@
1
+ from datetime import datetime
2
+ from typing import List, Optional
3
+
4
+ from LOGS.Auxiliary.Decorators import Endpoint
5
+ from LOGS.Entities.BridgeType import BridgeType
6
+ from LOGS.Entities.RunState import RunState
7
+ from LOGS.Entity.EntityWithIntId import IEntityWithIntId
8
+ from LOGS.Entity.SerializableContent import SerializableClass
9
+
10
+
11
+ class DataSourceStatusError(SerializableClass):
12
+ message: Optional[str] = None
13
+
14
+
15
+ @Endpoint("data_sources_status")
16
+ class DataSourceStatus(IEntityWithIntId):
17
+ _type: Optional[BridgeType] = None
18
+ _uuid: Optional[str] = None
19
+ _lastUpdated: Optional[datetime] = None
20
+ _counter: Optional[int] = None
21
+ _dataSourceId: Optional[int] = None
22
+ _runState: Optional[RunState] = None
23
+ _startedOn: Optional[datetime] = None
24
+ _duration: Optional[float] = None
25
+ _errors: Optional[List[DataSourceStatusError]] = None
26
+ _info: Optional[dict] = None
27
+
28
+ @property
29
+ def type(self) -> Optional[BridgeType]:
30
+ return self._type
31
+
32
+ @type.setter
33
+ def type(self, value):
34
+ self._type = self.checkAndConvertNullable(value, BridgeType, "type")
35
+
36
+ @property
37
+ def uuid(self) -> Optional[str]:
38
+ return self._uuid
39
+
40
+ @uuid.setter
41
+ def uuid(self, value):
42
+ self._uuid = self.checkAndConvertNullable(value, str, "uuid")
43
+
44
+ @property
45
+ def lastUpdated(self) -> Optional[datetime]:
46
+ return self._lastUpdated
47
+
48
+ @lastUpdated.setter
49
+ def lastUpdated(self, value):
50
+ self._lastUpdated = self.checkAndConvertNullable(value, datetime, "lastUpdated")
51
+
52
+ @property
53
+ def counter(self) -> Optional[int]:
54
+ return self._counter
55
+
56
+ @counter.setter
57
+ def counter(self, value):
58
+ self._counter = self.checkAndConvertNullable(value, int, "counter")
59
+
60
+ @property
61
+ def dataSourceId(self) -> Optional[int]:
62
+ return self._dataSourceId
63
+
64
+ @dataSourceId.setter
65
+ def dataSourceId(self, value):
66
+ self._dataSourceId = self.checkAndConvertNullable(value, int, "dataSourceId")
67
+
68
+ @property
69
+ def runState(self) -> Optional[RunState]:
70
+ return self._runState
71
+
72
+ @runState.setter
73
+ def runState(self, value):
74
+ self._runState = self.checkAndConvertNullable(value, RunState, "runState")
75
+
76
+ @property
77
+ def startedOn(self) -> Optional[datetime]:
78
+ return self._startedOn
79
+
80
+ @startedOn.setter
81
+ def startedOn(self, value):
82
+ self._startedOn = self.checkAndConvertNullable(value, datetime, "startedOn")
83
+
84
+ @property
85
+ def duration(self) -> Optional[float]:
86
+ return self._duration
87
+
88
+ @duration.setter
89
+ def duration(self, value):
90
+ self._duration = self.checkAndConvertNullable(value, float, "duration")
91
+
92
+ @property
93
+ def errors(self) -> Optional[List[DataSourceStatusError]]:
94
+ return self._errors
95
+
96
+ @errors.setter
97
+ def errors(self, value):
98
+ self._errors = self.checkListAndConvertNullable(
99
+ value, DataSourceStatusError, "errors"
100
+ )
101
+
102
+ @property
103
+ def info(self) -> Optional[dict]:
104
+ return self._info
105
+
106
+ @info.setter
107
+ def info(self, value):
108
+ self._info = self.checkAndConvertNullable(value, dict, "info")
@@ -0,0 +1,16 @@
1
+ from LOGS.Auxiliary.Decorators import Endpoint
2
+ from LOGS.Entities.DataSourceStatus import DataSourceStatus
3
+ from LOGS.Entities.DataSourceStatusRequestParameter import (
4
+ DataSourceStatusRequestParameter,
5
+ )
6
+ from LOGS.Entity.EntityIterator import EntityIterator
7
+
8
+
9
+ @Endpoint("data_sources_status")
10
+ class DataSourceStatusIterator(
11
+ EntityIterator[DataSourceStatus, DataSourceStatusRequestParameter]
12
+ ):
13
+ """LOGS connected class DataSourceStatus iterator"""
14
+
15
+ _generatorType = DataSourceStatus
16
+ _parameterType = DataSourceStatusRequestParameter
@@ -0,0 +1,31 @@
1
+ from dataclasses import dataclass, field
2
+ from datetime import datetime
3
+ from typing import List, Optional, Type, cast
4
+
5
+ from typing_extensions import Self
6
+
7
+ from LOGS.Entities.BridgeType import BridgeType
8
+ from LOGS.Entities.RunState import RunState
9
+ from LOGS.Entity.EntityRequestParameter import EntityRequestParameter
10
+ from LOGS.Entity.IGenericEntityOrderBy import IGenericEntitySortingOptions
11
+
12
+
13
+ class DataSourceStatusSortingOptions(IGenericEntitySortingOptions):
14
+ STARTED_ON: Self = cast(Self, "STARTED_ON")
15
+
16
+
17
+ @dataclass
18
+ class DataSourceStatusRequestParameter(
19
+ EntityRequestParameter[DataSourceStatusSortingOptions]
20
+ ):
21
+ _orderByType: Type[DataSourceStatusSortingOptions] = field(
22
+ default=DataSourceStatusSortingOptions, init=False
23
+ )
24
+
25
+ dataSourceIds: Optional[List[int]] = None
26
+ types: Optional[List[BridgeType]] = None
27
+ runStates: Optional[List[RunState]] = None
28
+ durationInSecondsMin: Optional[float] = None
29
+ durationInSecondsMax: Optional[float] = None
30
+ startedOnFrom: Optional[datetime] = None
31
+ startedOnTo: Optional[datetime] = None
@@ -0,0 +1,12 @@
1
+ from LOGS.Auxiliary.Decorators import Endpoint
2
+ from LOGS.Entities.DataSource import DataSource
3
+ from LOGS.Entities.DataSourceRequestParameter import DataSourceRequestParameter
4
+ from LOGS.Entity.EntityIterator import EntityIterator
5
+
6
+
7
+ @Endpoint("data_sources")
8
+ class DataSources(EntityIterator[DataSource, DataSourceRequestParameter]):
9
+ """LOGS connected class DataSource iterator"""
10
+
11
+ _generatorType = DataSource
12
+ _parameterType = DataSourceRequestParameter
@@ -0,0 +1,439 @@
1
+ import os
2
+ from datetime import datetime
3
+ from typing import TYPE_CHECKING, Any, Dict, List, Optional, Sequence, Union
4
+
5
+ from deprecation import deprecated # type: ignore
6
+
7
+ from LOGS.Auxiliary.Constants import Constants
8
+ from LOGS.Auxiliary.Decorators import Endpoint, UiEndpoint
9
+ from LOGS.Auxiliary.Exceptions import (
10
+ EntityFetchingException,
11
+ EntityIncompleteException,
12
+ LOGSException,
13
+ )
14
+ from LOGS.Auxiliary.MinimalModelGenerator import MinimalModelGenerator
15
+ from LOGS.Auxiliary.ParameterHelper import ParameterHelper
16
+ from LOGS.Converter import Converter
17
+ from LOGS.Converter.Conversion import Conversion
18
+ from LOGS.Converter.ExportParameters import ExportParameters
19
+ from LOGS.Entities.DatasetBase import DatasetBase
20
+ from LOGS.Entities.DatasetModels import DatasetSource, ParsedMetadata
21
+ from LOGS.Entities.Datatrack import Datatrack
22
+ from LOGS.Entities.FileEntry import FileEntry
23
+ from LOGS.Entities.HierarchyNode import HierarchyNode
24
+ from LOGS.Entities.Track import Track
25
+ from LOGS.Interfaces.IEntryRecord import IEntryRecord
26
+ from LOGS.Interfaces.ILockableEntity import ILockableEntity
27
+ from LOGS.Interfaces.IModificationRecord import IModificationRecord
28
+ from LOGS.Interfaces.IOwnedEntity import IOwnedEntity
29
+ from LOGS.Interfaces.IPermissionedEntity import IGenericPermissionEntity
30
+ from LOGS.Interfaces.IProjectBased import IProjectBased
31
+ from LOGS.Interfaces.ISignableEntity import ISignableEntity
32
+ from LOGS.Interfaces.ISoftDeletable import ISoftDeletable
33
+ from LOGS.Interfaces.ITypedEntity import ITypedEntity
34
+ from LOGS.Interfaces.IUniqueEntity import IUniqueEntity
35
+ from LOGS.LOGSConnection import LOGSConnection
36
+ from LOGS.Parameters.ParameterList import ParameterList
37
+
38
+ if TYPE_CHECKING:
39
+ from LOGS.Entities.BridgeMinimal import BridgeMinimal
40
+ from LOGS.Entities.DataFormatMinimal import DataFormatMinimal
41
+
42
+
43
+ @Endpoint("datasets")
44
+ @UiEndpoint("#data")
45
+ class Dataset(
46
+ DatasetBase,
47
+ IUniqueEntity,
48
+ ITypedEntity,
49
+ IOwnedEntity,
50
+ IProjectBased,
51
+ IEntryRecord,
52
+ IModificationRecord,
53
+ ISoftDeletable,
54
+ ILockableEntity,
55
+ IGenericPermissionEntity,
56
+ ISignableEntity,
57
+ ):
58
+
59
+ # state of additionally fetched data
60
+ _noParameters = True
61
+ _noExports = True
62
+ _noParameterTree = True
63
+
64
+ # private attributes
65
+ _parameterHelper: Optional[ParameterHelper] = None
66
+
67
+ # fields
68
+ _automaticName: Optional[str] = None
69
+ _isManuallyNamed: Optional[bool] = None
70
+ _creationDate: Optional[datetime] = None
71
+ _claimed: Optional[bool] = None
72
+ _bridge: Optional["BridgeMinimal"] = None
73
+ _parsedMetadata: Optional[ParsedMetadata] = None
74
+ _source: Optional[DatasetSource] = None
75
+
76
+ # special fetched fields
77
+ _parameters: Optional[Dict[str, Any]] = None
78
+ _parameterTree: Optional[ParameterList] = None
79
+ _exports: Optional[List[Converter]] = None
80
+
81
+ def __init__(
82
+ self,
83
+ ref=None,
84
+ id: Optional[int] = None,
85
+ connection: Optional[LOGSConnection] = None,
86
+ files: Optional[Sequence[Constants.FILE_TYPE]] = None,
87
+ formatOrFormatId: Optional[Union[str, "DataFormatMinimal"]] = None,
88
+ pathPrefixToStrip: Optional[str] = None,
89
+ pathPrefixToAdd: Optional[str] = None,
90
+ ):
91
+ super().__init__(ref=ref, id=id, connection=connection)
92
+
93
+ t = type(self)
94
+ self._noSerialize += [
95
+ t.parameters.fget.__name__, # type: ignore
96
+ t.parameterTree.fget.__name__, # type: ignore
97
+ t.formatVersion.fget.__name__, # type: ignore
98
+ t.parserLogs.fget.__name__, # type: ignore
99
+ t.tracks.fget.__name__, # type: ignore
100
+ t.datatracks.fget.__name__, # type: ignore
101
+ t.tracksHierarchy.fget.__name__, # type: ignore
102
+ t.exports.fget.__name__, # type: ignore
103
+ ]
104
+
105
+ if isinstance(ref, Dataset):
106
+ self._format = ref._format
107
+
108
+ if formatOrFormatId:
109
+ self.format = formatOrFormatId
110
+
111
+ if files:
112
+ if not self._format or not self._format.id:
113
+ raise LOGSException(
114
+ "Cannot create %s object from files parameter without a format"
115
+ % type(self).__name__
116
+ )
117
+
118
+ self._files = FileEntry.entriesFromFiles(files)
119
+ if self._files is not None:
120
+ for file in self._files:
121
+ if pathPrefixToStrip and file.path:
122
+ file.modifyPathPrefix(pathPrefixToStrip, pathPrefixToAdd)
123
+
124
+ def fromDict(self, ref) -> None:
125
+ if isinstance(ref, dict):
126
+ if "parameters" in ref:
127
+ self._parameters = self.checkAndConvertNullable(
128
+ ref["parameters"], dict, "parameters"
129
+ )
130
+ self._noParameters = False
131
+ if "parameterTree" in ref:
132
+ self._parameterTree = self.checkAndConvertNullable(
133
+ ref["parameterTree"], ParameterList, "parameters"
134
+ )
135
+ self._noParameterTree = False
136
+
137
+ infoFields = [
138
+ "formatVersion",
139
+ "parserLogs",
140
+ "tracks",
141
+ "datatracks",
142
+ "tracksHierarchy",
143
+ "parsingState",
144
+ ]
145
+
146
+ self._noInfo = not all(f in ref for f in infoFields)
147
+
148
+ info = {}
149
+ for field in infoFields:
150
+ if field in ref:
151
+ info[field] = ref[field]
152
+ del ref[field]
153
+
154
+ super().fromDict(ref=ref)
155
+ self._setInfo(info)
156
+
157
+ def fetchParameters(self):
158
+ connection, endpoint, id = self._getConnectionData()
159
+
160
+ parameters, responseError = connection.getEndpoint(
161
+ endpoint + [id, "parameters"]
162
+ )
163
+ if responseError:
164
+ raise EntityFetchingException(entity=self, responseError=responseError)
165
+
166
+ if isinstance(parameters, dict):
167
+ if "url" in parameters:
168
+ del parameters["url"]
169
+ self._parameters = parameters
170
+ else:
171
+ self._parameters = {}
172
+
173
+ self._parameterHelper = ParameterHelper(self._parameters)
174
+ self._noParameters = False
175
+
176
+ def fetchParameterTree(self):
177
+ connection, endpoint, id = self._getConnectionData()
178
+
179
+ parameters, responseError = connection.getEndpoint(
180
+ endpoint + [id, "parameter_tree"]
181
+ )
182
+ if responseError:
183
+ raise EntityFetchingException(entity=self, responseError=responseError)
184
+
185
+ if parameters == "":
186
+ parameters = None
187
+
188
+ self._parameterTree = self.checkAndConvertNullable(
189
+ parameters, ParameterList, "parameterTree"
190
+ )
191
+
192
+ self._noParameterTree = False
193
+
194
+ def fetchExports(self):
195
+ connection, endpoint, id = self._getConnectionData()
196
+
197
+ exports, responseError = connection.getEndpoint(endpoint + [id, "exports"])
198
+ if responseError:
199
+ raise EntityFetchingException(entity=self, responseError=responseError)
200
+
201
+ self.exports = exports
202
+ self._noExports = False
203
+
204
+ def clearCache(self):
205
+ dataDir = self._getDataDir()
206
+ if dataDir and os.path.exists(dataDir) and self.datatracks:
207
+ for datatrack in self.datatracks:
208
+ datatrack.clearCache()
209
+ os.rmdir(dataDir)
210
+
211
+ def fetchFull(self):
212
+ self.fetchParameters()
213
+ self.fetchInfo()
214
+ self.fetchZipSize()
215
+ self.fetchExports()
216
+
217
+ def getParameter(self, key, removeUnit=False):
218
+ if not self._parameterHelper:
219
+ self._parameterHelper = ParameterHelper(self.parameters)
220
+ return self._parameterHelper.get(key, removeUnit)
221
+
222
+ def _requestReport(self, exportId: str, parameters: Optional[ExportParameters]):
223
+ connection, endpoint, id = self._getConnectionData()
224
+ converterEndpoint: Any = endpoint + [id, "exports", exportId]
225
+ payload = parameters.toDict() if parameters else {}
226
+ data, responseError = connection.postEndpoint(converterEndpoint, data=payload)
227
+ if responseError:
228
+ raise EntityFetchingException(entity=self, responseError=responseError)
229
+
230
+ # TODO: create a report type to wait for the report to be generated
231
+ # TODO: maybe a class "Conversion" can be created that has a state and also and automatic awaiter function or so
232
+ conversion = self.checkAndConvert(data, Conversion, f"Conversion_to_{exportId}")
233
+ conversion._endpoint = converterEndpoint
234
+ conversion._payload = payload
235
+ conversion._parentEntity = self
236
+ return conversion
237
+
238
+ def exportTo(
239
+ self, exportId: str, parameters: Optional[Union[ExportParameters, dict]] = None
240
+ ):
241
+
242
+ if self._noExports:
243
+ self.fetchExports()
244
+
245
+ if self.exports is None:
246
+ raise LOGSException(f"Export id '{exportId}' not found in exports")
247
+
248
+ exports = {e.exportId: e for e in self.exports}
249
+ exports.update({e.id: e for e in self.exports})
250
+ if exportId not in exports:
251
+ raise LOGSException(f"Export id '{exportId}' not found in exports")
252
+
253
+ export = exports[exportId]
254
+ p = export.requestParameter
255
+ if parameters is not None and p is not None:
256
+ if isinstance(parameters, dict):
257
+ p.fromDict(parameters)
258
+ elif isinstance(parameters, ExportParameters):
259
+ if parameters._parentId is None or parameters._parentId != p._parentId:
260
+ raise LOGSException(
261
+ f"The passed export parameters is not generated by and valid export format. (Expected class '{p.identifier}')"
262
+ )
263
+ else:
264
+ raise LOGSException(
265
+ f"Invalid parameter type '{type(parameters).__name__}'. (Expected 'dict' or '{ExportParameters.__name__}')"
266
+ )
267
+
268
+ return self._requestReport(exportId, p)
269
+
270
+ def getTrackById(self, trackId: str) -> Optional[Track]:
271
+ if not self._tracks:
272
+ return None
273
+ for track in self._tracks:
274
+ if track.id == trackId:
275
+ return track
276
+ return None
277
+
278
+ @property
279
+ def format(self) -> Optional["DataFormatMinimal"]:
280
+ return self._format
281
+
282
+ @format.setter
283
+ def format(self, value):
284
+ if isinstance(value, str):
285
+ value = {"id": value}
286
+ self._format = MinimalModelGenerator.MinimalFromSingle(
287
+ value, "DataFormatMinimal", "format", connection=self._getConnection()
288
+ )
289
+
290
+ @property
291
+ def creationDate(self) -> Optional[datetime]:
292
+ return self._creationDate
293
+
294
+ @creationDate.setter
295
+ def creationDate(self, value):
296
+ self._creationDate = self.checkAndConvertNullable(
297
+ value, datetime, "creationDate"
298
+ )
299
+
300
+ @property
301
+ def claimed(self) -> Optional[bool]:
302
+ return self._claimed
303
+
304
+ @claimed.setter
305
+ def claimed(self, value):
306
+ self._claimed = self.checkAndConvertNullable(value, bool, "claimed")
307
+
308
+ @property
309
+ def parsedMetadata(self) -> Optional[ParsedMetadata]:
310
+ return self._parsedMetadata
311
+
312
+ @parsedMetadata.setter
313
+ def parsedMetadata(self, value):
314
+ self._parsedMetadata = self.checkAndConvertNullable(
315
+ value, ParsedMetadata, "parsedMetadata"
316
+ )
317
+
318
+ @property
319
+ def parameters(self) -> Optional[Dict[str, Any]]:
320
+ if self._noParameters:
321
+ raise EntityIncompleteException(
322
+ self,
323
+ parameterName="parameters",
324
+ functionName=f"{self.fetchParameters.__name__}()",
325
+ )
326
+ return self._parameters
327
+
328
+ @property
329
+ def parameterTree(self) -> Optional[ParameterList]:
330
+ if self._noParameterTree:
331
+ raise EntityIncompleteException(
332
+ self,
333
+ parameterName="parameterTree",
334
+ functionName=f"{self.fetchParameterTree.__name__}()",
335
+ hasFetchFull=False,
336
+ )
337
+ return self._parameterTree
338
+
339
+ @property
340
+ def formatVersion(self) -> Optional[int]:
341
+ if self._noInfo:
342
+ raise EntityIncompleteException(
343
+ self,
344
+ parameterName="formatVersion",
345
+ functionName=f"{self.fetchInfo.__name__}()",
346
+ )
347
+ return self._formatVersion
348
+
349
+ @property
350
+ def tracks(self) -> Optional[List[Track]]:
351
+ if self._noInfo:
352
+ raise EntityIncompleteException(
353
+ self,
354
+ parameterName="tracks",
355
+ functionName=f"{self.fetchInfo.__name__}()",
356
+ )
357
+ return self._tracks
358
+
359
+ @property
360
+ def datatracks(self) -> Optional[List[Datatrack]]:
361
+ if self._noInfo:
362
+ raise EntityIncompleteException(
363
+ self,
364
+ parameterName="datatracks",
365
+ functionName=f"{self.fetchInfo.__name__}()",
366
+ )
367
+ return self._datatracks
368
+
369
+ @property
370
+ def tracksHierarchy(self) -> Optional[HierarchyNode]:
371
+ if self._noInfo:
372
+ raise EntityIncompleteException(
373
+ self,
374
+ parameterName="tracksHierarchy",
375
+ functionName=f"{self.fetchInfo.__name__}()",
376
+ )
377
+ return self._tracksHierarchy
378
+
379
+ @property
380
+ def bridge(self) -> Optional["BridgeMinimal"]:
381
+ return self._bridge
382
+
383
+ @bridge.setter
384
+ def bridge(self, value):
385
+ self._bridge = MinimalModelGenerator.MinimalFromSingle(
386
+ value, "BridgeMinimal", "bridge", connection=self._getConnection()
387
+ )
388
+
389
+ @property
390
+ def bridgeId(self) -> Optional[int]:
391
+ return self._bridge.id if self._bridge else None
392
+
393
+ @bridgeId.setter
394
+ def bridgeId(self, value):
395
+ self._bridge = MinimalModelGenerator.MinimalFromSingle(
396
+ value, "BridgeMinimal", "bridge", connection=self._getConnection()
397
+ )
398
+
399
+ @property
400
+ def exports(self) -> Optional[List[Converter]]:
401
+ if self._noExports:
402
+ raise EntityIncompleteException(
403
+ self,
404
+ parameterName="exports",
405
+ functionName=f"{self.fetchExports.__name__}()",
406
+ hasFetchFull=True,
407
+ )
408
+
409
+ return self._exports
410
+
411
+ @exports.setter
412
+ def exports(self, value):
413
+ self._exports = self.checkListAndConvertNullable(value, Converter, "exports")
414
+
415
+ @property
416
+ def source(self) -> Optional[DatasetSource]:
417
+ return self._source
418
+
419
+ @source.setter
420
+ def source(self, value):
421
+ self._source = self.checkAndConvertNullable(value, DatasetSource, "source")
422
+
423
+ @property
424
+ def isManuallyNamed(self) -> Optional[bool]:
425
+ return self._isManuallyNamed
426
+
427
+ @isManuallyNamed.setter
428
+ def isManuallyNamed(self, value):
429
+ self._isManuallyNamed = self.checkAndConvertNullable(
430
+ value, bool, "isManuallyNamed"
431
+ )
432
+
433
+ @property
434
+ def automaticName(self) -> Optional[str]:
435
+ return self._automaticName
436
+
437
+ @automaticName.setter
438
+ def automaticName(self, value):
439
+ self._automaticName = self.checkAndConvertNullable(value, str, "automaticName")