hydroserverpy 0.2.0__py3-none-any.whl → 0.2.3__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.

hydroserverpy/__init__.py CHANGED
@@ -1,13 +1,19 @@
1
- from hydroserverpy.main import HydroServer
2
- from hydroserverpy.schemas.things import ThingPostBody
3
- from hydroserverpy.schemas.observed_properties import ObservedPropertyPostBody
4
- from hydroserverpy.schemas.units import UnitPostBody
5
- from hydroserverpy.schemas.datastreams import DatastreamPostBody
1
+ from .main import HydroServer
2
+ from .schemas.things import ThingPostBody
3
+ from .schemas.sensors import SensorPostBody
4
+ from .schemas.observed_properties import ObservedPropertyPostBody
5
+ from .schemas.units import UnitPostBody
6
+ from .schemas.processing_levels import ProcessingLevelPostBody
7
+ from .schemas.result_qualifiers import ResultQualifierPostBody
8
+ from .schemas.datastreams import DatastreamPostBody
6
9
 
7
10
  __all__ = [
8
11
  "HydroServer",
9
12
  "ThingPostBody",
13
+ "SensorPostBody",
10
14
  "ObservedPropertyPostBody",
11
15
  "UnitPostBody",
16
+ "ProcessingLevelPostBody",
17
+ "ResultQualifierPostBody",
12
18
  "DatastreamPostBody"
13
19
  ]
hydroserverpy/etl.py CHANGED
@@ -5,10 +5,10 @@ import croniter
5
5
  from typing import IO, List
6
6
  from datetime import datetime, timezone, timedelta
7
7
  from dateutil.parser import isoparse
8
- from hydroserverpy.schemas.data_sources import DataSourceGetResponse
9
- from hydroserverpy.schemas.datastreams import DatastreamGetResponse
10
- from hydroserverpy.exceptions import HeaderParsingError, TimestampParsingError
11
- from hydroserverpy.schemas.data_sources import DataSourcePatchBody
8
+ from .schemas.data_sources import DataSourceGetResponse
9
+ from .schemas.datastreams import DatastreamGetResponse
10
+ from .exceptions import HeaderParsingError, TimestampParsingError
11
+ from .schemas.data_sources import DataSourcePatchBody
12
12
 
13
13
  logger = logging.getLogger('hydroserver_etl')
14
14
  logger.addHandler(logging.NullHandler())
@@ -137,7 +137,7 @@ class HydroServerETL:
137
137
 
138
138
  try:
139
139
  self._timestamp_column_index = row.index(self._data_source.timestamp_column) \
140
- if not self._data_source.timestamp_column.isdigit() \
140
+ if isinstance(self._data_source.timestamp_column, str) \
141
141
  else int(self._data_source.timestamp_column) - 1
142
142
  if self._timestamp_column_index > len(row):
143
143
  raise ValueError
@@ -151,6 +151,7 @@ class HydroServerETL:
151
151
  max(self._datastream_column_indexes.values()) > len(row):
152
152
  raise ValueError
153
153
  except ValueError as e:
154
+ logger.error(f'Failed to load data from data source: "{self._data_source.name}"')
154
155
  raise HeaderParsingError(str(e)) from e
155
156
 
156
157
  def _parse_row_timestamp(self, row: List[str]) -> datetime:
