|
27 | 27 | # otherwise, bucket is extracted automatically from full file uri
|
28 | 28 | S3_BUCKET = "bnl"
|
29 | 29 |
|
30 |
| - |
31 | 30 | @pytest.mark.parametrize("storage_options, active_storage_url", storage_options_paramlist)
|
32 | 31 | def test_compression_and_filters_cmip6_data(storage_options, active_storage_url):
|
33 | 32 | """
|
@@ -107,3 +106,79 @@ def test_compression_and_filters_cmip6_forced_s3_from_local(storage_options, act
|
107 | 106 | assert access_denied_err in str(rederr.value)
|
108 | 107 | # assert nc_min == result
|
109 | 108 | # assert result == 239.25946044921875
|
| 109 | + |
| 110 | + |
| 111 | +def test_compression_and_filters_cmip6_forced_s3_from_local_2(): |
| 112 | + """ |
| 113 | + Test use of datasets with compression and filters applied for a real |
| 114 | + CMIP6 dataset (CMIP6-test.nc) - an IPSL file. |
| 115 | +
|
| 116 | + This is for a special anon=True bucket connected to via valid key.secret |
| 117 | + """ |
| 118 | + storage_options = { |
| 119 | + 'key': "f2d55c6dcfc7618b2c34e00b58df3cef", |
| 120 | + 'secret': "$/'#M{0{/4rVhp%n^(XeX$q@y#&(NM3W1->~N.Q6VP.5[@bLpi='nt]AfH)>78pT", |
| 121 | + 'client_kwargs': {'endpoint_url': "https://uor-aces-o.s3-ext.jc.rl.ac.uk"} |
| 122 | + } |
| 123 | + active_storage_url = "https://192.171.169.248:8080" |
| 124 | + test_file = str(Path(__file__).resolve().parent / 'test_data' / 'CMIP6-test.nc') |
| 125 | + with Dataset(test_file) as nc_data: |
| 126 | + nc_min = np.min(nc_data["tas"][0:2,4:6,7:9]) |
| 127 | + print(f"Numpy min from compressed file {nc_min}") |
| 128 | + |
| 129 | + ofile = os.path.basename(test_file) |
| 130 | + test_file_uri = os.path.join( |
| 131 | + S3_BUCKET, |
| 132 | + ofile |
| 133 | + ) |
| 134 | + print("S3 Test file path:", test_file_uri) |
| 135 | + active = Active(test_file_uri, 'tas', storage_type="s3", |
| 136 | + storage_options=storage_options, |
| 137 | + active_storage_url=active_storage_url) |
| 138 | + |
| 139 | + active._version = 1 |
| 140 | + active._method = "min" |
| 141 | + |
| 142 | + result = active[0:2,4:6,7:9] |
| 143 | + assert nc_min == result |
| 144 | + assert result == 239.25946044921875 |
| 145 | + |
| 146 | + |
| 147 | +@pytest.mark.skipif(not USE_S3, reason="we need only localhost Reductionist in GA CI") |
| 148 | +@pytest.mark.skipif(REMOTE_RED, reason="we need only localhost Reductionist in GA CI") |
| 149 | +def test_compression_and_filters_cmip6_forced_s3_using_local_Reductionist(): |
| 150 | + """ |
| 151 | + Test use of datasets with compression and filters applied for a real |
| 152 | + CMIP6 dataset (CMIP6-test.nc) - an IPSL file. |
| 153 | +
|
| 154 | + This is for a special anon=True bucket connected to via valid key.secret |
| 155 | + and uses the locally deployed Reductionist via container. |
| 156 | + """ |
| 157 | + print("Reductionist URL", S3_ACTIVE_STORAGE_URL) |
| 158 | + storage_options = { |
| 159 | + 'key': "f2d55c6dcfc7618b2c34e00b58df3cef", |
| 160 | + 'secret': "$/'#M{0{/4rVhp%n^(XeX$q@y#&(NM3W1->~N.Q6VP.5[@bLpi='nt]AfH)>78pT", |
| 161 | + 'client_kwargs': {'endpoint_url': "https://uor-aces-o.s3-ext.jc.rl.ac.uk"} |
| 162 | + } |
| 163 | + |
| 164 | + test_file = str(Path(__file__).resolve().parent / 'test_data' / 'CMIP6-test.nc') |
| 165 | + with Dataset(test_file) as nc_data: |
| 166 | + nc_min = np.min(nc_data["tas"][0:2,4:6,7:9]) |
| 167 | + print(f"Numpy min from compressed file {nc_min}") |
| 168 | + |
| 169 | + ofile = os.path.basename(test_file) |
| 170 | + test_file_uri = os.path.join( |
| 171 | + S3_BUCKET, |
| 172 | + ofile |
| 173 | + ) |
| 174 | + print("S3 Test file path:", test_file_uri) |
| 175 | + active = Active(test_file_uri, 'tas', storage_type="s3", |
| 176 | + storage_options=storage_options, |
| 177 | + active_storage_url=S3_ACTIVE_STORAGE_URL) |
| 178 | + |
| 179 | + active._version = 1 |
| 180 | + active._method = "min" |
| 181 | + |
| 182 | + result = active[0:2,4:6,7:9] |
| 183 | + assert nc_min == result |
| 184 | + assert result == 239.25946044921875 |
0 commit comments