hydroserverpy 0.4.0__py3-none-any.whl → 0.5.0b2__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 hydroserverpy might be problematic. Click here for more details.

Files changed (72) hide show
  1. hydroserverpy/__init__.py +2 -3
  2. hydroserverpy/api/http.py +22 -0
  3. hydroserverpy/api/main.py +173 -0
  4. hydroserverpy/api/models/__init__.py +21 -0
  5. hydroserverpy/api/models/base.py +74 -0
  6. hydroserverpy/api/models/etl/__init__.py +0 -0
  7. hydroserverpy/api/models/etl/data_archive.py +105 -0
  8. hydroserverpy/api/models/etl/data_source.py +150 -0
  9. hydroserverpy/api/models/etl/orchestration_configuration.py +35 -0
  10. hydroserverpy/api/models/etl/orchestration_system.py +78 -0
  11. hydroserverpy/api/models/iam/__init__.py +0 -0
  12. hydroserverpy/api/models/iam/account.py +12 -0
  13. hydroserverpy/api/models/iam/collaborator.py +34 -0
  14. hydroserverpy/api/models/iam/role.py +10 -0
  15. hydroserverpy/api/models/iam/workspace.py +238 -0
  16. hydroserverpy/api/models/sta/__init__.py +0 -0
  17. hydroserverpy/api/models/sta/datastream.py +338 -0
  18. hydroserverpy/api/models/sta/observed_property.py +72 -0
  19. hydroserverpy/api/models/sta/processing_level.py +50 -0
  20. hydroserverpy/api/models/sta/result_qualifier.py +49 -0
  21. hydroserverpy/api/models/sta/sensor.py +105 -0
  22. hydroserverpy/api/models/sta/thing.py +217 -0
  23. hydroserverpy/api/models/sta/unit.py +49 -0
  24. hydroserverpy/api/services/__init__.py +11 -0
  25. hydroserverpy/api/services/base.py +102 -0
  26. hydroserverpy/api/services/etl/__init__.py +0 -0
  27. hydroserverpy/api/services/etl/data_archive.py +196 -0
  28. hydroserverpy/api/services/etl/data_source.py +196 -0
  29. hydroserverpy/api/services/etl/orchestration_system.py +74 -0
  30. hydroserverpy/api/services/iam/__init__.py +0 -0
  31. hydroserverpy/api/services/iam/workspace.py +126 -0
  32. hydroserverpy/api/services/sta/__init__.py +0 -0
  33. hydroserverpy/api/services/sta/datastream.py +354 -0
  34. hydroserverpy/api/services/sta/observed_property.py +100 -0
  35. hydroserverpy/api/services/sta/processing_level.py +78 -0
  36. hydroserverpy/api/services/sta/result_qualifier.py +74 -0
  37. hydroserverpy/api/services/sta/sensor.py +116 -0
  38. hydroserverpy/api/services/sta/thing.py +188 -0
  39. hydroserverpy/api/services/sta/unit.py +82 -0
  40. hydroserverpy/etl/loaders/hydroserver_loader.py +1 -1
  41. hydroserverpy/etl_csv/hydroserver_etl_csv.py +49 -34
  42. {hydroserverpy-0.4.0.dist-info → hydroserverpy-0.5.0b2.dist-info}/METADATA +4 -3
  43. hydroserverpy-0.5.0b2.dist-info/RECORD +66 -0
  44. {hydroserverpy-0.4.0.dist-info → hydroserverpy-0.5.0b2.dist-info}/WHEEL +1 -1
  45. hydroserverpy/core/endpoints/__init__.py +0 -9
  46. hydroserverpy/core/endpoints/base.py +0 -146
  47. hydroserverpy/core/endpoints/data_loaders.py +0 -93
  48. hydroserverpy/core/endpoints/data_sources.py +0 -93
  49. hydroserverpy/core/endpoints/datastreams.py +0 -225
  50. hydroserverpy/core/endpoints/observed_properties.py +0 -111
  51. hydroserverpy/core/endpoints/processing_levels.py +0 -111
  52. hydroserverpy/core/endpoints/result_qualifiers.py +0 -111
  53. hydroserverpy/core/endpoints/sensors.py +0 -111
  54. hydroserverpy/core/endpoints/things.py +0 -261
  55. hydroserverpy/core/endpoints/units.py +0 -111
  56. hydroserverpy/core/schemas/__init__.py +0 -9
  57. hydroserverpy/core/schemas/base.py +0 -124
  58. hydroserverpy/core/schemas/data_loaders.py +0 -73
  59. hydroserverpy/core/schemas/data_sources.py +0 -223
  60. hydroserverpy/core/schemas/datastreams.py +0 -330
  61. hydroserverpy/core/schemas/observed_properties.py +0 -43
  62. hydroserverpy/core/schemas/processing_levels.py +0 -31
  63. hydroserverpy/core/schemas/result_qualifiers.py +0 -26
  64. hydroserverpy/core/schemas/sensors.py +0 -68
  65. hydroserverpy/core/schemas/things.py +0 -346
  66. hydroserverpy/core/schemas/units.py +0 -29
  67. hydroserverpy/core/service.py +0 -200
  68. hydroserverpy-0.4.0.dist-info/RECORD +0 -51
  69. /hydroserverpy/{core → api}/__init__.py +0 -0
  70. {hydroserverpy-0.4.0.dist-info → hydroserverpy-0.5.0b2.dist-info/licenses}/LICENSE +0 -0
  71. {hydroserverpy-0.4.0.dist-info → hydroserverpy-0.5.0b2.dist-info}/top_level.txt +0 -0
  72. {hydroserverpy-0.4.0.dist-info → hydroserverpy-0.5.0b2.dist-info}/zip-safe +0 -0
