diff --git a/activestorage/active.py b/activestorage/active.py index 438c52c0..efa29b47 100644 --- a/activestorage/active.py +++ b/activestorage/active.py @@ -515,20 +515,19 @@ def _from_storage(self, ds, indexer, chunks, out_shape, out_dtype, if self.interface_type == "s3" and self._version == 2: if self.storage_options is not None: key, secret = None, None - if self.storage_options.get("anon", None) is True: - print("Reductionist session for Anon S3 bucket.") - session = reductionist.get_session( - None, None, S3_ACTIVE_STORAGE_CACERT) if "key" in self.storage_options: key = self.storage_options["key"] if "secret" in self.storage_options: secret = self.storage_options["secret"] - if key and secret: - session = reductionist.get_session( - key, secret, S3_ACTIVE_STORAGE_CACERT) + elif self.storage_options.get("anon", None) is True: + print("Reductionist session for Anon S3 bucket.") + key = None + secret = None else: - session = reductionist.get_session( - S3_ACCESS_KEY, S3_SECRET_KEY, S3_ACTIVE_STORAGE_CACERT) + key = S3_ACCESS_KEY + secret = S3_SECRET_KEY + session = reductionist.get_session( + key, secret, S3_ACTIVE_STORAGE_CACERT) else: session = reductionist.get_session(S3_ACCESS_KEY, S3_SECRET_KEY, diff --git a/activestorage/reductionist.py b/activestorage/reductionist.py index 17b26d21..002c454b 100644 --- a/activestorage/reductionist.py +++ b/activestorage/reductionist.py @@ -24,11 +24,6 @@ def get_session(username: str, password: str, :returns: a client session object. """ session = requests.Session() - # TODO Stack-HPC - # we need to allow Anon buckets. though this - # will break connection to data server - # if username is None and password is None: - # return session session.auth = (username, password) session.verify = cacert or False return session @@ -91,6 +86,7 @@ def reduce_chunk(session, print(f"Reductionist request data dictionary: {request_data}") api_operation = "sum" if operation == "mean" else operation or "select" url = f'{server}/v2/{api_operation}/' + print("Reductionist Session auth:", session.auth) response = request(session, url, request_data) if response.ok: diff --git a/tests/test_real_s3.py b/tests/test_real_s3.py index 1af391d9..36215ed2 100644 --- a/tests/test_real_s3.py +++ b/tests/test_real_s3.py @@ -31,9 +31,9 @@ def test_anon_s3(): }, active_storage_url=active_storage_url) active._version = 2 - with pytest.raises(ReductionistError): - result = active.min()[:] - assert result == 197.69595 + + result = active.min()[:] + assert result == 197.69595 def test_s3_small_file():