specklia 1.9.21__tar.gz → 1.9.28__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: specklia
3
- Version: 1.9.21
3
+ Version: 1.9.28
4
4
  Summary: Python client for Specklia, a geospatial point cloud database by Earthwave.
5
5
  Home-page: https://specklia.earthwave.co.uk/
6
6
  Author: Earthwave Ltd
@@ -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.
@@ -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[Dict[str, Union[Dict, gpd.GeoDataFrame]]],
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
- n['chunk_set_uuid'] = chunked_transfer.upload_chunks(
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
- del n['gdf']
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': 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
 
@@ -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
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: specklia
3
- Version: 1.9.21
3
+ Version: 1.9.28
4
4
  Summary: Python client for Specklia, a geospatial point cloud database by Earthwave.
5
5
  Home-page: https://specklia.earthwave.co.uk/
6
6
  Author: Earthwave Ltd
@@ -157,7 +157,7 @@ def test_query_dataset(
157
157
  AttributeError, "object has no attribute 'timestamp'")
158
158
  ])
159
159
  def test_query_dataset_invalid_request(test_client: Specklia, invalid_json: dict,
160
- expected_exception: Exception, expected_match: str):
160
+ expected_exception: type[Exception], expected_match: str):
161
161
  with pytest.raises(expected_exception, match=expected_match):
162
162
  test_client.query_dataset(
163
163
  dataset_id=invalid_json['dataset_id'],
File without changes
File without changes
File without changes
File without changes