specklia 1.9.12__tar.gz → 1.9.14__tar.gz
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-1.9.12 → specklia-1.9.14}/PKG-INFO +1 -1
- {specklia-1.9.12 → specklia-1.9.14}/specklia/client.py +18 -5
- {specklia-1.9.12 → specklia-1.9.14}/specklia.egg-info/PKG-INFO +1 -1
- {specklia-1.9.12 → specklia-1.9.14}/tests/test_client.py +2 -1
- {specklia-1.9.12 → specklia-1.9.14}/LICENCE +0 -0
- {specklia-1.9.12 → specklia-1.9.14}/README.md +0 -0
- {specklia-1.9.12 → specklia-1.9.14}/setup.cfg +0 -0
- {specklia-1.9.12 → specklia-1.9.14}/setup.py +0 -0
- {specklia-1.9.12 → specklia-1.9.14}/specklia/__init__.py +0 -0
- {specklia-1.9.12 → specklia-1.9.14}/specklia/chunked_transfer.py +0 -0
- {specklia-1.9.12 → specklia-1.9.14}/specklia/utilities.py +0 -0
- {specklia-1.9.12 → specklia-1.9.14}/specklia.egg-info/SOURCES.txt +0 -0
- {specklia-1.9.12 → specklia-1.9.14}/specklia.egg-info/dependency_links.txt +0 -0
- {specklia-1.9.12 → specklia-1.9.14}/specklia.egg-info/requires.txt +0 -0
- {specklia-1.9.12 → specklia-1.9.14}/specklia.egg-info/top_level.txt +0 -0
- {specklia-1.9.12 → specklia-1.9.14}/tests/test_chunked_transfer.py +0 -0
- {specklia-1.9.12 → specklia-1.9.14}/tests/test_utilities.py +0 -0
|
@@ -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, Optional, Tuple, Union
|
|
7
|
+
from typing import Dict, List, Literal, Optional, Tuple, Union
|
|
8
8
|
import warnings
|
|
9
9
|
|
|
10
10
|
from dateutil import parser
|
|
@@ -270,7 +270,8 @@ class Specklia:
|
|
|
270
270
|
raise NotImplementedError()
|
|
271
271
|
|
|
272
272
|
def add_points_to_dataset(
|
|
273
|
-
self: Specklia, dataset_id: str, new_points: List[Dict[str, Union[Dict, gpd.GeoDataFrame]]]
|
|
273
|
+
self: Specklia, dataset_id: str, new_points: List[Dict[str, Union[Dict, gpd.GeoDataFrame]]],
|
|
274
|
+
duplicate_source_behaviour: Literal['error', 'ignore', 'replace', 'merge'] = 'error') -> None:
|
|
274
275
|
"""
|
|
275
276
|
Add new data to a dataset.
|
|
276
277
|
|
|
@@ -300,6 +301,12 @@ class Specklia:
|
|
|
300
301
|
The timestamp column must contain POSIX timestamps.
|
|
301
302
|
The 'geometry' column must contain Points following the (lon, lat) convention.
|
|
302
303
|
The GeoDataFrame must have its CRS specified as EPSG 4326.
|
|
304
|
+
duplicate_source_behaviour : Literal['error', 'ignore', 'replace', 'merge']
|
|
305
|
+
Determines what should happen if a source already exists in the dataset:
|
|
306
|
+
- 'error': Throw an error.
|
|
307
|
+
- 'ignore': Ignore the incoming data and continue. Leave existing data unchanged.
|
|
308
|
+
- 'replace': Delete existing data for the source, and replace it with the incoming data.
|
|
309
|
+
- 'merge': Append incoming data to existing data, sharing the same source.
|
|
303
310
|
"""
|
|
304
311
|
# serialise and upload each dataframe
|
|
305
312
|
for n in new_points:
|
|
@@ -308,9 +315,15 @@ class Specklia:
|
|
|
308
315
|
chunked_transfer.serialise_dataframe(n['gdf'])), _log)
|
|
309
316
|
del n['gdf']
|
|
310
317
|
|
|
311
|
-
response = requests.post(
|
|
312
|
-
|
|
313
|
-
|
|
318
|
+
response = requests.post(
|
|
319
|
+
self.server_url + "/ingest",
|
|
320
|
+
json={
|
|
321
|
+
'dataset_id': dataset_id,
|
|
322
|
+
'new_points': new_points,
|
|
323
|
+
'duplicate_source_behaviour': duplicate_source_behaviour,
|
|
324
|
+
},
|
|
325
|
+
headers={"Authorization": "Bearer " + self.auth_token},
|
|
326
|
+
)
|
|
314
327
|
_check_response_ok(response)
|
|
315
328
|
|
|
316
329
|
_log.info('Added new data to specklia dataset ID %s.', dataset_id)
|
|
@@ -104,7 +104,8 @@ def test_add_points_to_dataset(
|
|
|
104
104
|
call('https://localhost/ingest',
|
|
105
105
|
json={'dataset_id': 'dummy_dataset',
|
|
106
106
|
'new_points': [
|
|
107
|
-
{'source': {'reference': 'cheese'}, 'chunk_set_uuid': 'brian'}]
|
|
107
|
+
{'source': {'reference': 'cheese'}, 'chunk_set_uuid': 'brian'}],
|
|
108
|
+
'duplicate_source_behaviour': 'error'},
|
|
108
109
|
headers={'Authorization': 'Bearer fake_token'})])
|
|
109
110
|
|
|
110
111
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|