Skip to content

Commit 32fec36

Browse files
committed
debug
1 parent e9b7907 commit 32fec36

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

xarray/backends/pydap_.py

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,24 +54,34 @@ def __getitem__(self, key):
5454
)
5555

5656
def _getitem(self, key):
57-
if self._batch and hasattr(self.array, "dataset"): # is self.array not loaded?
57+
if self._batch and hasattr(self.array, "dataset"):
5858
# this are both True only for pydap>3.5.5
59-
from pydap.lib import resolve_batch_for_all_variables
59+
# from pydap.lib import resolve_batch_for_all_variables
60+
from pydap.lib import get_batch_data
6061

6162
dataset = self.array.dataset
62-
resolve_batch_for_all_variables(self.array, key, checksums=self._checksums)
63-
result = np.asarray(
64-
dataset._current_batch_promise.wait_for_result(self.array.id)
65-
)
63+
print("[batching]", self.array.id)
64+
if not dataset[self.array.id]._is_data_loaded():
65+
print("data not loaded", self.array.id)
66+
# data has not been deserialized yet
67+
# runs only once per store/hierarchy
68+
get_batch_data(self.array, checksums=self._checksums, key=key)
69+
result = np.asarray(dataset[self.array.id].data)
70+
result = robust_getitem(result, key, catch=ValueError)
6671
else:
72+
print("[non-batching]", self.array.id)
6773
result = robust_getitem(self.array, key, catch=ValueError)
68-
# try:
6974
result = np.asarray(result.data)
70-
# except AttributeError:
71-
# result = np.asarray(result)
7275
axis = tuple(n for n, k in enumerate(key) if isinstance(k, integer_types))
76+
print(key)
77+
print("axis:", axis)
78+
# print("ndim", result.ndim)
79+
# print("array.ndim", self.array.ndim)
7380
if result.ndim + len(axis) != self.array.ndim and axis:
81+
# print('here????')
82+
# print("squeezed result", np.shape(result))
7483
result = np.squeeze(result, axis)
84+
# print("squeezed result", np.shape(result))
7585
return result
7686

7787

@@ -246,9 +256,9 @@ def _get_data_array(self, var):
246256
from pydap.lib import get_batch_data
247257

248258
if not var._is_data_loaded():
249-
# this implies dat has not been deserialized yet
259+
# data has not been deserialized yet
250260
# runs only once per store/hierarchy
251-
get_batch_data(var.parent, checksums=self._checksums)
261+
get_batch_data(var, checksums=self._checksums)
252262
return self.dataset[var.id].data
253263

254264

0 commit comments

Comments
 (0)