specklia 1.9.21__py3-none-any.whl → 1.9.22__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.
- specklia/chunked_transfer.py +1 -1
- specklia/client.py +13 -7
- specklia/utilities.py +9 -1
- {specklia-1.9.21.dist-info → specklia-1.9.22.dist-info}/METADATA +1 -1
- specklia-1.9.22.dist-info/RECORD +9 -0
- specklia-1.9.21.dist-info/RECORD +0 -9
- {specklia-1.9.21.dist-info → specklia-1.9.22.dist-info}/LICENCE +0 -0
- {specklia-1.9.21.dist-info → specklia-1.9.22.dist-info}/WHEEL +0 -0
- {specklia-1.9.21.dist-info → specklia-1.9.22.dist-info}/top_level.txt +0 -0
specklia/chunked_transfer.py
CHANGED
|
@@ -212,7 +212,7 @@ def deserialise_dataframe(data: bytes) -> Union[DataFrame, GeoDataFrame]:
|
|
|
212
212
|
"""
|
|
213
213
|
try:
|
|
214
214
|
buffer = BytesIO(data)
|
|
215
|
-
df = read_geofeather(buffer)
|
|
215
|
+
df = read_geofeather(buffer) # type: ignore
|
|
216
216
|
except ValueError as e:
|
|
217
217
|
# First attempt to deserialise as a geodataframe. If geo meta is missing, we expect a clear ValueError
|
|
218
218
|
# and we then load as a plain dataframe instead.
|
specklia/client.py
CHANGED
|
@@ -4,7 +4,7 @@ from __future__ import annotations
|
|
|
4
4
|
from datetime import datetime
|
|
5
5
|
import json
|
|
6
6
|
import logging
|
|
7
|
-
from typing import Dict, List, Literal, Optional, Tuple, Union
|
|
7
|
+
from typing import cast, Dict, List, Literal, Optional, Tuple, Union
|
|
8
8
|
import warnings
|
|
9
9
|
|
|
10
10
|
from dateutil import parser
|
|
@@ -15,6 +15,7 @@ from shapely import MultiPolygon, Polygon, to_geojson
|
|
|
15
15
|
from shapely.geometry import shape
|
|
16
16
|
|
|
17
17
|
from specklia import chunked_transfer, utilities
|
|
18
|
+
from specklia.utilities import NewPoints
|
|
18
19
|
|
|
19
20
|
_log = logging.getLogger(__name__)
|
|
20
21
|
|
|
@@ -239,7 +240,7 @@ class Specklia:
|
|
|
239
240
|
# perform some light deserialisation of sources for backwards compatibility.
|
|
240
241
|
sources = utilities.deserialise_sources(response_dict['sources'])
|
|
241
242
|
|
|
242
|
-
return gdf, sources
|
|
243
|
+
return cast(gpd.GeoDataFrame, gdf), cast(list[dict], sources)
|
|
243
244
|
|
|
244
245
|
def update_points_in_dataset(
|
|
245
246
|
self: Specklia, _dataset_id: str, _new_points: pd.DataFrame, _source_description: Dict) -> None:
|
|
@@ -270,7 +271,7 @@ class Specklia:
|
|
|
270
271
|
raise NotImplementedError()
|
|
271
272
|
|
|
272
273
|
def add_points_to_dataset(
|
|
273
|
-
self: Specklia, dataset_id: str, new_points: List[
|
|
274
|
+
self: Specklia, dataset_id: str, new_points: List[NewPoints],
|
|
274
275
|
duplicate_source_behaviour: Literal['error', 'ignore', 'replace', 'merge'] = 'error') -> None:
|
|
275
276
|
"""
|
|
276
277
|
Add new data to a dataset.
|
|
@@ -309,17 +310,22 @@ class Specklia:
|
|
|
309
310
|
- 'merge': Append incoming data to existing data, sharing the same source.
|
|
310
311
|
"""
|
|
311
312
|
# serialise and upload each dataframe
|
|
313
|
+
upload_points = []
|
|
312
314
|
for n in new_points:
|
|
313
|
-
|
|
315
|
+
chunk_set_uuid = chunked_transfer.upload_chunks(
|
|
314
316
|
self.server_url, chunked_transfer.split_into_chunks(
|
|
315
317
|
chunked_transfer.serialise_dataframe(n['gdf'])), _log)
|
|
316
|
-
|
|
318
|
+
upload_points.append({
|
|
319
|
+
'source': n['source'],
|
|
320
|
+
'chunk_set_uuid': chunk_set_uuid
|
|
321
|
+
})
|
|
322
|
+
del n
|
|
317
323
|
|
|
318
324
|
response = requests.post(
|
|
319
325
|
self.server_url + "/ingest",
|
|
320
326
|
json={
|
|
321
327
|
'dataset_id': dataset_id,
|
|
322
|
-
'new_points':
|
|
328
|
+
'new_points': upload_points,
|
|
323
329
|
'duplicate_source_behaviour': duplicate_source_behaviour,
|
|
324
330
|
},
|
|
325
331
|
headers={"Authorization": "Bearer " + self.auth_token},
|
|
@@ -672,7 +678,7 @@ class Specklia:
|
|
|
672
678
|
lambda x: parser.parse(x, ignoretz=True) if x is not None else None)
|
|
673
679
|
if column == 'epsg4326_coverage':
|
|
674
680
|
datasets_df[column] = gpd.GeoSeries(
|
|
675
|
-
datasets_df[column].apply(lambda x: shape(x) if x is not None else None), crs=4326)
|
|
681
|
+
datasets_df[column].apply(lambda x: shape(x) if x is not None else None), crs=4326) # type: ignore
|
|
676
682
|
|
|
677
683
|
return datasets_df.convert_dtypes() # convert the rest of the dtypes to pandas' best guest
|
|
678
684
|
|
specklia/utilities.py
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"""This file contains client-side utilities provided to make it easier to use Specklia."""
|
|
2
2
|
from datetime import datetime
|
|
3
3
|
import os
|
|
4
|
-
from typing import Dict, List, Optional
|
|
4
|
+
from typing import Dict, List, Optional, TypedDict
|
|
5
5
|
|
|
6
6
|
import geopandas as gpd
|
|
7
7
|
import numpy as np
|
|
8
8
|
import rasterio
|
|
9
|
+
import rasterio.transform
|
|
9
10
|
from shapely.geometry import shape
|
|
10
11
|
|
|
11
12
|
|
|
@@ -113,3 +114,10 @@ def deserialise_sources(sources: List[Dict]) -> List[Dict]:
|
|
|
113
114
|
source['max_time'] = datetime.fromisoformat(source['max_time'])
|
|
114
115
|
|
|
115
116
|
return sources
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
class NewPoints(TypedDict):
|
|
120
|
+
"""List of data points to ingest."""
|
|
121
|
+
|
|
122
|
+
gdf: gpd.GeoDataFrame
|
|
123
|
+
source: dict
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
specklia/__init__.py,sha256=ePVHqq642NocoE8tS0cNTd0B5wJdUB7r3y815oQXD6A,51
|
|
2
|
+
specklia/chunked_transfer.py,sha256=sQGh_0M3DcJw4Uu1Upb7zA9L1syupI9JXVL_94OoNEs,8343
|
|
3
|
+
specklia/client.py,sha256=IlOr3CP_0BJpB0oOvkvHFgtiqmmFynpUriDM3NHUVeU,42088
|
|
4
|
+
specklia/utilities.py,sha256=fs9DOSq-0hdgOlGAnPY_og5QngDcu3essVAupz6ychM,5170
|
|
5
|
+
specklia-1.9.22.dist-info/LICENCE,sha256=kjWTA-TtT_rJtsWuAgWvesvu01BytVXgt_uCbeQgjOg,1061
|
|
6
|
+
specklia-1.9.22.dist-info/METADATA,sha256=D_E5534h_qfU9v4B7djdSEOWw3XheSIt5JHIBmoR24k,3082
|
|
7
|
+
specklia-1.9.22.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
8
|
+
specklia-1.9.22.dist-info/top_level.txt,sha256=XgU53UpAJbqEni5EjJaPdQPYuNx16Geg2I5A9lo1BQw,9
|
|
9
|
+
specklia-1.9.22.dist-info/RECORD,,
|
specklia-1.9.21.dist-info/RECORD
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
specklia/__init__.py,sha256=ePVHqq642NocoE8tS0cNTd0B5wJdUB7r3y815oQXD6A,51
|
|
2
|
-
specklia/chunked_transfer.py,sha256=Mw0wLaOYzNvVTRE421RdHnsnaDbEpNYgQNGV_kcjuVs,8327
|
|
3
|
-
specklia/client.py,sha256=P4XXzC24OuLK5S6joc7d0zt9Q39-IveAK87EUCF7n3M,41858
|
|
4
|
-
specklia/utilities.py,sha256=0_pgTbcq2RgQhys0-CZ6h5YZJg9ZMPhD_ibGPggFUpE,5018
|
|
5
|
-
specklia-1.9.21.dist-info/LICENCE,sha256=kjWTA-TtT_rJtsWuAgWvesvu01BytVXgt_uCbeQgjOg,1061
|
|
6
|
-
specklia-1.9.21.dist-info/METADATA,sha256=JIadoGfwW8TPR6JqHW-h_N84EdAU9Dn8-Gy1E3M60sQ,3082
|
|
7
|
-
specklia-1.9.21.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
8
|
-
specklia-1.9.21.dist-info/top_level.txt,sha256=XgU53UpAJbqEni5EjJaPdQPYuNx16Geg2I5A9lo1BQw,9
|
|
9
|
-
specklia-1.9.21.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|