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/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
- # Apply xarray printing fix to prevent crashes with GeoDataFrames
38
- self._apply_xarray_fix()
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
- Apply xarray printing fix to prevent crashes when GeoDataFrames contain xarray objects.
43
- This fix is applied automatically when the client is initialized.
44
- """
45
- try:
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
- # Check if fix is already applied globally
48
- if hasattr(xr.DataArray, '_terrakio_fix_applied'):
49
- if self.verbose:
50
- self.logger.info("xarray printing fix already applied")
51
- return
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
- # Store original methods for potential restoration
54
- if not hasattr(xr.DataArray, '_original_iter'):
55
- xr.DataArray._original_iter = xr.DataArray.__iter__
56
- xr.Dataset._original_iter = xr.Dataset.__iter__
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
- # Define safe iteration methods that prevent pandas from iterating
59
- # but leave __repr__ and __str__ untouched for normal xarray printing
60
- def safe_dataarray_iter(self):
61
- # Return infinite iterator that always yields the same safe value
62
- name = getattr(self, 'name', None) or 'unnamed'
63
- shape_str = 'x'.join(map(str, self.shape)) if hasattr(self, 'shape') else 'unknown'
64
- placeholder = f"<DataArray '{name}' {shape_str}>"
65
- while True:
66
- yield placeholder
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
- def safe_dataset_iter(self):
69
- # Return infinite iterator that always yields the same safe value
70
- num_vars = len(self.data_vars) if hasattr(self, 'data_vars') else 0
71
- num_dims = len(self.dims) if hasattr(self, 'dims') else 0
72
- placeholder = f"<Dataset: {num_vars} vars, {num_dims} dims>"
73
- while True:
74
- yield placeholder
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
- # Apply only the iteration fix - leave __repr__ and __str__ untouched
77
- xr.DataArray.__iter__ = safe_dataarray_iter
78
- xr.Dataset.__iter__ = safe_dataset_iter
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
- # Mark as applied to avoid duplicate applications
81
- xr.DataArray._terrakio_fix_applied = True
82
- xr.Dataset._terrakio_fix_applied = True
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
- if self.verbose:
85
- self.logger.info("xarray iteration fix applied - GeoDataFrames with xarray objects will print safely, direct xarray printing unchanged")
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
- except ImportError:
88
- # xarray not installed, skip the fix
89
- if self.verbose:
90
- self.logger.info("xarray not installed, skipping printing fix")
91
- except Exception as e:
92
- # Log warning but don't fail initialization
93
- warning_msg = f"Failed to apply xarray printing fix: {e}"
94
- warnings.warn(warning_msg)
95
- if self.verbose:
96
- self.logger.warning(warning_msg)
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
- Restore original xarray printing behavior.
101
- Call this method if you want to see full xarray representations again.
102
- """
103
- try:
104
- import xarray as xr
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
- if hasattr(xr.DataArray, '_original_iter'):
107
- xr.DataArray.__iter__ = xr.DataArray._original_iter
108
- xr.Dataset.__iter__ = xr.Dataset._original_iter
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
- # Remove the fix markers
111
- if hasattr(xr.DataArray, '_terrakio_fix_applied'):
112
- delattr(xr.DataArray, '_terrakio_fix_applied')
113
- if hasattr(xr.Dataset, '_terrakio_fix_applied'):
114
- delattr(xr.Dataset, '_terrakio_fix_applied')
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
- if self.verbose:
117
- self.logger.info("Original xarray iteration behavior restored")
118
- else:
119
- if self.verbose:
120
- self.logger.info("No xarray fix to restore")
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
- except ImportError:
123
- if self.verbose:
124
- self.logger.info("xarray not available")
125
- except Exception as e:
126
- warning_msg = f"Failed to restore xarray printing: {e}"
127
- warnings.warn(warning_msg)
128
- if self.verbose:
129
- self.logger.warning(warning_msg)
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
- """Initialize the HTTP session - implemented by sync/async clients"""
134
- pass
130
+ # @abstractmethod
131
+ # def _setup_session(self):
132
+ # """Initialize the HTTP session - implemented by sync/async clients"""
133
+ # pass