openclimatefix / Satip

Satip contains the code necessary for retrieving, transforming and storing EUMETSAT data
https://satip.readthedocs.io/
MIT License
41 stars 28 forks source link

botocore.exceptions.NoCredentialsError: Unable to locate credentials #217

Closed TomPughe closed 8 months ago

TomPughe commented 8 months ago

I'm having issues getting the app to complete successfully. I'm running it with the command:

python3 satip/app.py --api-key=[redacted]--api-secret=[redacted] --save-dir="data" --history="20 minutes"

But I get the following exception:

Traceback (most recent call last):
  File "/home/vboxuser/Documents/open_src/Satip/satip/app.py", line 252, in <module>
    run()
...
  File "/home/vboxuser/Documents/open_src/Satip/satip/app.py", line 235, in run
    utils.collate_files_into_latest(save_dir=save_dir, using_backup=use_backup)
  File "/home/vboxuser/Documents/open_src/Satip/satip/utils.py", line 1065, in collate_files_into_latest
    xr.open_mfdataset(
...
  File "/usr/local/lib/python3.10/dist-packages/botocore/auth.py", line 418, in add_auth
    raise NoCredentialsError()
botocore.exceptions.NoCredentialsError: Unable to locate credentials

Occurring in utils.py:

 def collate_files_into_latest(save_dir: str, using_backup: bool = False):
 ...
    hrv_files = ["zip:///::s3://" + str(f) for f in hrv_files]
    log.debug(hrv_files)        
    dataset = (
        xr.open_mfdataset(
            hrv_files,

Having looked up the libraries the exception is thrown in, it looks like the exception occurs in an AWS/S3 interface library, which looking at the code I presume is related to adding the prefix "zip:///::s3://" to the file path of hrv_files. Could anyone clarify what the problem might be, or if I'm lacking some setup in my development environment that might cause this?

I'm not that familiar with the use of AWS/S3, but I wasn't clear what the purpose of adding the prefix to the local path was, so if anyone can clarify the purpose of this that would be helpful too.

jacobbieker commented 8 months ago

Hi, it seems that you are not signed into an AWS account, and that code currently assumes that you are, so that it can save the final Zarr files to AWS S3 for later use. This is because the app.py has primarily been used for our production forecasting service running in AWS. You could either change the code, so that it doesn't append the s3://, after which it should save locally just fine, or sign into an AWS account for it to save to S3. By default, it tries to read the credentials stored in a file created by the aws cli utility after you log in.

peterdudfield commented 8 months ago

I think you have to use aws configure to make sure you are logged in

TomPughe commented 8 months ago

Thanks for the advice, I'll give that a try