@@ -1,330 +0,0 @@
1
- from pydantic import BaseModel, Field
2
- from pandas import DataFrame
3
- from typing import Optional, Literal, TYPE_CHECKING
4
- from uuid import UUID
5
- from datetime import datetime
6
- from hydroserverpy.core.schemas.base import HydroServerCoreModel
7
-
8
- if TYPE_CHECKING:
9
- from hydroserverpy.core.schemas.things import Thing
10
- from hydroserverpy.core.schemas.data_sources import DataSource
11
- from hydroserverpy.core.schemas.sensors import Sensor
12
- from hydroserverpy.core.schemas.units import Unit
13
- from hydroserverpy.core.schemas.processing_levels import ProcessingLevel
14
- from hydroserverpy.core.schemas.observed_properties import ObservedProperty
15
-
16
-
17
- class DatastreamFields(BaseModel):
18
- name: str = Field(
19
- ...,
20
- strip_whitespace=True,
21
- max_length=255,
22
- description="The name of the datastream.",
23
- )
24
- description: str = Field(
25
- ..., strip_whitespace=True, description="A description of the datastream."
26
- )
27
- observation_type: str = Field(
28
- ...,
29
- strip_whitespace=True,
30
- max_length=255,
31
- description="The type of observation recorded in this datastream",
32
- )
33
- sampled_medium: str = Field(
34
- ...,
35
- strip_whitespace=True,
36
- max_length=255,
37
- description="The physical medium in which the observations were sampled.",
38
- )
39
- no_data_value: float = Field(
40
- ...,
41
- description="A numerical value representing no data at a given timestamp.",
42
- )
43
- aggregation_statistic: str = Field(
44
- ...,
45
- strip_whitespace=True,
46
- max_length=255,
47
- description="The statistic calculated over the time aggregation interval of observations in this datastream.",
48
- )
49
- time_aggregation_interval: float = Field(
50
- ...,
51
- description="The time interval over which the aggregation statistic is applied to observations.",
52
- )
53
- status: Optional[str] = Field(
54
- None,
55
- strip_whitespace=True,
56
- max_length=255,
57
- description="The current status of this datastream.",
58
- )
59
- result_type: str = Field(
60
- ...,
61
- strip_whitespace=True,
62
- max_length=255,
63
- description="The type of result recorded in this datastream.",
64
- )
65
- value_count: Optional[int] = Field(
66
- None, ge=0, description="The total number of observations in this datastream."
67
- )
68
- phenomenon_begin_time: Optional[datetime] = Field(
69
- None,
70
- description="The timestamp representing when the first phenomenon recorded in this datastream occurred.",
71
- )
72
- phenomenon_end_time: Optional[datetime] = Field(
73
- None,
74
- description="The timestamp representing when the last phenomenon recorded in this datastream occurred.",
75
- )
76
- result_begin_time: Optional[datetime] = Field(
77
- None,
78
- description="The timestamp representing when the first observation of this datastream was recorded.",
79
- )
80
- result_end_time: Optional[datetime] = Field(
81
- None,
82
- description="The timestamp representing when the last observation of this datastream was recorded.",
83
- )
84
- data_source_id: Optional[UUID] = Field(
85
- None, description="The data source for observations of this datastream."
86
- )
87
- data_source_column: Optional[str] = Field(
88
- None,
89
- strip_whitespace=True,
90
- max_length=255,
91
- description="The name of the column containing this datastream's observations in the data source file.",
92
- )
93
- is_visible: bool = Field(
94
- True, description="Whether this datastream is publicly visible."
95
- )
96
- is_data_visible: bool = Field(
97
- True,
98
- description="Whether this observations associated with this datastream are publicly visible.",
99
- )
100
- thing_id: UUID = Field(
101
- ...,
102
- description="The site/thing from which observations of this datastream were recorded.",
103
- )
104
- sensor_id: UUID = Field(
105
- ..., description="The sensor used to record observations of this datastream."
106
- )
107
- observed_property_id: UUID = Field(
108
- ..., description="The physical property being observed for this datastream."
109
- )
110
- processing_level_id: UUID = Field(
111
- ..., description="The processing level applied to this datastream."
112
- )
113
- unit_id: UUID = Field(
114
- ..., description="The unit used to record observations for this datastream."
115
- )
116
- time_aggregation_interval_units: Literal["seconds", "minutes", "hours", "days"] = (
117
- Field(
118
- ...,
119
- description="The time unit for this datastream's time aggregation interval",
120
- )
121
- )
122
- intended_time_spacing: Optional[float] = Field(
123
- None,
124
- description="The time interval at which observations should be made for this datastream.",
125
- )
126
- intended_time_spacing_units: Optional[
127
- Literal["seconds", "minutes", "hours", "days"]
128
- ] = Field(
129
- None,
130
- description="The time unit for this datastream's intended time spacing interval",
131
- )
132
-
133
-
134
- class Datastream(HydroServerCoreModel, DatastreamFields):
135
- """
136
- A model representing a datastream, extending the core functionality of HydroServerCoreModel with additional
137
- properties and methods.
138
-
139
- :ivar _thing: A private attribute to cache the associated thing entity.
140
- :ivar _data_source: A private attribute to cache the associated data source entity.
141
- :ivar _observed_property: A private attribute to cache the associated observed property entity.
142
- :ivar _processing_level: A private attribute to cache the associated processing level entity.
143
- :ivar _unit: A private attribute to cache the associated unit entity.
144
- :ivar _sensor: A private attribute to cache the associated sensor entity.
145
- """
146
-
147
- def __init__(self, _endpoint, _uid: Optional[UUID] = None, **data):
148
- """
149
- Initialize a Datastream instance.
150
-
151
- :param _endpoint: The endpoint associated with the Datastream.
152
- :param _uid: The unique identifier for the Datastream.
153
- :type _uid: Optional[UUID]
154
- :param data: Additional attributes for the Datastream.
155
- """
156
-
157
- super().__init__(_endpoint=_endpoint, _uid=_uid, **data)
158
- self._thing = None
159
- self._data_source = None
160
- self._observed_property = None
161
- self._processing_level = None
162
- self._unit = None
163
- self._sensor = None
164
-
165
- @property
166
- def thing(self) -> "Thing":
167
- """
168
- The thing entity associated with the datastream. If not already cached, fetch it from the server.
169
-
170
- :return: The thing entity associated with the datastream.
171
- :rtype: Thing
172
- """
173
-
174
- if self._thing is None:
175
- self._thing = self._endpoint._service.things.get(uid=self.thing_id) # noqa
176
-
177
- return self._thing
178
-
179
- @property
180
- def data_source(self) -> "DataSource":
181
- """
182
- The data source entity associated with the datastream. If not already cached, fetch it from the server.
183
-
184
- :return: The data source entity associated with the datastream.
185
- :rtype: DataSource
186
- """
187
-
188
- if self._data_source is None:
189
- self._data_source = self._endpoint._service.datasources.get(
190
- uid=self.data_source_id
191
- ) # noqa
192
-
193
- return self._data_source
194
-
195
- @property
196
- def observed_property(self) -> "ObservedProperty":
197
- """
198
- Retrieve the observed property entity associated with the datastream. If not already cached, fetch it from the
199
- server.
200
-
201
- :return: The observed property entity associated with the datastream.
202
- :rtype: ObservedProperty
203
- """
204
-
205
- if self._observed_property is None:
206
- self._observed_property = self._endpoint._service.observedproperties.get(
207
- uid=self.observed_property_id
208
- ) # noqa
209
-
210
- return self._observed_property
211
-
212
- @property
213
- def processing_level(self) -> "ProcessingLevel":
214
- """
215
- Retrieve the processing level entity associated with the datastream. If not already cached, fetch it from the
216
- server.
217
-
218
- :return: The processing level entity associated with the datastream.
219
- :rtype: ProcessingLevel
220
- """
221
-
222
- if self._processing_level is None:
223
- self._processing_level = self._endpoint._service.processinglevels.get(
224
- uid=self.processing_level_id
225
- ) # noqa
226
-
227
- return self._processing_level
228
-
229
- @property
230
- def unit(self) -> "Unit":
231
- """
232
- Retrieve the unit entity associated with the datastream. If not already cached, fetch it from the server.
233
-
234
- :return: The unit entity associated with the datastream.
235
- :rtype: Unit
236
- """
237
-
238
- if self._unit is None:
239
- self._unit = self._endpoint._service.units.get(uid=self.unit_id) # noqa
240
-
241
- return self._unit
242
-
243
- @property
244
- def sensor(self) -> "Sensor":
245
- """
246
- Retrieve the sensor entity associated with the datastream. If not already cached, fetch it from the server.
247
-
248
- :return: The sensor entity associated with the datastream.
249
- :rtype: Any
250
- """
251
-
252
- if self._sensor is None:
253
- self._sensor = self._endpoint._service.sensors.get(
254
- uid=self.sensor_id
255
- ) # noqa
256
-
257
- return self._sensor
258
-
259
- def refresh(self) -> None:
260
- """
261
- Refresh the datastream with the latest data from the server and update cached entities if they were previously
262
- loaded.
263
- """
264
-
265
- entity = self._endpoint.get(uid=self.uid).model_dump(exclude=["uid"])
266
- self._original_data = entity
267
- self.__dict__.update(entity)
268
- if self._thing is not None:
269
- self._thing = self._endpoint._service.things.get(uid=self.thing_id) # noqa
270
- if self._data_source is not None:
271
- self._data_source = self._endpoint._service.datasources.get(
272
- uid=self.data_source_id
273
- ) # noqa
274
- if self._observed_property is not None:
275
- self._observed_property = self._endpoint._service.observedproperties.get(
276
- uid=self.observed_property_id
277
- ) # noqa
278
- if self._processing_level is not None:
279
- self._processing_level = self._endpoint._service.processinglevels.get(
280
- uid=self.processing_level_id
281
- ) # noqa
282
- if self._unit is not None:
283
- self._unit = self._endpoint._service.units.get(uid=self.unit_id) # noqa
284
- if self._sensor is not None:
285
- self._sensor = self._endpoint._service.sensors.get(
286
- uid=self.sensor_id
287
- ) # noqa
288
-
289
- def get_observations(
290
- self,
291
- start_time: datetime = None,
292
- end_time: datetime = None,
293
- page: int = 1,
294
- page_size: int = 100000,
295
- include_quality: bool = False,
296
- fetch_all: bool = False,
297
- ) -> DataFrame:
298
- """
299
- Retrieve the observations for this datastream.
300
-
301
- :return: A DataFrame containing the observations associated with the datastream.
302
- :rtype: DataFrame
303
- """
304
-
305
- return self._endpoint.get_observations(
306
- uid=self.uid,
307
- start_time=start_time,
308
- end_time=end_time,
309
- page=page,
310
- page_size=page_size,
311
- include_quality=include_quality,
312
- fetch_all=fetch_all,
313
- )
314
-
315
- def load_observations(
316
- self,
317
- observations: DataFrame,
318
- ) -> None:
319
- """
320
- Load a DataFrame of observations to the datastream.
321
-
322
- :param observations: A pandas DataFrame containing the observations to be uploaded.
323
- :type observations: DataFrame
324
- :return: None
325
- """
326
-
327
- return self._endpoint.load_observations(
328
- uid=self.uid,
329
- observations=observations,
330
- )
@@ -1,43 +0,0 @@
1
- from pydantic import BaseModel, Field
2
- from typing import Optional
3
- from hydroserverpy.core.schemas.base import HydroServerCoreModel
4
-
5
-
6
- class ObservedPropertyFields(BaseModel):
7
- name: str = Field(
8
- ...,
9
- strip_whitespace=True,
10
- max_length=255,
11
- description="The name of the observed property.",
12
- )
13
- definition: str = Field(
14
- ...,
15
- strip_whitespace=True,
16
- description="The definition of the observed property.",
17
- )
18
- description: Optional[str] = Field(
19
- None,
20
- strip_whitespace=True,
21
- description="A description of the observed property.",
22
- )
23
- type: Optional[str] = Field(
24
- None,
25
- strip_whitespace=True,
26
- max_length=255,
27
- description="The type of the observed property.",
28
- )
29
- code: Optional[str] = Field(
30
- None,
31
- strip_whitespace=True,
32
- max_length=255,
33
- description="A code representing the observed property.",
34
- )
35
-
36
-
37
- class ObservedProperty(HydroServerCoreModel, ObservedPropertyFields):
38
- """
39
- A model representing an observed property, extending the core functionality of HydroServerCoreModel with additional
40
- fields defined in ObservedPropertyFields.
41
- """
42
-
43
- pass
@@ -1,31 +0,0 @@
1
- from pydantic import BaseModel, Field
2
- from typing import Optional
3
- from hydroserverpy.core.schemas.base import HydroServerCoreModel
4
-
5
-
6
- class ProcessingLevelFields(BaseModel):
7
- code: str = Field(
8
- ...,
9
- strip_whitespace=True,
10
- max_length=255,
11
- description="A code representing the processing level.",
12
- )
13
- definition: Optional[str] = Field(
14
- None,
15
- strip_whitespace=True,
16
- description="The definition of the processing level.",
17
- )
18
- explanation: Optional[str] = Field(
19
- None,
20
- strip_whitespace=True,
21
- description="The explanation of the processing level.",
22
- )
23
-
24
-
25
- class ProcessingLevel(HydroServerCoreModel, ProcessingLevelFields):
26
- """
27
- A model representing a processing level, extending the core functionality of HydroServerCoreModel with additional
28
- fields defined in ProcessingLevelFields.
29
- """
30
-
31
- pass
@@ -1,26 +0,0 @@
1
- from pydantic import BaseModel, Field
2
- from typing import Optional
3
- from hydroserverpy.core.schemas.base import HydroServerCoreModel
4
-
5
-
6
- class ResultQualifierFields(BaseModel):
7
- code: str = Field(
8
- ...,
9
- strip_whitespace=True,
10
- max_length=255,
11
- description="A code representing the result qualifier.",
12
- )
13
- description: Optional[str] = Field(
14
- None,
15
- strip_whitespace=True,
16
- description="A description of the result qualifier.",
17
- )
18
-
19
-
20
- class ResultQualifier(HydroServerCoreModel, ResultQualifierFields):
21
- """
22
- A model representing an result qualifier, extending the core functionality of HydroServerCoreModel with additional
23
- fields defined in ResultQualifierFields.
24
- """
25
-
26
- pass
@@ -1,68 +0,0 @@
1
- from pydantic import BaseModel, Field, ConfigDict
2
- from typing import Optional
3
- from hydroserverpy.core.schemas.base import HydroServerCoreModel
4
-
5
-
6
- class SensorFields(BaseModel):
7
- name: str = Field(
8
- ...,
9
- strip_whitespace=True,
10
- max_length=255,
11
- description="The name of the sensor.",
12
- )
13
- description: str = Field(
14
- strip_whitespace=True, description="A description of the sensor."
15
- )
16
- encoding_type: str = Field(
17
- ...,
18
- strip_whitespace=True,
19
- max_length=255,
20
- description="The encoding type of the sensor.",
21
- )
22
- manufacturer: Optional[str] = Field(
23
- None,
24
- strip_whitespace=True,
25
- max_length=255,
26
- description="The manufacturer of the sensor.",
27
- )
28
- model: Optional[str] = Field(
29
- None,
30
- strip_whitespace=True,
31
- max_length=255,
32
- description="The model of the sensor.",
33
- )
34
- model_link: Optional[str] = Field(
35
- None,
36
- strip_whitespace=True,
37
- max_length=500,
38
- description="A link to a website or file that describes the sensor model.",
39
- )
40
- method_type: str = Field(
41
- ...,
42
- strip_whitespace=True,
43
- max_length=100,
44
- description="The type of method used by this sensor to collect observations.",
45
- )
46
- method_link: Optional[str] = Field(
47
- None,
48
- strip_whitespace=True,
49
- max_length=500,
50
- description="A link to a website or file that describes the sensor method.",
51
- )
52
- method_code: Optional[str] = Field(
53
- None,
54
- strip_whitespace=True,
55
- max_length=50,
56
- description="A code representing the sensor method.",
57
- )
58
-
59
- model_config = ConfigDict(protected_namespaces=())
60
-
61
-
62
- class Sensor(HydroServerCoreModel, SensorFields):
63
- """
64
- A model representing a sensor, extending the core functionality of HydroServerCoreModel with additional
65
- fields defined in SensorFields.
66
- """
67
-
68
- pass