New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Requester pays environment variable for assets on S3 #82
Comments
Thanks for feedback @arthurelmes, while using environment variables is certainly a valid approach, it is more proper (probably more robust when using remote Dask workers) to use configure-s3-access with |
And please go ahead with a PR |
Actually, conversion from boolean happens inside rasterio, so it's probably not a culprit. But it looks like request_payer environment variable is missing from this list: Lines 31 to 41 in 1db2b1a
might be related to the issue you are observing regarding "requester_pays" option having no effect. Do you want to try adding that and testing if that fixes it? |
Sure thing -- I will try adding the key locally, and see if I can get it to work without specifying the env var externally. Thanks! |
@Kirill888 I tried adding |
Hi @arthurelmes, I've been playing with Landsat too. The following worked for me; there may be something in this that works for you. The following shows two things:
from pystac_client import Client
from odc.stac import configure_s3_access, stac_load
from odc.stac._rio import _dump_rio_config, _CFG # For testing
configure_s3_access(requester_pays=True);
with _CFG.env():
_dump_rio_config()
catalog = Client.open('https://landsatlook.usgs.gov/stac-server/')
product = 'landsat-c2l2-sr'
query_cfg = ["platform=LANDSAT_8", "landsat:collection_category=T1"]
query = catalog.search(
collections=[product], datetime=times, bbox=bbox, query=query_cfg
)
items = list(query.get_items())
def patch(uri: str) -> str:
"""Return the Landsat S3 version of the URI"""
return uri.replace('https://landsatlook.usgs.gov/data/', 's3://usgs-landsat/')
xx = stac_load(
items,
bands=("B4",),
patch_url = patch,
) |
Strange. Even a direct copy/paste of your code (adding in the Library versions:
Thanks for the help! |
I returned to this and encountered essentially the same behaviour reported by @arthurelmes, Manually setting This issue, I think, relates to the (configure_s3) environment not being activated for the (current) thread. That is, under our use patterns, _load.py#L189 seems to be doing the correct thing. While, for example, _load.py#L195 could potentially create the situation we're seeing in this issue. I'll keep digging to find the path(s) through As an example or workaround, the following seems to repeatedly work for me. # Borrowing from above...
from odc.stac import configure_s3_access, stac_load
from odc.stac._rio import _CFG
configure_s3_access(requester_pays=True);
# Manually wrap stac_load the first time
with _CFG.env():
xx = stac_load(
items,
bands=("B4",),
patch_url=patch,
)
# With the rasterio.env.Env() activated for the current thread, further unwrapped loads work as expected
yy = stac_load(more_items, bands=("B4",), patch_url=patch) |
When loading data without Dask, configured RIO environment was ignored, and in case of multi-threaded processing currently activated environment didn't get passed along to processing threads either. Also adds requester payer env var to a list of captured envs.
@mpaget thanks for looking into this, pretty sure that should be fixed by commit referenced above. |
When loading data without Dask, configured RIO environment was ignored, and in case of multi-threaded processing currently activated environment didn't get passed along to processing threads either. Also adds requester payer env var to a list of captured envs.
Although it is possible to use
odc.stac.load
to load items whose assets are in requester-pays S3 buckets (e.g.landsat-c2l2-sr
), the documentation is not entirely clear on how to accomplish this. Setting the environment variableAWS_REQUEST_PAYER
torequester
does the trick, but I was unable to useodc.stac.configure_rio(aws={"requester_pays": True})
to load the data. I'm happy to make a docs PR here to address this topic, unless there is a more native way of going about this.The text was updated successfully, but these errors were encountered: