terrakio-core 0.2.2__py3-none-any.whl → 0.2.4__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 terrakio-core might be problematic. Click here for more details.

terrakio_core/client.py CHANGED
@@ -1,12 +1,16 @@
1
- import requests
2
- import xarray as xr
1
+ import json
2
+ import asyncio
3
3
  from io import BytesIO
4
4
  from typing import Dict, Any, Optional, Union
5
- import json
5
+
6
+ import requests
6
7
  import aiohttp
7
- import asyncio
8
- from shapely.geometry import shape
8
+ import pandas as pd
9
+ import geopandas as gpd
10
+ import xarray as xr
11
+ from shapely.geometry import shape, mapping
9
12
  from shapely.geometry.base import BaseGeometry as ShapelyGeometry
13
+
10
14
  from .exceptions import APIError, ConfigurationError
11
15
 
12
16
  class BaseClient:
@@ -671,10 +675,6 @@ class BaseClient:
671
675
  """
672
676
  Compute zonal statistics for all geometries in a GeoDataFrame using asyncio for concurrency.
673
677
  """
674
- import asyncio
675
- import pandas as pd
676
- import geopandas as gpd
677
- from shapely.geometry import mapping
678
678
 
679
679
  # Process geometries in batches
680
680
  all_results = []
@@ -971,3 +971,35 @@ class BaseClient:
971
971
  )
972
972
  return self.space_management.delete_data_in_path(path, region)
973
973
 
974
+ def train_model(self, model_name: str, training_data: dict) -> dict:
975
+ """
976
+ Train a model using the external model training API.
977
+
978
+ Args:
979
+ model_name (str): The name of the model to train.
980
+ training_data (dict): Dictionary containing training data parameters.
981
+
982
+ Returns:
983
+ dict: The response from the model training API.
984
+ """
985
+ endpoint = "https://modeltraining-573248941006.australia-southeast1.run.app/train_model"
986
+ payload = {
987
+ "model_name": model_name,
988
+ "training_data": training_data
989
+ }
990
+ try:
991
+ response = self.session.post(endpoint, json=payload, timeout=self.timeout, verify=self.verify)
992
+ if not response.ok:
993
+ error_msg = f"Model training request failed: {response.status_code} {response.reason}"
994
+ try:
995
+ error_data = response.json()
996
+ if "detail" in error_data:
997
+ error_msg += f" - {error_data['detail']}"
998
+ except Exception:
999
+ if response.text:
1000
+ error_msg += f" - {response.text}"
1001
+ raise APIError(error_msg)
1002
+ return response.json()
1003
+ except requests.RequestException as e:
1004
+ raise APIError(f"Model training request failed: {str(e)}")
1005
+
@@ -1,9 +1,7 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: terrakio-core
3
- Version: 0.2.2
3
+ Version: 0.2.4
4
4
  Summary: Core components for Terrakio API clients
5
- Home-page: https://github.com/HaizeaAnalytics/terrakio-python-api
6
- Author: Yupeng Chao
7
5
  Author-email: Yupeng Chao <yupeng@haizea.com.au>
8
6
  Project-URL: Homepage, https://github.com/HaizeaAnalytics/terrakio-python-api
9
7
  Project-URL: Bug Tracker, https://github.com/HaizeaAnalytics/terrakio-python-api/issues
@@ -15,7 +13,7 @@ Classifier: Programming Language :: Python :: 3.10
15
13
  Classifier: License :: OSI Approved :: MIT License
16
14
  Classifier: Operating System :: OS Independent
17
15
  Classifier: Development Status :: 4 - Beta
18
- Requires-Python: >=3.7
16
+ Requires-Python: >3.11
19
17
  Description-Content-Type: text/markdown
20
18
  Requires-Dist: requests>=2.25.0
21
19
  Requires-Dist: aiohttp>=3.8.0
@@ -23,9 +21,6 @@ Requires-Dist: pyyaml>=5.1
23
21
  Requires-Dist: xarray>=2023.1.0
24
22
  Requires-Dist: shapely>=2.0.0
25
23
  Requires-Dist: geopandas>=0.13.0
26
- Dynamic: author
27
- Dynamic: home-page
28
- Dynamic: requires-python
29
24
 
30
25
  # Terrakio Core
31
26
 
@@ -1,6 +1,6 @@
1
1
  terrakio_core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
2
  terrakio_core/auth.py,sha256=Nuj0_X3Hiy17svYgGxrSAR-LXpTlP0J0dSrfMnkPUbI,7717
3
- terrakio_core/client.py,sha256=uxu11vA_G4uZP1TaE0f9C1zjl4bh8oswBbYst-Jb4CU,43555
3
+ terrakio_core/client.py,sha256=ChKbsGsCbkngRZ8mWgAijhKzElL0ZSdRHU2_XF9C7Ss,44850
4
4
  terrakio_core/config.py,sha256=AwJ1VgR5K7N32XCU5k7_Dp1nIv_FYt8MBonq9yKlGzA,2658
5
5
  terrakio_core/dataset_management.py,sha256=hhO35fwStS6HYFQdKP9wkr3DxHgjvpctmIU8UWH6w6U,8742
6
6
  terrakio_core/exceptions.py,sha256=9S-I20-QiDRj1qgjFyYUwYM7BLic_bxurcDOIm2Fu_0,410
@@ -8,7 +8,7 @@ terrakio_core/group_access_management.py,sha256=NJ7SX4keUzZAUENmJ5L6ynKf4eRlqtyi
8
8
  terrakio_core/mass_stats.py,sha256=AqYJsd6nqo2BDh4vEPUDgsv4T0UR1_TPDoXa3WO3gTU,9284
9
9
  terrakio_core/space_management.py,sha256=wlUUQrlj_4U_Lpjn9lbF5oj0Rv3NPvvnrd5mWej5kmA,4211
10
10
  terrakio_core/user_management.py,sha256=MMNWkz0V_9X7ZYjjteuRU4H4W3F16iuQw1dpA2wVTGg,7400
11
- terrakio_core-0.2.2.dist-info/METADATA,sha256=hJV6bpoJSybkz_6J4oCXvGeH5HnVfGL5qpfQkYQ0KjI,1551
12
- terrakio_core-0.2.2.dist-info/WHEEL,sha256=zaaOINJESkSfm_4HQVc5ssNzHCPXhJm0kEUakpsEHaU,91
13
- terrakio_core-0.2.2.dist-info/top_level.txt,sha256=5cBj6O7rNWyn97ND4YuvvXm0Crv4RxttT4JZvNdOG6Q,14
14
- terrakio_core-0.2.2.dist-info/RECORD,,
11
+ terrakio_core-0.2.4.dist-info/METADATA,sha256=dMdHIPIFLVF1UMfTSa7D3GMLOw6nVJwl4hMeMcs0FdQ,1405
12
+ terrakio_core-0.2.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
13
+ terrakio_core-0.2.4.dist-info/top_level.txt,sha256=5cBj6O7rNWyn97ND4YuvvXm0Crv4RxttT4JZvNdOG6Q,14
14
+ terrakio_core-0.2.4.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.8.0)
2
+ Generator: setuptools (80.9.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5