Change method: statistic from Property to Method to allow eg active.mean(axis=(0, 1)) and instriduce comprehensive testing of Reductionist axis implementation#300
Conversation
… the headers such as x-activestorage-count in favour of returning their data as part of the JSON payload.
|
@maxstack many thanks for looking into this! I think I found the issue at hand - in the current Reductionist, the response is a dict that has a "bytes" key eg: but that value comes in as raw bytes and needs to be decoded at end pount by the Client; this explains a few things:
You can see the 503 from the failed test: -> that's a json decoder error (which also, incidentally, completely destroyed the memory on my local machine). We should not get Reductionist to return raw bytes, we need actual data that can not risk corruption and the Client being unable to decode it and use. Is this something doable? Cheers 🍺 |
|
@maxstack I added a test that runs with a small file, run it like so: the test uses a small file with data 15x143x144, and looks like this: def test_small_file_axis_0_1():
"""Fails: activestorage.reductionist.ReductionistError: Reductionist error: HTTP 502: -"""
active = build_active_small_file()
result = active.min(axis=(0, 1))[:]
print("Reductionist final result", result)
assert result == [[[[164.8125]]]]the result that Reductionist returns looks like: so it looks like Reductionist is not applying a final statistic, by the looks of it - no idea why there are 101 elements in that array though; at any rate, the full payload sent by Reductionist looks like this: bytes is 576 long, so that's a bit weird too. Anyway, at least this test runs 🍺 |
… "url" with accompanying "interface_type" to denote either "s3" or "http" / "https" backend
The following example would work, tested with TLS cert and authentication:
storage_options = {
'username': "admin",
'password': "admin",
'client_kwargs': {'endpoint_url': "https://example.net:8000"}, # final proxy
}
active_storage_url = "https://reductionist.example.net/" # Reductionist
active = Active("file_path/file.nc", 'm01s30i111', storage_type="https",
storage_options=storage_options,
active_storage_url=active_storage_url)
…e_type as this is auto-detected
|
@maxstack great many thanks for the good work done, mate! This is all spiffy and I'm merging now - big leaps with our work here 🍻 |
The Big One
API change
meanis not a property anymore, but a method, soactive.mean[...]becomesactive.mean()[...]so we can pass args and kwargs, so now you canactive.mean(axis=(0, 1))[...]axisObsolete points, mainly from Max-V conversations
Main test case for Reductionist with axis
https://github.com/NCAS-CMS/PyActiveStorage/blob/axis_api/tests/test_real_s3_with_axes.py
Test Case 1
Test Case 2
Test Case 3
These fails are here https://github.com/NCAS-CMS/PyActiveStorage/actions/runs/20272446127/job/58211728980?pr=300