logs-py 2.9.6__py3-none-any.whl → 3.0.1__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 logs-py might be problematic. Click here for more details.
- LOGS/Auxiliary/DateTimeConverter.py +11 -1
- LOGS/Auxiliary/Exceptions.py +40 -4
- LOGS/Auxiliary/LOGSErrorResponse.py +4 -1
- LOGS/Auxiliary/MinimalModelGenerator.py +88 -28
- LOGS/Auxiliary/Tools.py +11 -0
- LOGS/Converter/Conversion.py +248 -0
- LOGS/Converter/Converter.py +96 -0
- LOGS/Converter/ConverterParameter.py +88 -0
- LOGS/Converter/ExportParamters.py +89 -0
- LOGS/Converter/__init__.py +13 -0
- LOGS/Entities/Bridge.py +6 -3
- LOGS/Entities/CustomField.py +96 -91
- LOGS/Entities/CustomFieldModels.py +57 -0
- LOGS/Entities/CustomFieldRelations.py +10 -0
- LOGS/Entities/CustomFieldRequestParameter.py +43 -15
- LOGS/Entities/CustomFieldValue.py +88 -0
- LOGS/Entities/CustomFieldValueConverter.py +66 -0
- LOGS/Entities/CustomType.py +187 -0
- LOGS/Entities/CustomTypeEntityType.py +11 -0
- LOGS/Entities/CustomTypeMinimal.py +8 -0
- LOGS/Entities/CustomTypeRelations.py +59 -0
- LOGS/Entities/CustomTypeRequestParameter.py +61 -0
- LOGS/Entities/CustomTypeSection.py +39 -0
- LOGS/Entities/CustomTypes.py +12 -0
- LOGS/Entities/DataSource.py +28 -14
- LOGS/Entities/Dataset.py +274 -136
- LOGS/Entities/DatasetCreator.py +23 -72
- LOGS/Entities/DatasetInfo.py +23 -2
- LOGS/Entities/DatasetModels.py +31 -0
- LOGS/Entities/DatasetRequestParameter.py +45 -32
- LOGS/Entities/Datatrack.py +74 -30
- LOGS/Entities/DatatrackFormattedTable.py +25 -0
- LOGS/Entities/DatatrackGeneric.py +34 -0
- LOGS/Entities/DatatrackImage.py +25 -0
- LOGS/Entities/DatatrackNumericArray.py +9 -39
- LOGS/Entities/DatatrackNumericMatrix.py +86 -0
- LOGS/Entities/DocumentRequestParameter.py +2 -2
- LOGS/Entities/EntitiesRequestParameter.py +2 -2
- LOGS/Entities/Experiment.py +3 -3
- LOGS/Entities/FileExcludePattern.py +8 -0
- LOGS/Entities/FormatFormat.py +22 -1
- LOGS/Entities/FormatFormatRequestParameter.py +2 -1
- LOGS/Entities/FormatFormats.py +1 -1
- LOGS/Entities/FormattedTable/DatatypeFormattedTable.py +135 -0
- LOGS/Entities/FormattedTable/DatatypeFormattedTableCell.py +108 -0
- LOGS/Entities/FormattedTable/DatatypeFormattedTableSettings.py +11 -0
- LOGS/Entities/FormattedTable/__init__.py +9 -0
- LOGS/Entities/ILiterarTypedEntity.py +19 -0
- LOGS/Entities/Instrument.py +3 -3
- LOGS/Entities/Inventories.py +12 -0
- LOGS/Entities/Inventory.py +95 -0
- LOGS/Entities/InventoryMinimal.py +20 -0
- LOGS/Entities/InventoryRelations.py +23 -0
- LOGS/Entities/InventoryRequestParameter.py +53 -0
- LOGS/Entities/LabNotebook.py +37 -0
- LOGS/Entities/LabNotebookEntry.py +47 -24
- LOGS/Entities/LabNotebookEntryContent/BasicAttribute.py +15 -0
- LOGS/Entities/LabNotebookEntryContent/EntityAttribute.py +85 -0
- LOGS/Entities/LabNotebookEntryContent/EntryContentBlockquote.py +13 -0
- LOGS/Entities/LabNotebookEntryContent/EntryContentBulletList.py +17 -0
- LOGS/Entities/LabNotebookEntryContent/EntryContentCallout.py +40 -0
- LOGS/Entities/LabNotebookEntryContent/EntryContentContentPlaceholderNode.py +31 -0
- LOGS/Entities/LabNotebookEntryContent/EntryContentConverter.py +207 -0
- LOGS/Entities/LabNotebookEntryContent/EntryContentDocument.py +8 -0
- LOGS/Entities/LabNotebookEntryContent/EntryContentEntity.py +13 -0
- LOGS/Entities/LabNotebookEntryContent/EntryContentEntityMention.py +31 -0
- LOGS/Entities/LabNotebookEntryContent/EntryContentHeading.py +33 -0
- LOGS/Entities/LabNotebookEntryContent/EntryContentHorizontalRule.py +12 -0
- LOGS/Entities/LabNotebookEntryContent/EntryContentItem.py +37 -0
- LOGS/Entities/LabNotebookEntryContent/EntryContentListItem.py +49 -0
- LOGS/Entities/LabNotebookEntryContent/EntryContentOrderedList.py +31 -0
- LOGS/Entities/LabNotebookEntryContent/EntryContentParagraph.py +13 -0
- LOGS/Entities/LabNotebookEntryContent/EntryContentTable.py +17 -0
- LOGS/Entities/LabNotebookEntryContent/EntryContentTableCell.py +40 -0
- LOGS/Entities/LabNotebookEntryContent/EntryContentTableRow.py +8 -0
- LOGS/Entities/LabNotebookEntryContent/EntryContentTaskList.py +17 -0
- LOGS/Entities/LabNotebookEntryContent/EntryContentTaskListItem.py +31 -0
- LOGS/Entities/LabNotebookEntryContent/EntryContentText.py +33 -0
- LOGS/Entities/LabNotebookEntryContent/IEntryContentWithAttribute.py +23 -0
- LOGS/Entities/LabNotebookEntryContent/IEntryContentWithContent.py +38 -0
- LOGS/Entities/LabNotebookEntryContent/IEntryContentWithTextAttribute.py +16 -0
- LOGS/Entities/LabNotebookEntryContent/TextAttribute.py +46 -0
- LOGS/Entities/LabNotebookEntryContent/TextMarkAtributes.py +64 -0
- LOGS/Entities/LabNotebookEntryContent/TextMarkConverter.py +45 -0
- LOGS/Entities/LabNotebookEntryContent/TextMarks.py +71 -0
- LOGS/Entities/LabNotebookEntryContent/__init__.py +34 -0
- LOGS/Entities/LabNotebookEntryRequestParameter.py +2 -0
- LOGS/Entities/LabNotebookExperiment.py +52 -0
- LOGS/Entities/LabNotebookExperimentMinimal.py +8 -0
- LOGS/Entities/LabNotebookExperimentRequestParameter.py +49 -0
- LOGS/Entities/LabNotebookExperiments.py +16 -0
- LOGS/Entities/LabNotebookMinimal.py +19 -0
- LOGS/Entities/LabNotebookModels.py +14 -0
- LOGS/Entities/LabNotebookRequestParameter.py +43 -0
- LOGS/Entities/LabNotebooks.py +12 -0
- LOGS/Entities/Method.py +3 -3
- LOGS/Entities/ParserLog.py +4 -0
- LOGS/Entities/Person.py +2 -2
- LOGS/Entities/PersonRequestParameter.py +1 -0
- LOGS/Entities/Project.py +7 -7
- LOGS/Entities/{ProjectUserPermission.py → ProjectPersonPermission.py} +14 -4
- LOGS/Entities/Role.py +3 -3
- LOGS/Entities/RunState.py +1 -0
- LOGS/Entities/Sample.py +36 -57
- LOGS/Entities/SampleRequestParameter.py +30 -15
- LOGS/Entities/Track.py +8 -4
- LOGS/Entities/TrackData.py +11 -0
- LOGS/Entities/TrackImage.py +21 -0
- LOGS/Entities/TrackImageData.py +20 -0
- LOGS/Entities/TrackMatrix.py +28 -0
- LOGS/Entities/TrackMatrixData.py +22 -0
- LOGS/Entities/TrackTable.py +21 -0
- LOGS/Entities/TrackTableData.py +22 -0
- LOGS/Entities/TrackXY.py +5 -1
- LOGS/Entities/TrackXYComplex.py +1 -1
- LOGS/Entities/__init__.py +26 -7
- LOGS/Entity/ConnectedEntity.py +39 -1
- LOGS/Entity/Entity.py +9 -14
- LOGS/Entity/SerializeableContent.py +62 -5
- LOGS/Interfaces/IHierarchyType.py +63 -0
- LOGS/Interfaces/IPermissionedEntity.py +29 -5
- LOGS/Interfaces/IProjectBased.py +1 -1
- LOGS/Interfaces/ITypedEntity.py +69 -12
- LOGS/Interfaces/IVersionedEntity.py +39 -0
- LOGS/LOGS.py +137 -46
- LOGS/LOGSConnection.py +52 -24
- LOGS/LOGSOptions.py +8 -0
- LOGS/Parameters/Color.py +92 -0
- LOGS/Parameters/ParameterBase.py +55 -0
- LOGS/Parameters/ParameterConverter.py +24 -0
- LOGS/Parameters/ParameterElement.py +99 -0
- LOGS/Parameters/ParameterList.py +52 -0
- LOGS/Parameters/ParameterTable.py +64 -0
- LOGS/Parameters/__init__.py +13 -0
- LOGS/__init__.py +1 -0
- {logs_py-2.9.6.dist-info → logs_py-3.0.1.dist-info}/METADATA +2 -1
- logs_py-3.0.1.dist-info/RECORD +263 -0
- LOGS/Entities/CustomFieldEnums.py +0 -25
- LOGS/Entities/DatasetType.py +0 -7
- LOGS/Entities/DatasetTypeMinimal.py +0 -8
- LOGS/Entities/SampleType.py +0 -34
- LOGS/Entities/SampleTypeMinimal.py +0 -8
- LOGS/Entities/SampleTypeRequestParameter.py +0 -8
- LOGS/Entities/SampleTypes.py +0 -12
- logs_py-2.9.6.dist-info/RECORD +0 -183
- {logs_py-2.9.6.dist-info → logs_py-3.0.1.dist-info}/WHEEL +0 -0
- {logs_py-2.9.6.dist-info → logs_py-3.0.1.dist-info}/top_level.txt +0 -0
LOGS/Entities/Dataset.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import os
|
|
2
|
+
from dataclasses import dataclass
|
|
2
3
|
from datetime import datetime
|
|
3
4
|
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Sequence, Union, cast
|
|
4
5
|
|
|
@@ -13,7 +14,6 @@ from LOGS.Auxiliary.Exceptions import (
|
|
|
13
14
|
)
|
|
14
15
|
from LOGS.Auxiliary.MinimalModelGenerator import (
|
|
15
16
|
BridgeMinimalFromDict,
|
|
16
|
-
DatasetTypeMinimalFromDict,
|
|
17
17
|
ExperimentMinimalFromDict,
|
|
18
18
|
FormatMinimalFromDict,
|
|
19
19
|
InstrumentMinimalFromDict,
|
|
@@ -23,26 +23,33 @@ from LOGS.Auxiliary.MinimalModelGenerator import (
|
|
|
23
23
|
)
|
|
24
24
|
from LOGS.Auxiliary.ParameterHelper import ParameterHelper
|
|
25
25
|
from LOGS.Auxiliary.Tools import Tools
|
|
26
|
+
from LOGS.Converter import Converter
|
|
27
|
+
from LOGS.Converter.Conversion import Conversion
|
|
28
|
+
from LOGS.Converter.ExportParamters import ExportParamters
|
|
26
29
|
from LOGS.Entities.DatasetInfo import DatasetInfo
|
|
30
|
+
from LOGS.Entities.DatasetModels import DatasetSourceType, ViewableEntityTypes
|
|
27
31
|
from LOGS.Entities.DatasetRelations import DatasetRelations
|
|
28
32
|
from LOGS.Entities.DatasetRequestParameter import ParsingStates
|
|
29
|
-
from LOGS.Entities.DatasetTypeMinimal import DatasetTypeMinimal
|
|
30
33
|
from LOGS.Entities.Datatrack import Datatrack
|
|
31
34
|
from LOGS.Entities.FileEntry import FileEntry
|
|
32
35
|
from LOGS.Entities.HierarchyNode import HierarchyNode
|
|
33
36
|
from LOGS.Entities.ParserLog import ParserLog
|
|
34
37
|
from LOGS.Entities.Track import Track
|
|
38
|
+
from LOGS.Entity.EntityMinimalWithIntId import EntityMinimalWithIntId
|
|
35
39
|
from LOGS.Entity.EntityWithIntId import IEntityWithIntId
|
|
36
40
|
from LOGS.Entity.SerializeableContent import SerializeableContent
|
|
41
|
+
from LOGS.Interfaces.ICreationRecord import ICreationRecord
|
|
42
|
+
from LOGS.Interfaces.IModificationRecord import IModificationRecord
|
|
37
43
|
from LOGS.Interfaces.INamedEntity import INamedEntity
|
|
38
44
|
from LOGS.Interfaces.IOwnedEntity import IOwnedEntity
|
|
39
|
-
from LOGS.Interfaces.IPermissionedEntity import
|
|
45
|
+
from LOGS.Interfaces.IPermissionedEntity import GenericPermissionEntity
|
|
40
46
|
from LOGS.Interfaces.IProjectBased import IProjectBased
|
|
41
47
|
from LOGS.Interfaces.IRelatedEntity import IRelatedEntity
|
|
42
48
|
from LOGS.Interfaces.ISoftDeletable import ISoftDeletable
|
|
43
49
|
from LOGS.Interfaces.ITypedEntity import ITypedEntity
|
|
44
50
|
from LOGS.Interfaces.IUniqueEntity import IUniqueEntity
|
|
45
51
|
from LOGS.LOGSConnection import LOGSConnection, ResponseTypes
|
|
52
|
+
from LOGS.Parameters.ParameterList import ParameterList
|
|
46
53
|
|
|
47
54
|
if TYPE_CHECKING:
|
|
48
55
|
from LOGS.Entities.BridgeMinimal import BridgeMinimal
|
|
@@ -52,7 +59,6 @@ if TYPE_CHECKING:
|
|
|
52
59
|
from LOGS.Entities.InstrumentMinimal import InstrumentMinimal
|
|
53
60
|
from LOGS.Entities.MethodMinimal import MethodMinimal
|
|
54
61
|
from LOGS.Entities.PersonMinimal import PersonMinimal
|
|
55
|
-
from LOGS.Entities.ProjectMinimal import ProjectMinimal
|
|
56
62
|
from LOGS.Entities.SampleMinimal import SampleMinimal
|
|
57
63
|
|
|
58
64
|
|
|
@@ -63,54 +69,69 @@ class ParsedMetadata(SerializeableContent):
|
|
|
63
69
|
TrackViewerTypes: List[str] = []
|
|
64
70
|
|
|
65
71
|
|
|
72
|
+
@dataclass
|
|
73
|
+
class DatasetSource:
|
|
74
|
+
id: Optional[int] = None
|
|
75
|
+
type: Optional[DatasetSourceType] = None
|
|
76
|
+
name: Optional[str] = None
|
|
77
|
+
|
|
78
|
+
|
|
66
79
|
@Endpoint("datasets")
|
|
67
80
|
@UiEndpoint("#data")
|
|
68
81
|
class Dataset(
|
|
82
|
+
IEntityWithIntId,
|
|
83
|
+
GenericPermissionEntity,
|
|
69
84
|
INamedEntity,
|
|
70
|
-
IProjectBased,
|
|
71
85
|
IOwnedEntity,
|
|
72
|
-
|
|
86
|
+
IProjectBased,
|
|
73
87
|
IRelatedEntity[DatasetRelations],
|
|
74
|
-
ITypedEntity,
|
|
75
88
|
ISoftDeletable,
|
|
89
|
+
ITypedEntity,
|
|
76
90
|
IUniqueEntity,
|
|
77
|
-
|
|
91
|
+
ICreationRecord,
|
|
92
|
+
IModificationRecord,
|
|
78
93
|
):
|
|
79
94
|
_noInfo = True
|
|
80
95
|
_noParameters = True
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
_instrument: Optional["InstrumentMinimal"]
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
96
|
+
_noExports = True
|
|
97
|
+
_noParameterTree = True
|
|
98
|
+
_relationType = DatasetRelations
|
|
99
|
+
|
|
100
|
+
_acquisitionDate: Optional[datetime] = None
|
|
101
|
+
_automaticName: Optional[str] = None
|
|
102
|
+
_bridge: Optional["BridgeMinimal"] = None
|
|
103
|
+
_claimed: Optional[bool] = None
|
|
104
|
+
_customImport: Optional[EntityMinimalWithIntId] = None
|
|
105
|
+
_datatracks: Optional[List[Datatrack]] = None
|
|
106
|
+
_equipments: Optional[List["EquipmentMinimal"]] = None
|
|
107
|
+
_experiment: Optional["ExperimentMinimal"] = None
|
|
108
|
+
_exports: Optional[List[Converter]] = None
|
|
109
|
+
_files: Optional[List[FileEntry]] = None
|
|
110
|
+
_format: Optional["FormatMinimal"] = None
|
|
111
|
+
_formatVersion: Optional[int] = None
|
|
112
|
+
_instrument: Optional["InstrumentMinimal"] = None
|
|
113
|
+
_isManuallyNamed: Optional[bool] = None
|
|
114
|
+
_isViewableEntity: Optional[bool] = None
|
|
115
|
+
_legacyId: Optional[str] = None
|
|
116
|
+
_method: Optional["MethodMinimal"] = None
|
|
117
|
+
_notes: Optional[str] = None
|
|
118
|
+
_operators: Optional[List["PersonMinimal"]] = None
|
|
119
|
+
_other: Optional[str] = None
|
|
120
|
+
_parameterHelper: Optional[ParameterHelper] = None
|
|
121
|
+
_parameters: Optional[Dict[str, Any]] = None
|
|
122
|
+
_parameterTree: Optional[ParameterList] = None
|
|
123
|
+
_parsedMetadata: Optional[ParsedMetadata] = None
|
|
124
|
+
_parserLogs: Optional[List[ParserLog]] = None
|
|
125
|
+
_parsingState: Optional[ParsingStates] = None
|
|
126
|
+
_path: Optional[str] = None
|
|
127
|
+
_sample: Optional["SampleMinimal"] = None
|
|
128
|
+
_source: Optional[DatasetSource] = None
|
|
129
|
+
_sourceBaseDirectory: Optional[str] = None
|
|
130
|
+
_sourceRelativeDirectory: Optional[str] = None
|
|
131
|
+
_tracks: Optional[List[Track]] = None
|
|
132
|
+
_tracksHierarchy: Optional[HierarchyNode] = None
|
|
133
|
+
_viewableEntityType: Optional[ViewableEntityTypes] = None
|
|
134
|
+
_zipSize: Optional[int] = None
|
|
114
135
|
|
|
115
136
|
def __init__(
|
|
116
137
|
self,
|
|
@@ -120,45 +141,18 @@ class Dataset(
|
|
|
120
141
|
files: Optional[Sequence[Constants.FILE_TYPE]] = None,
|
|
121
142
|
format: Optional[Union[str, "FormatMinimal"]] = None,
|
|
122
143
|
):
|
|
123
|
-
self._legacyId = None
|
|
124
|
-
self._type = None
|
|
125
|
-
self._format = None
|
|
126
|
-
self._acquisitionDate = None
|
|
127
|
-
self._path = None
|
|
128
|
-
self._method = None
|
|
129
|
-
self._experiment = None
|
|
130
|
-
self._claimed = None
|
|
131
|
-
self._notes = None
|
|
132
|
-
self._dateAdded = None
|
|
133
|
-
self._isViewableEntity = None
|
|
134
|
-
self._isDeleted = None
|
|
135
|
-
self._other = None
|
|
136
|
-
self._instrument = None
|
|
137
|
-
self._sample = None
|
|
138
|
-
self._bridge = None
|
|
139
|
-
self._operators = None
|
|
140
|
-
self._equipments = None
|
|
141
|
-
self._projects = None
|
|
142
|
-
self._parsingState = None
|
|
143
|
-
self._parsedMetadata = None
|
|
144
|
-
self._parameters = None
|
|
145
|
-
self._formatVersion = None
|
|
146
|
-
self._parserLogs = None
|
|
147
|
-
self._tracks = None
|
|
148
|
-
self._datatracks = None
|
|
149
|
-
self._tracksHierarchy = None
|
|
150
|
-
self._files = None
|
|
151
|
-
self._parameterHelper = None
|
|
152
|
-
self._zipSize = None
|
|
153
|
-
|
|
154
144
|
super().__init__(ref=ref, id=id, connection=connection)
|
|
145
|
+
|
|
146
|
+
t = type(self)
|
|
155
147
|
self._noSerialize += [
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
148
|
+
t.parameters.fget.__name__, # type: ignore
|
|
149
|
+
t.parameterTree.fget.__name__, # type: ignore
|
|
150
|
+
t.formatVersion.fget.__name__, # type: ignore
|
|
151
|
+
t.parserLogs.fget.__name__, # type: ignore
|
|
152
|
+
t.tracks.fget.__name__, # type: ignore
|
|
153
|
+
t.datatracks.fget.__name__, # type: ignore
|
|
154
|
+
t.tracksHierarchy.fget.__name__, # type: ignore
|
|
155
|
+
t.exports.fget.__name__, # type: ignore
|
|
162
156
|
]
|
|
163
157
|
|
|
164
158
|
if isinstance(ref, Dataset):
|
|
@@ -183,34 +177,31 @@ class Dataset(
|
|
|
183
177
|
ref["parameters"], dict, "parameters"
|
|
184
178
|
)
|
|
185
179
|
self._noParameters = False
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
ref["formatVersion"], int, "formatVersion"
|
|
190
|
-
)
|
|
191
|
-
self._noInfo = False
|
|
192
|
-
if "parserLogs" in ref:
|
|
193
|
-
self._parserLogs = self.checkListAndConvertNullable(
|
|
194
|
-
ref["parserLogs"], ParserLog, "parserLogs"
|
|
180
|
+
if "parameterTree" in ref:
|
|
181
|
+
self._parameterTree = self.checkAndConvertNullable(
|
|
182
|
+
ref["parameterTree"], ParameterList, "parameters"
|
|
195
183
|
)
|
|
196
|
-
self.
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
184
|
+
self._noParameterTree = False
|
|
185
|
+
|
|
186
|
+
infoFields = [
|
|
187
|
+
"formatVersion",
|
|
188
|
+
"parserLogs",
|
|
189
|
+
"tracks",
|
|
190
|
+
"datatracks",
|
|
191
|
+
"tracksHierarchy",
|
|
192
|
+
"parsingState",
|
|
193
|
+
]
|
|
194
|
+
|
|
195
|
+
self._noInfo = not all(f in ref for f in infoFields)
|
|
196
|
+
|
|
197
|
+
info = {}
|
|
198
|
+
for field in infoFields:
|
|
199
|
+
if field in ref:
|
|
200
|
+
info[field] = ref[field]
|
|
201
|
+
del ref[field]
|
|
212
202
|
|
|
213
203
|
super().fromDict(ref=ref)
|
|
204
|
+
self._setInfo(info)
|
|
214
205
|
|
|
215
206
|
def fetchZipSize(self):
|
|
216
207
|
connection, endpoint, id = self._getConnectionData()
|
|
@@ -243,13 +234,48 @@ class Dataset(
|
|
|
243
234
|
self._parameterHelper = ParameterHelper(self._parameters)
|
|
244
235
|
self._noParameters = False
|
|
245
236
|
|
|
246
|
-
def
|
|
237
|
+
def fetchParameterTree(self):
|
|
247
238
|
connection, endpoint, id = self._getConnectionData()
|
|
248
239
|
|
|
249
|
-
|
|
240
|
+
parameters, responseError = connection.getEndpoint(
|
|
241
|
+
endpoint + [id, "parameter_tree"]
|
|
242
|
+
)
|
|
243
|
+
if responseError:
|
|
244
|
+
raise EntityFetchingException(entity=self, responseError=responseError)
|
|
245
|
+
|
|
246
|
+
self._parameterTree = self.checkAndConvertNullable(
|
|
247
|
+
parameters, ParameterList, "parameterTree"
|
|
248
|
+
)
|
|
249
|
+
|
|
250
|
+
self._noParameterTree = False
|
|
251
|
+
|
|
252
|
+
def fetchExports(self):
|
|
253
|
+
connection, endpoint, id = self._getConnectionData()
|
|
254
|
+
|
|
255
|
+
exports, responseError = connection.getEndpoint(endpoint + [id, "exports"])
|
|
250
256
|
if responseError:
|
|
251
257
|
raise EntityFetchingException(entity=self, responseError=responseError)
|
|
252
258
|
|
|
259
|
+
self.exports = exports
|
|
260
|
+
self._noExports = False
|
|
261
|
+
|
|
262
|
+
def _getDataDir(self):
|
|
263
|
+
if self.cacheDir:
|
|
264
|
+
if not os.path.isdir(self.cacheDir):
|
|
265
|
+
raise LOGSException(
|
|
266
|
+
f"Specified cache directory '{self.cacheDir}' cannot be opened or is not a directory."
|
|
267
|
+
)
|
|
268
|
+
return self.cacheDir
|
|
269
|
+
return None
|
|
270
|
+
|
|
271
|
+
def clearCache(self):
|
|
272
|
+
dataDir = self._getDataDir()
|
|
273
|
+
if dataDir and os.path.exists(dataDir) and self.datatracks:
|
|
274
|
+
for datatrack in self.datatracks:
|
|
275
|
+
datatrack.clearCache()
|
|
276
|
+
os.rmdir(dataDir)
|
|
277
|
+
|
|
278
|
+
def _setInfo(self, data: dict):
|
|
253
279
|
info = DatasetInfo(data)
|
|
254
280
|
self._formatVersion = info.formatVersion
|
|
255
281
|
self._parserLogs = info.parserLogs
|
|
@@ -258,17 +284,20 @@ class Dataset(
|
|
|
258
284
|
self._tracksHierarchy = info.tracksHierarchy
|
|
259
285
|
self._parsingState = info.parsingState
|
|
260
286
|
|
|
287
|
+
dataDir = self._getDataDir()
|
|
288
|
+
|
|
261
289
|
trackLookup: Dict[str, Datatrack] = {}
|
|
262
290
|
if self._datatracks:
|
|
263
291
|
for datatrack in self._datatracks:
|
|
264
292
|
datatrack.connection = self.connection
|
|
265
|
-
datatrack.
|
|
293
|
+
datatrack.cacheDir = dataDir
|
|
266
294
|
if datatrack.id:
|
|
267
295
|
trackLookup[datatrack.id] = datatrack
|
|
268
296
|
|
|
269
297
|
if self._tracks:
|
|
270
298
|
for track in self._tracks:
|
|
271
299
|
track.connection = self.connection
|
|
300
|
+
track.cacheDir = dataDir
|
|
272
301
|
if track._dataIds:
|
|
273
302
|
track.datatracks = cast(
|
|
274
303
|
Any,
|
|
@@ -277,12 +306,31 @@ class Dataset(
|
|
|
277
306
|
for k, v in track._dataIds.items()
|
|
278
307
|
},
|
|
279
308
|
)
|
|
309
|
+
|
|
310
|
+
def fetchInfo(self):
|
|
311
|
+
connection, endpoint, id = self._getConnectionData()
|
|
312
|
+
|
|
313
|
+
data, responseError = connection.getEndpoint(endpoint + [id, "info"])
|
|
314
|
+
if responseError:
|
|
315
|
+
raise EntityFetchingException(entity=self, responseError=responseError)
|
|
316
|
+
|
|
317
|
+
dataDir = self._getDataDir()
|
|
318
|
+
if dataDir and not os.path.exists(dataDir):
|
|
319
|
+
os.mkdir(dataDir)
|
|
320
|
+
|
|
321
|
+
self._setInfo(cast(dict, data))
|
|
280
322
|
self._noInfo = False
|
|
323
|
+
if self._datatracks:
|
|
324
|
+
for datatrack in self._datatracks:
|
|
325
|
+
datatrack._endpoint = (
|
|
326
|
+
endpoint + [str(id), "datatrack"] if endpoint else None
|
|
327
|
+
)
|
|
281
328
|
|
|
282
329
|
def fetchFull(self):
|
|
283
330
|
self.fetchParameters()
|
|
284
331
|
self.fetchInfo()
|
|
285
332
|
self.fetchZipSize()
|
|
333
|
+
self.fetchExports()
|
|
286
334
|
|
|
287
335
|
def download(
|
|
288
336
|
self,
|
|
@@ -324,15 +372,54 @@ class Dataset(
|
|
|
324
372
|
self._parameterHelper = ParameterHelper(self.parameters)
|
|
325
373
|
return self._parameterHelper.get(key, removeUnit)
|
|
326
374
|
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
375
|
+
def _requestReport(self, exportId: str, parameters: Optional[ExportParamters]):
|
|
376
|
+
connection, endpoint, id = self._getConnectionData()
|
|
377
|
+
converterEndpoint: Any = endpoint + [id, "exports", exportId]
|
|
378
|
+
payload = parameters.toDict() if parameters else {}
|
|
379
|
+
data, responseError = connection.postEndpoint(converterEndpoint, data=payload)
|
|
380
|
+
if responseError:
|
|
381
|
+
raise EntityFetchingException(entity=self, responseError=responseError)
|
|
330
382
|
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
self.
|
|
334
|
-
|
|
335
|
-
|
|
383
|
+
# TODO: create a report type to wait for the report to be generated
|
|
384
|
+
# TODO: maybe a class "Conversion" can be created that has a state and also and automatic awaiter function or so
|
|
385
|
+
conversion = self.checkAndConvert(data, Conversion, f"Conversion_to_{exportId}")
|
|
386
|
+
conversion.connection = self.connection
|
|
387
|
+
conversion._endpoint = converterEndpoint
|
|
388
|
+
conversion._payload = payload
|
|
389
|
+
conversion._parentEntity = self
|
|
390
|
+
return conversion
|
|
391
|
+
|
|
392
|
+
def exportTo(
|
|
393
|
+
self, exportId: str, parameters: Optional[Union[ExportParamters, dict]] = None
|
|
394
|
+
):
|
|
395
|
+
|
|
396
|
+
if self._noExports:
|
|
397
|
+
self.fetchExports()
|
|
398
|
+
|
|
399
|
+
if self.exports is None:
|
|
400
|
+
raise LOGSException(f"Export id '{exportId}' not found in exports")
|
|
401
|
+
|
|
402
|
+
exports = {e.exportId: e for e in self.exports}
|
|
403
|
+
exports.update({e.id: e for e in self.exports})
|
|
404
|
+
if exportId not in exports:
|
|
405
|
+
raise LOGSException(f"Export id '{exportId}' not found in exports")
|
|
406
|
+
|
|
407
|
+
export = exports[exportId]
|
|
408
|
+
p = export.requestParameter
|
|
409
|
+
if parameters is not None and p is not None:
|
|
410
|
+
if isinstance(parameters, dict):
|
|
411
|
+
p.fromDict(parameters)
|
|
412
|
+
elif isinstance(parameters, ExportParamters):
|
|
413
|
+
if parameters._parentId is None or parameters._parentId != p._parentId:
|
|
414
|
+
raise LOGSException(
|
|
415
|
+
f"The passed export parameters is not generated by and valid export format. (Expected class '{p.identifier}')"
|
|
416
|
+
)
|
|
417
|
+
else:
|
|
418
|
+
raise LOGSException(
|
|
419
|
+
f"Invalid parameter type '{type(parameters).__name__}'. (Expected 'dict' or '{ExportParamters.__name__}')"
|
|
420
|
+
)
|
|
421
|
+
|
|
422
|
+
return self._requestReport(exportId, p)
|
|
336
423
|
|
|
337
424
|
@property
|
|
338
425
|
def format(self) -> Optional["FormatMinimal"]:
|
|
@@ -432,6 +519,17 @@ class Dataset(
|
|
|
432
519
|
)
|
|
433
520
|
return self._parameters
|
|
434
521
|
|
|
522
|
+
@property
|
|
523
|
+
def parameterTree(self) -> Optional[ParameterList]:
|
|
524
|
+
if self._noParameterTree:
|
|
525
|
+
raise EntityIncompleteException(
|
|
526
|
+
self,
|
|
527
|
+
parameterName="parameterTree",
|
|
528
|
+
functionName=f"{self.fetchParameterTree.__name__}()",
|
|
529
|
+
hasFetchFull=False,
|
|
530
|
+
)
|
|
531
|
+
return self._parameterTree
|
|
532
|
+
|
|
435
533
|
@property
|
|
436
534
|
def formatVersion(self) -> Optional[int]:
|
|
437
535
|
if self._noInfo:
|
|
@@ -600,28 +698,6 @@ class Dataset(
|
|
|
600
698
|
value, "PersonMinimal", "operators", connection=self.connection
|
|
601
699
|
)
|
|
602
700
|
|
|
603
|
-
@property
|
|
604
|
-
def projects(self) -> Optional[List["ProjectMinimal"]]:
|
|
605
|
-
return self._projects
|
|
606
|
-
|
|
607
|
-
@projects.setter
|
|
608
|
-
def projects(self, value):
|
|
609
|
-
self._projects = MinimalFromList(
|
|
610
|
-
value, "ProjectMinimal", "projects", connection=self.connection
|
|
611
|
-
)
|
|
612
|
-
|
|
613
|
-
@property
|
|
614
|
-
def projectIds(self) -> Optional[List[int]]:
|
|
615
|
-
if self._projects is None:
|
|
616
|
-
return None
|
|
617
|
-
return [e.id for e in self._projects]
|
|
618
|
-
|
|
619
|
-
@projectIds.setter
|
|
620
|
-
def projectIds(self, value):
|
|
621
|
-
self._projects = MinimalFromList(
|
|
622
|
-
value, "ProjectMinimal", "projects", connection=self.connection
|
|
623
|
-
)
|
|
624
|
-
|
|
625
701
|
@property
|
|
626
702
|
def instrument(self) -> Optional["InstrumentMinimal"]:
|
|
627
703
|
return self._instrument
|
|
@@ -681,3 +757,65 @@ class Dataset(
|
|
|
681
757
|
self._isViewableEntity = self.checkAndConvertNullable(
|
|
682
758
|
value, bool, "isViewableEntity"
|
|
683
759
|
)
|
|
760
|
+
|
|
761
|
+
@property
|
|
762
|
+
def exports(self) -> Optional[List[Converter]]:
|
|
763
|
+
if self._noExports:
|
|
764
|
+
raise EntityIncompleteException(
|
|
765
|
+
self,
|
|
766
|
+
parameterName="exports",
|
|
767
|
+
functionName=f"{self.fetchExports.__name__}()",
|
|
768
|
+
hasFetchFull=True,
|
|
769
|
+
)
|
|
770
|
+
|
|
771
|
+
return self._exports
|
|
772
|
+
|
|
773
|
+
@exports.setter
|
|
774
|
+
def exports(self, value):
|
|
775
|
+
self._exports = self.checkListAndConvertNullable(value, Converter, "exports")
|
|
776
|
+
|
|
777
|
+
@property
|
|
778
|
+
def viewableEntityType(self) -> Optional[ViewableEntityTypes]:
|
|
779
|
+
return self._viewableEntityType
|
|
780
|
+
|
|
781
|
+
@viewableEntityType.setter
|
|
782
|
+
def viewableEntityType(self, value):
|
|
783
|
+
self._viewableEntityType = self.checkAndConvertNullable(
|
|
784
|
+
value, ViewableEntityTypes, "viewableEntityType"
|
|
785
|
+
)
|
|
786
|
+
|
|
787
|
+
@property
|
|
788
|
+
def customImport(self) -> Optional[EntityMinimalWithIntId]:
|
|
789
|
+
return self._customImport
|
|
790
|
+
|
|
791
|
+
@customImport.setter
|
|
792
|
+
def customImport(self, value):
|
|
793
|
+
self._customImport = self.checkAndConvertNullable(
|
|
794
|
+
value, EntityMinimalWithIntId, "customImport"
|
|
795
|
+
)
|
|
796
|
+
|
|
797
|
+
@property
|
|
798
|
+
def source(self) -> Optional[DatasetSource]:
|
|
799
|
+
return self._source
|
|
800
|
+
|
|
801
|
+
@source.setter
|
|
802
|
+
def source(self, value):
|
|
803
|
+
self._source = self.checkAndConvertNullable(value, DatasetSource, "source")
|
|
804
|
+
|
|
805
|
+
@property
|
|
806
|
+
def isManuallyNamed(self) -> Optional[bool]:
|
|
807
|
+
return self._isManuallyNamed
|
|
808
|
+
|
|
809
|
+
@isManuallyNamed.setter
|
|
810
|
+
def isManuallyNamed(self, value):
|
|
811
|
+
self._isManuallyNamed = self.checkAndConvertNullable(
|
|
812
|
+
value, bool, "isManuallyNamed"
|
|
813
|
+
)
|
|
814
|
+
|
|
815
|
+
@property
|
|
816
|
+
def automaticName(self) -> Optional[str]:
|
|
817
|
+
return self._automaticName
|
|
818
|
+
|
|
819
|
+
@automaticName.setter
|
|
820
|
+
def automaticName(self, value):
|
|
821
|
+
self._automaticName = self.checkAndConvertNullable(value, str, "automaticName")
|
LOGS/Entities/DatasetCreator.py
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
from
|
|
2
|
-
from typing import TYPE_CHECKING, Any, List, Optional
|
|
3
|
-
|
|
4
|
-
from deprecation import deprecated
|
|
1
|
+
from typing import TYPE_CHECKING, List, Optional
|
|
5
2
|
|
|
6
3
|
from LOGS.Auxiliary.Decorators import Endpoint
|
|
7
4
|
from LOGS.Auxiliary.Exceptions import EntityCreatingException, LOGSException
|
|
@@ -9,86 +6,40 @@ from LOGS.Auxiliary.Tools import Tools
|
|
|
9
6
|
from LOGS.Entities.Dataset import Dataset
|
|
10
7
|
from LOGS.Entities.FileEntry import FileEntry
|
|
11
8
|
from LOGS.Entity.EntityConnector import EntityConnector
|
|
12
|
-
from LOGS.Entity.SerializeableContent import SerializeableClass
|
|
13
9
|
from LOGS.LOGSConnection import LOGSConnection, MultipartEntry
|
|
14
10
|
|
|
15
11
|
if TYPE_CHECKING:
|
|
16
12
|
pass
|
|
17
13
|
|
|
18
14
|
|
|
19
|
-
class
|
|
20
|
-
|
|
21
|
-
SFTPAutoload = 1
|
|
22
|
-
ClientAutoload = 2
|
|
23
|
-
APIUpload = 3
|
|
15
|
+
class DatasetUploadRequest(Dataset):
|
|
16
|
+
_typeMapper = {"files": FileEntry}
|
|
24
17
|
|
|
18
|
+
def __init__(self, ref=None):
|
|
19
|
+
super().__init__(ref)
|
|
20
|
+
if ref and isinstance(ref, Dataset):
|
|
21
|
+
self._files = ref._files
|
|
25
22
|
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
_files: Optional[List[FileEntry]]
|
|
24
|
+
_filePathsAreAbsolute: Optional[bool] = True
|
|
28
25
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
self.
|
|
32
|
-
self.methodId: Optional[int] = None
|
|
33
|
-
self.instrumentId: Optional[int] = None
|
|
34
|
-
self.experimentId: Optional[int] = None
|
|
35
|
-
self.sampleId: Optional[int] = None
|
|
36
|
-
self.ownerId: Optional[int] = None
|
|
37
|
-
self.projectIds: Optional[List[int]] = None
|
|
38
|
-
self.organizationIds: Optional[List[int]] = None
|
|
39
|
-
self.operatorIds: Optional[List[int]] = None
|
|
40
|
-
self.equipmentIds: Optional[List[int]] = None
|
|
41
|
-
self.autoloadBaseDir: str = ""
|
|
42
|
-
self.relativeDir: str = ""
|
|
43
|
-
self.dataSourceId: Optional[str] = None
|
|
44
|
-
self.isViewableEntity: Optional[bool] = None
|
|
45
|
-
self.files: List[FileEntry] = []
|
|
46
|
-
self.filePathsAreAbsolute: Optional[bool] = True
|
|
47
|
-
|
|
48
|
-
if isinstance(ref, Dataset) and ref.format:
|
|
49
|
-
self.name = ref.name
|
|
50
|
-
|
|
51
|
-
if ref.name:
|
|
52
|
-
self.name = ref.name
|
|
53
|
-
if ref.format:
|
|
54
|
-
self.formatId = ref.format.id
|
|
55
|
-
if ref.owner:
|
|
56
|
-
self.ownerId = ref.owner.id
|
|
57
|
-
if ref._files:
|
|
58
|
-
self.files = ref._files
|
|
59
|
-
if ref.method:
|
|
60
|
-
self.methodId = ref.method.id
|
|
61
|
-
if ref.instrument:
|
|
62
|
-
self.instrumentId = ref.instrument.id
|
|
63
|
-
if ref.experiment:
|
|
64
|
-
self.experimentId = ref.experiment.id
|
|
65
|
-
if ref.sampleId:
|
|
66
|
-
self.sampleId = ref.sampleId
|
|
67
|
-
if ref.owner:
|
|
68
|
-
self.ownerId = ref.owner.id
|
|
69
|
-
if ref.projects:
|
|
70
|
-
self.projectIds = [p.id for p in ref.projects]
|
|
71
|
-
if ref.operators:
|
|
72
|
-
self.operatorIds = [o.id for o in ref.operators]
|
|
73
|
-
if ref.equipments:
|
|
74
|
-
self.equipmentIds = [e.id for e in ref.equipments]
|
|
75
|
-
if ref.isViewableEntity:
|
|
76
|
-
self.isViewableEntity = ref.isViewableEntity
|
|
77
|
-
if ref._files:
|
|
78
|
-
self.files = ref._files
|
|
79
|
-
ref = None
|
|
26
|
+
@property
|
|
27
|
+
def files(self) -> Optional[List[FileEntry]]:
|
|
28
|
+
return self._files
|
|
80
29
|
|
|
81
|
-
|
|
30
|
+
@files.setter
|
|
31
|
+
def files(self, value):
|
|
32
|
+
self._files = self.checkListAndConvertNullable(value, FileEntry, "files")
|
|
82
33
|
|
|
83
34
|
@property
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
35
|
+
def filePathsAreAbsolute(self) -> Optional[bool]:
|
|
36
|
+
return self._filePathsAreAbsolute
|
|
37
|
+
|
|
38
|
+
@filePathsAreAbsolute.setter
|
|
39
|
+
def filePathsAreAbsolute(self, value):
|
|
40
|
+
self._filePathsAreAbsolute = self.checkAndConvertNullable(
|
|
41
|
+
value, bool, "filePathsAreAbsolute"
|
|
42
|
+
)
|
|
92
43
|
|
|
93
44
|
|
|
94
45
|
@Endpoint("datasets")
|