Skip to content

Commit c5f4d62

Browse files
committed
add extra kwarg to request_data
1 parent 70dc84e commit c5f4d62

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

activestorage/active.py

+5-6
Original file line numberDiff line numberDiff line change
@@ -243,9 +243,6 @@ def __load_nc_file(self):
243243
nc = load_from_s3(self.uri, self.storage_options)
244244
elif self.storage_type == "https":
245245
nc = load_from_https(self.uri)
246-
# testing only
247-
elif self.storage_type == "https-Reductionist":
248-
nc = load_from_https(self.uri)
249246
self.filename = self.uri
250247
self.ds = nc[ncvar]
251248

@@ -522,7 +519,7 @@ def _process_chunk(self, session, ds, chunks, chunk_coords, chunk_selection, cou
522519
chunk_selection, method=self.method
523520
)
524521

525-
elif self.storage_type == "s3" and self._version==2:
522+
elif self.storage_type == "s3" and self._version == 2:
526523
# S3: pass in pre-configured storage options (credentials)
527524
# print("S3 rfile is:", self.filename)
528525
parsed_url = urllib.parse.urlparse(self.filename)
@@ -570,13 +567,14 @@ def _process_chunk(self, session, ds, chunks, chunk_coords, chunk_selection, cou
570567
# this is for testing ONLY until Reductionist is able to handle https
571568
# located files; after that, we can pipe any regular https file through
572569
# to Reductionist, provided the https server is "closer" to Reductionist
573-
elif self.storage_type == "https-Reductionist" and self._version==2:
570+
elif self.storage_type == "https" and self._version == 2:
574571
# build a simple session
575572
session = requests.Session()
576573
session.auth = (None, None)
577574
session.verify = False
578575
bucket = "https"
579576

577+
# note the extra "storage_type" kwarg
580578
tmp, count = reductionist.reduce_chunk(session,
581579
"https://192.171.169.113:8080",
582580
self.filename,
@@ -586,7 +584,8 @@ def _process_chunk(self, session, ds, chunks, chunk_coords, chunk_selection, cou
586584
chunks,
587585
ds._order,
588586
chunk_selection,
589-
operation=self._method)
587+
operation=self._method,
588+
storage_type="https")
590589
elif self.storage_type=='ActivePosix' and self.version==2:
591590
# This is where the DDN Fuse and Infinia wrappers go
592591
raise NotImplementedError

activestorage/reductionist.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def get_session(username: str, password: str, cacert: typing.Optional[str]) -> r
2727

2828
def reduce_chunk(session, server, source, bucket, object,
2929
offset, size, compression, filters, missing, dtype, shape,
30-
order, chunk_selection, operation):
30+
order, chunk_selection, operation, storage_type=None):
3131
"""Perform a reduction on a chunk using Reductionist.
3232
3333
:param server: Reductionist server URL
@@ -50,12 +50,14 @@ def reduce_chunk(session, server, source, bucket, object,
5050
this defines the part of the chunk which is to be
5151
obtained or operated upon.
5252
:param operation: name of operation to perform
53+
:param storage_type: optional testing flag to allow HTTPS reduction
5354
:returns: the reduced data as a numpy array or scalar
5455
:raises ReductionistError: if the request to Reductionist fails
5556
"""
5657

5758
request_data = build_request_data(source, bucket, object, offset, size, compression,
58-
filters, missing, dtype, shape, order, chunk_selection)
59+
filters, missing, dtype, shape, order, chunk_selection,
60+
storage_type=storage_type)
5961
if DEBUG:
6062
print(f"Reductionist request data dictionary: {request_data}")
6163
api_operation = "sum" if operation == "mean" else operation or "select"
@@ -135,7 +137,7 @@ def encode_missing(missing):
135137

136138
def build_request_data(source: str, bucket: str, object: str, offset: int,
137139
size: int, compression, filters, missing, dtype, shape,
138-
order, selection) -> dict:
140+
order, selection, storage_type=None) -> dict:
139141
"""Build request data for Reductionist API."""
140142
request_data = {
141143
'source': source,
@@ -146,6 +148,7 @@ def build_request_data(source: str, bucket: str, object: str, offset: int,
146148
'offset': int(offset),
147149
'size': int(size),
148150
'order': order,
151+
'storage_type': storage_type,
149152
}
150153
if shape:
151154
request_data["shape"] = shape

0 commit comments

Comments
 (0)