IMAP-Science-Operations-Center / imap-data-access

Package to download, query, and upload files from the IMAP Science Data Center.
MIT License
0 stars 7 forks source link

BUG - Not accessing IMAP_DATA_DIR env var #15

Closed maxinelasp closed 4 months ago

maxinelasp commented 4 months ago

Description of the issue

When importing as a library, the code does not correctly read the data directory from the IMAP_DATA_DIR environment variable

Steps to reproduce the issue

    1. 3.
  1. Clone imap_processing dev commit a29978f3a31d5f1ff10f256245e5eb4ab20a8b37

  2. Run the CLI with: python -m cli --instrument swe --level l1a --file_path imap/swe/l1a/2024/02/imap_swe_l1a_sci_20240203_20240203_v01-01.cdf --dependency "[{'instrument':'swe', 'level':'l0', 'version':'v01-01'}]"

  3. See that it fails

  4. update IMAP_DATA_DIR value to the expected directory (mine was /Users/maha7656/Documents/code/imap/imap_processing/imap_processing/imap-data)

  5. see that it still fails

Code Snippet:

Code

Expected behavior (What should happen)

Should read the data directory value from IMAP_DATA_DIR when it's set

Actual behavior (What does happen)

Defaults to $PWD/data as data directory

Additional notes

Reproducing this might need tweaking depending on data in the bucket

Affected areas (code, data, or process)

No response

Suggested fix?

Read config value differently

maxinelasp commented 4 months ago

I get the same error when trying to update IMAP_DATA_DIR using the CLI

greglucas commented 4 months ago

Good catch! I think that is because we hadn't fully brought the IMAP_DATA_DIR portion of the code from imap_processing over here: https://github.com/IMAP-Science-Operations-Center/imap_processing/blob/a29978f3a31d5f1ff10f256245e5eb4ab20a8b37/imap_processing/__init__.py#L22

Now that we've switched over to having this be more of a central repo that the other projects are going to depend on I think it makes sense to lift that over and the tests as well: https://github.com/IMAP-Science-Operations-Center/imap_processing/blob/a29978f3a31d5f1ff10f256245e5eb4ab20a8b37/imap_processing/tests/test_data_access.py#L27

maxinelasp commented 4 months ago

That's a good catch. I bet that is the source of the issue.