@@ -163,7 +164,7 @@ class HydroServerETL:
163
164
  """
164
165
 
165
166
  try:
166
- if self._data_source.timestamp_format == 'iso':
167
+ if self._data_source.timestamp_format == 'iso' or self._data_source.timestamp_format is None:
167
168
  timestamp = isoparse(
168
169
  row[self._timestamp_column_index]
169
170
  )
@@ -188,6 +189,7 @@ class HydroServerETL:
188
189
  ).tzinfo
189
190
  )
190
191
  except ValueError as e:
192
+ logger.error(f'Failed to load data from data source: "{self._data_source.name}"')
191
193
  raise TimestampParsingError(str(e)) from e
192
194
 
193
195
  return timestamp
@@ -214,7 +216,7 @@ class HydroServerETL:
214
216
  f'Loading observations from ' +
215
217
  f'{observations[0]["phenomenon_time"].strftime("%Y-%m-%dT%H:%M:%S%z")} to ' +
216
218
  f'{observations[-1]["phenomenon_time"].strftime("%Y-%m-%dT%H:%M:%S%z")} for datastream: ' +
217
- f'{str(datastream_id)}.'
219
+ f'{str(datastream_id)} in data source "{self._data_source.name}".'
218
220
  )
219
221
 
220
222
  data_array_value = getattr(fsc.model, 'ext').data_array_value.DataArrayValue()
@@ -250,7 +252,8 @@ class HydroServerETL:
250
252
  f'Skipping observations POST request from ' +
251
253
  f'{observations[0]["phenomenon_time"].strftime("%Y-%m-%dT%H:%M:%S%z")} to ' +
252
254
  f'{observations[-1]["phenomenon_time"].strftime("%Y-%m-%dT%H:%M:%S%z")} for datastream: ' +
253
- f'{str(datastream_id)}, due to previous failed POST request.'
255
+ f'{str(datastream_id)} in data source "{self._data_source.name}",' +
256
+ f'due to previous failed POST request.'
254
257
  )
255
258
 
256
259
  self._observations = {}
@@ -1,5 +1,5 @@
1
1
  from pydantic import BaseModel, Field
2
- from typing import Union
2
+ from typing import Union, Literal, Optional
3
3
  from uuid import UUID
4
4
  from datetime import datetime
5
5
  from hydroserverpy.utils import allow_partial
@@ -33,8 +33,10 @@ class DatastreamFields(BaseModel):
33
33
  observed_property_id: UUID = Field(..., alias='observedPropertyId')
34
34
  processing_level_id: UUID = Field(..., alias='processingLevelId')
35
35
  unit_id: UUID = Field(..., alias='unitId')
36
- time_aggregation_interval_units_id: UUID = Field(..., alias='timeAggregationIntervalUnitsId')
37
- intended_time_spacing_units_id: UUID = Field(None, alias='intendedTimeSpacingUnitsId')
36
+ time_aggregation_interval_units: Literal['seconds', 'minutes', 'hours', 'days'] = \
37
+ Field(..., alias='timeAggregationIntervalUnits')
38
+ intended_time_spacing_units: Optional[Literal['seconds', 'minutes', 'hours', 'days']] = \
39
+ Field(None, alias='intendedTimeSpacingUnits')
38
40
 
39
41
 
40
42
  class DatastreamGetResponse(DatastreamFields, DatastreamID):
@@ -44,7 +46,9 @@ class DatastreamGetResponse(DatastreamFields, DatastreamID):
44
46
 
45
47
 
46
48
  class DatastreamPostBody(DatastreamFields):
47
- pass
49
+
50
+ class Config:
51
+ allow_population_by_field_name = True
48
52
 
49
53
 
50
54
  @allow_partial
@@ -18,7 +18,7 @@ class ObservedPropertyFields(BaseModel):
18
18
 
19
19
 
20
20
  class ObservedPropertyGetResponse(ObservedPropertyFields, ObservedPropertyID):
21
- owner: Optional[UserFields]
21
+ owner: Optional[str]
22
22
 
23
23
  class Config:
24
24
  allow_population_by_field_name = True
@@ -1,8 +1,8 @@
1
1
  from pydantic import BaseModel
2
2
  from uuid import UUID
3
3
  from typing import Optional
4
- from hydroserverpy.utils import allow_partial
5
- from hydroserverpy.schemas.users import UserFields
4
+ from ..utils import allow_partial
5
+ from ..schemas.users import UserFields
6
6
 
7
7
 
8
8
  class ProcessingLevelID(BaseModel):
@@ -16,14 +16,16 @@ class ProcessingLevelFields(BaseModel):
16
16
 
17
17
 
18
18
  class ProcessingLevelGetResponse(ProcessingLevelFields, ProcessingLevelID):
19
- owner: Optional[UserFields]
19
+ owner: Optional[str]
20
20
 
21
21
  class Config:
22
22
  allow_population_by_field_name = True
23
23
 
24
24
 
25
25
  class ProcessingLevelPostBody(ProcessingLevelFields):
26
- pass
26
+
27
+ class Config:
28
+ allow_population_by_field_name = True
27
29
 
28
30
 
29
31
  @allow_partial
@@ -1,8 +1,8 @@
1
1
  from pydantic import BaseModel
2
2
  from uuid import UUID
3
3
  from typing import Optional
4
- from hydroserverpy.utils import allow_partial
5
- from hydroserverpy.schemas.users import UserFields
4
+ from ..utils import allow_partial
5
+ from ..schemas.users import UserFields
6
6
 
7
7
 
8
8
  class ResultQualifierID(BaseModel):
@@ -15,14 +15,16 @@ class ResultQualifierFields(BaseModel):
15
15
 
16
16
 
17
17
  class ResultQualifierGetResponse(ResultQualifierFields, ResultQualifierID):
18
- owner: Optional[UserFields]
18
+ owner: Optional[str]
19
19
 
20
20
  class Config:
21
21
  allow_population_by_field_name = True
22
22
 
23
23
 
24
24
  class ResultQualifierPostBody(ResultQualifierFields):
25
- pass
25
+
26
+ class Config:
27
+ allow_population_by_field_name = True
26
28
 
27
29
 
28
30
  @allow_partial
@@ -22,14 +22,16 @@ class SensorFields(BaseModel):
22
22
 
23
23
 
24
24
  class SensorGetResponse(SensorFields, SensorID):
25
- owner: Optional[UserFields]
25
+ owner: Optional[str]
26
26
 
27
27
  class Config:
28
28
  allow_population_by_field_name = True
29
29
 
30
30
 
31
31
  class SensorPostBody(SensorFields):
32
- pass
32
+
33
+ class Config:
34
+ allow_population_by_field_name = True
33
35
 
34
36
 
35
37
  @allow_partial
@@ -17,7 +17,7 @@ class UnitFields(BaseModel):
17
17
 
18
18
 
19
19
  class UnitGetResponse(UnitFields, UnitID):
20
- owner: Optional[UserFields]
20
+ owner: Optional[str]
21
21
 
22
22
  class Config:
23
23
  allow_population_by_field_name = True
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: hydroserverpy
3
- Version: 0.2.0
3
+ Version: 0.2.3
4
4
  License-File: LICENSE
5
5
  Requires-Dist: requests >=2
6
6
  Requires-Dist: pydantic <2.0.0,>=1.6
@@ -1,5 +1,5 @@
1
- hydroserverpy/__init__.py,sha256=qD1hfLj901nRrIG4LsXJWUD8rqVPuQ1X93BtO3iS5Ts,427
2
- hydroserverpy/etl.py,sha256=KCF2PUjPMtA8WRl-eibck7og2Kf4JZk_AfSZlkJK4g0,12927
1
+ hydroserverpy/__init__.py,sha256=iZcBLrXpuWr7SYUIgIT3ngDKcI63LgfRNCwCIiv_CW4,616
2
+ hydroserverpy/etl.py,sha256=3cczra-7m1WxdHXm3yZO3hlz-OkWUJdQkA8mdhF8bi0,13229
3
3
  hydroserverpy/exceptions.py,sha256=0UY8YUlNepG0y6FfH36hJyR1bOhwYHSZIdUSSMTg7GA,314
4
4
  hydroserverpy/main.py,sha256=UD8l4wFvJbLWA07r0kR5tYPW3dnD7OCQoB4PJVpHkeo,1421
5
5
  hydroserverpy/models.py,sha256=IxQrSEHM344Bn6qtwjGFdY7bqyH_-lc8TJggVqDsvdg,8174
@@ -19,17 +19,17 @@ hydroserverpy/components/users.py,sha256=jpZ6TGOImK_j3ghwTFoAxpD9WMBG9DzIC0vcsb2
19
19
  hydroserverpy/schemas/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
20
20
  hydroserverpy/schemas/data_loaders.py,sha256=5YIXryh1LaVgjRetruyZHvBivsCS1XqOnT6lbcMCIMg,459
21
21
  hydroserverpy/schemas/data_sources.py,sha256=cYnhKUaKqirhJjxo9niSgtOdokv98Fah635rOywosAE,2053
22
- hydroserverpy/schemas/datastreams.py,sha256=3Halcwi2LzrMvtGTUT0RXXuvM6OeO8WSY1p2t4-h2e0,2087
23
- hydroserverpy/schemas/observed_properties.py,sha256=RquFsIadC2pyuCNGXDDxfOrftJ_lZII2WqKrPI6Xf-M,705
24
- hydroserverpy/schemas/processing_levels.py,sha256=ghdVzxfCQxrEKe8kik4jF4fmaKgrn0s4ndYFRakF_Y0,661
25
- hydroserverpy/schemas/result_qualifiers.py,sha256=T143dxl3PWqPlZNy8x_vOEOAkZ34k4CAwVGgKUSINiY,627
26
- hydroserverpy/schemas/sensors.py,sha256=84smNzc_0bJi2finQrWnDgvXMJGo6hS_CPu-4wjayKk,869
22
+ hydroserverpy/schemas/datastreams.py,sha256=wOY3O8UBLjfJXlVJI18rkcPNFApGDteKmFGsCbCv4s4,2266
23
+ hydroserverpy/schemas/observed_properties.py,sha256=-DpFuo4UYY5dx7mAxRSyN6EqjHGp9-CT5AapzSOE2RQ,698
24
+ hydroserverpy/schemas/processing_levels.py,sha256=MWy7fRIP-hDJtjwmSB1PK27agx9U2UFpjhl5lrYMIHA,686
25
+ hydroserverpy/schemas/result_qualifiers.py,sha256=m2OfJHefO1jFfRqV-Klgv6b50jOM0X1UtNCrSon3Znc,652
26
+ hydroserverpy/schemas/sensors.py,sha256=mUilTxc61zkrL2GULhJTO-q3P58Rkh2leHyCSZl1-Ug,918
27
27
  hydroserverpy/schemas/things.py,sha256=kolNbZ-JxNcIK3uNXBCNy7k1BTDbTpjlHa3v_YPrQvU,3359
28
- hydroserverpy/schemas/units.py,sha256=nno8mbzETzmRkAt88vKimoAAIdzaH1-2G6hcphOogg4,557
28
+ hydroserverpy/schemas/units.py,sha256=_28zmCz9TDuNfHa4Ycj1RKkxwUB_J832NSWIO3cBK9k,550
29
29
  hydroserverpy/schemas/users.py,sha256=TauiaArJ4LVjAKq80KvjKjxex5DAwQekc_nDXHyaU3U,675
30
- hydroserverpy-0.2.0.dist-info/LICENSE,sha256=xVqFxDw3QOEJukakL7gQCqIMTQ1dlSCTo6Oc1otNW80,1508
31
- hydroserverpy-0.2.0.dist-info/METADATA,sha256=4QLA03R9syUdBhZfLC2_K2AMitiVRg8CLvgLTvSDzVQ,419
32
- hydroserverpy-0.2.0.dist-info/WHEEL,sha256=Xo9-1PvkuimrydujYJAjF7pCkriuXBpUPEjma1nZyJ0,92
33
- hydroserverpy-0.2.0.dist-info/top_level.txt,sha256=Zf37hrncXLOYvXhgCrf5mZdeq81G9fShdE2LfYbtb7w,14
34
- hydroserverpy-0.2.0.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
35
- hydroserverpy-0.2.0.dist-info/RECORD,,
30
+ hydroserverpy-0.2.3.dist-info/LICENSE,sha256=xVqFxDw3QOEJukakL7gQCqIMTQ1dlSCTo6Oc1otNW80,1508
31
+ hydroserverpy-0.2.3.dist-info/METADATA,sha256=M7f0ECACJA2u6EVhnGJseeEyhbHw7HtqQ6S3zO-lIZY,419
32
+ hydroserverpy-0.2.3.dist-info/WHEEL,sha256=y4mX-SOX4fYIkonsAGA5N0Oy-8_gI4FXw5HNI1xqvWg,91
33
+ hydroserverpy-0.2.3.dist-info/top_level.txt,sha256=Zf37hrncXLOYvXhgCrf5mZdeq81G9fShdE2LfYbtb7w,14
34
+ hydroserverpy-0.2.3.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
35
+ hydroserverpy-0.2.3.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.41.3)
2
+ Generator: setuptools (70.2.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5