Skip to content

Commit dd0da7d

Browse files
Merge pull request #309 from NCAS-CMS/use_dataset_for_https
Allow the use of pyfive.Dataset for interface_type https as well
2 parents 9fc759c + 459e96f commit dd0da7d

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

activestorage/active.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ def __init__(self,
250250
elif input_variable and self.interface_type == "s3":
251251
self.filename = self.ds.id._filename
252252
elif input_variable and self.interface_type == "https":
253-
self.filename = self.ds
253+
self.filename = self.ds.id._filename
254254

255255
# get storage_options
256256
self.storage_options = storage_options
@@ -726,7 +726,7 @@ def _process_chunk(self,
726726
elif self.interface_type == "https" and self._version == 2:
727727
tmp, count = reductionist.reduce_chunk(session,
728728
self.active_storage_url,
729-
f"{self.uri}",
729+
self.filename,
730730
offset,
731731
size,
732732
compressor,

tests/test_real_https.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,20 @@ def test_https():
9292
assert result.shape == (1, 1, 144, 192)
9393
assert result[0, 0, 0, 0] == f_1
9494
assert result[0, 0, 143, 191] == f_2
95+
96+
# run with pyfive.Dataset instead of File
97+
dataset = load_from_https(test_file_uri)
98+
av = dataset['ta']
99+
active = Active(av,
100+
active_storage_url=active_storage_url)
101+
active._version = 2
102+
print("Interface type", active.interface_type)
103+
result = active.min(axis=(0, 1))[:]
104+
print("Result is", result)
105+
print("Result shape is", result.shape)
106+
assert result.shape == (1, 1, 144, 192)
107+
assert result[0, 0, 0, 0] == f_1
108+
assert result[0, 0, 143, 191] == f_2
95109

96110

97111
@pytest.mark.skip(

tests/test_real_s3.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ def test_s3_small_file():
6161
assert result == 222.09129333496094
6262

6363

64-
@pytest.mark.xfail(reason="Pyfive needs PR #197")
6564
def test_s3_small_dataset():
6665
"""Run an S3 test on a small file."""
6766
storage_options = {

0 commit comments

Comments
 (0)