terrakio-core 0.4.3__py3-none-any.whl → 0.4.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/__init__.py +3 -1
- terrakio_core/accessors.py +477 -0
- terrakio_core/async_client.py +23 -38
- terrakio_core/client.py +83 -84
- terrakio_core/convenience_functions/convenience_functions.py +316 -324
- terrakio_core/endpoints/auth.py +8 -1
- terrakio_core/endpoints/mass_stats.py +13 -9
- terrakio_core/endpoints/model_management.py +604 -948
- terrakio_core/sync_client.py +341 -33
- {terrakio_core-0.4.3.dist-info → terrakio_core-0.4.4.dist-info}/METADATA +2 -1
- terrakio_core-0.4.4.dist-info/RECORD +22 -0
- terrakio_core-0.4.3.dist-info/RECORD +0 -21
- {terrakio_core-0.4.3.dist-info → terrakio_core-0.4.4.dist-info}/WHEEL +0 -0
- {terrakio_core-0.4.3.dist-info → terrakio_core-0.4.4.dist-info}/top_level.txt +0 -0
terrakio_core/client.py
CHANGED
|
@@ -8,7 +8,6 @@ import xarray as xr
|
|
|
8
8
|
|
|
9
9
|
class BaseClient():
|
|
10
10
|
def __init__(self, url: Optional[str] = None, api_key: Optional[str] = None, verbose: bool = False):
|
|
11
|
-
|
|
12
11
|
self.verbose = verbose
|
|
13
12
|
self.logger = logging.getLogger("terrakio")
|
|
14
13
|
if verbose:
|
|
@@ -34,101 +33,101 @@ class BaseClient():
|
|
|
34
33
|
|
|
35
34
|
self.token = config.get('token')
|
|
36
35
|
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
# # Apply xarray printing fix to prevent crashes with GeoDataFrames
|
|
37
|
+
# self._apply_xarray_fix()
|
|
39
38
|
|
|
40
|
-
def _apply_xarray_fix(self):
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
39
|
+
# def _apply_xarray_fix(self):
|
|
40
|
+
# """
|
|
41
|
+
# Apply xarray printing fix to prevent crashes when GeoDataFrames contain xarray objects.
|
|
42
|
+
# This fix is applied automatically when the client is initialized.
|
|
43
|
+
# """
|
|
44
|
+
# try:
|
|
46
45
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
46
|
+
# # Check if fix is already applied globally
|
|
47
|
+
# if hasattr(xr.DataArray, '_terrakio_fix_applied'):
|
|
48
|
+
# if self.verbose:
|
|
49
|
+
# self.logger.info("xarray printing fix already applied")
|
|
50
|
+
# return
|
|
52
51
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
52
|
+
# # Store original methods for potential restoration
|
|
53
|
+
# if not hasattr(xr.DataArray, '_original_iter'):
|
|
54
|
+
# xr.DataArray._original_iter = xr.DataArray.__iter__
|
|
55
|
+
# xr.Dataset._original_iter = xr.Dataset.__iter__
|
|
57
56
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
57
|
+
# # Define safe iteration methods that prevent pandas from iterating
|
|
58
|
+
# # but leave __repr__ and __str__ untouched for normal xarray printing
|
|
59
|
+
# def safe_dataarray_iter(self):
|
|
60
|
+
# # Return infinite iterator that always yields the same safe value
|
|
61
|
+
# name = getattr(self, 'name', None) or 'unnamed'
|
|
62
|
+
# shape_str = 'x'.join(map(str, self.shape)) if hasattr(self, 'shape') else 'unknown'
|
|
63
|
+
# placeholder = f"<DataArray '{name}' {shape_str}>"
|
|
64
|
+
# while True:
|
|
65
|
+
# yield placeholder
|
|
67
66
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
67
|
+
# def safe_dataset_iter(self):
|
|
68
|
+
# # Return infinite iterator that always yields the same safe value
|
|
69
|
+
# num_vars = len(self.data_vars) if hasattr(self, 'data_vars') else 0
|
|
70
|
+
# num_dims = len(self.dims) if hasattr(self, 'dims') else 0
|
|
71
|
+
# placeholder = f"<Dataset: {num_vars} vars, {num_dims} dims>"
|
|
72
|
+
# while True:
|
|
73
|
+
# yield placeholder
|
|
75
74
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
75
|
+
# # Apply only the iteration fix - leave __repr__ and __str__ untouched
|
|
76
|
+
# xr.DataArray.__iter__ = safe_dataarray_iter
|
|
77
|
+
# xr.Dataset.__iter__ = safe_dataset_iter
|
|
79
78
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
79
|
+
# # Mark as applied to avoid duplicate applications
|
|
80
|
+
# xr.DataArray._terrakio_fix_applied = True
|
|
81
|
+
# xr.Dataset._terrakio_fix_applied = True
|
|
83
82
|
|
|
84
|
-
|
|
85
|
-
|
|
83
|
+
# if self.verbose:
|
|
84
|
+
# self.logger.info("xarray iteration fix applied - GeoDataFrames with xarray objects will print safely, direct xarray printing unchanged")
|
|
86
85
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
86
|
+
# except ImportError:
|
|
87
|
+
# # xarray not installed, skip the fix
|
|
88
|
+
# if self.verbose:
|
|
89
|
+
# self.logger.info("xarray not installed, skipping printing fix")
|
|
90
|
+
# except Exception as e:
|
|
91
|
+
# # Log warning but don't fail initialization
|
|
92
|
+
# warning_msg = f"Failed to apply xarray printing fix: {e}"
|
|
93
|
+
# warnings.warn(warning_msg)
|
|
94
|
+
# if self.verbose:
|
|
95
|
+
# self.logger.warning(warning_msg)
|
|
97
96
|
|
|
98
|
-
def restore_xarray_printing(self):
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
97
|
+
# def restore_xarray_printing(self):
|
|
98
|
+
# """
|
|
99
|
+
# Restore original xarray printing behavior.
|
|
100
|
+
# Call this method if you want to see full xarray representations again.
|
|
101
|
+
# """
|
|
102
|
+
# try:
|
|
103
|
+
# import xarray as xr
|
|
105
104
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
105
|
+
# if hasattr(xr.DataArray, '_original_iter'):
|
|
106
|
+
# xr.DataArray.__iter__ = xr.DataArray._original_iter
|
|
107
|
+
# xr.Dataset.__iter__ = xr.Dataset._original_iter
|
|
109
108
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
109
|
+
# # Remove the fix markers
|
|
110
|
+
# if hasattr(xr.DataArray, '_terrakio_fix_applied'):
|
|
111
|
+
# delattr(xr.DataArray, '_terrakio_fix_applied')
|
|
112
|
+
# if hasattr(xr.Dataset, '_terrakio_fix_applied'):
|
|
113
|
+
# delattr(xr.Dataset, '_terrakio_fix_applied')
|
|
115
114
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
115
|
+
# if self.verbose:
|
|
116
|
+
# self.logger.info("Original xarray iteration behavior restored")
|
|
117
|
+
# else:
|
|
118
|
+
# if self.verbose:
|
|
119
|
+
# self.logger.info("No xarray fix to restore")
|
|
121
120
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
121
|
+
# except ImportError:
|
|
122
|
+
# if self.verbose:
|
|
123
|
+
# self.logger.info("xarray not available")
|
|
124
|
+
# except Exception as e:
|
|
125
|
+
# warning_msg = f"Failed to restore xarray printing: {e}"
|
|
126
|
+
# warnings.warn(warning_msg)
|
|
127
|
+
# if self.verbose:
|
|
128
|
+
# self.logger.warning(warning_msg)
|
|
130
129
|
|
|
131
|
-
@abstractmethod
|
|
132
|
-
def _setup_session(self):
|
|
133
|
-
|
|
134
|
-
|
|
130
|
+
# @abstractmethod
|
|
131
|
+
# def _setup_session(self):
|
|
132
|
+
# """Initialize the HTTP session - implemented by sync/async clients"""
|
|
133
|
+
# pass
|