Skip to content
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

ALMA: add option to just validate data #2263

Merged
merged 7 commits into from
Mar 18, 2022

Conversation

keflavich
Copy link
Contributor

This is a minor improvement to allow going through the data download loop without downloading anything

@pep8speaks
Copy link

pep8speaks commented Jan 26, 2022

Hello @keflavich! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2022-03-18 21:36:23 UTC

@keflavich keflavich added the alma label Jan 26, 2022
astroquery/alma/core.py Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Jan 26, 2022

Codecov Report

Merging #2263 (438e3af) into main (d17805e) will decrease coverage by 0.04%.
The diff coverage is 22.22%.

@@            Coverage Diff             @@
##             main    #2263      +/-   ##
==========================================
- Coverage   62.98%   62.93%   -0.05%     
==========================================
  Files         131      131              
  Lines       17067    17084      +17     
==========================================
+ Hits        10749    10752       +3     
- Misses       6318     6332      +14     
Impacted Files Coverage Δ
astroquery/exceptions.py 0.00% <0.00%> (ø)
astroquery/alma/core.py 41.16% <25.00%> (-0.60%) ⬇️

📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more

@andamian andamian self-requested a review January 26, 2022 17:16
@bsipocz bsipocz added this to the v0.4.6 milestone Jan 26, 2022
Copy link
Member

@bsipocz bsipocz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would need a changelog, and preferably a one-liner mention in the docs, and a test. After that, good to go.

@bsipocz
Copy link
Member

bsipocz commented Feb 25, 2022

@keflavich - this is close to being ready once you add a changelog, docs and preferably a test.

@bsipocz
Copy link
Member

bsipocz commented Mar 18, 2022

@keflavich - I would include this in the release tomorrow if you could add the missing tests and changelog, otherwise will remilestone.

@keflavich
Copy link
Contributor Author

Last sticking point: I raise this warning:

warnings.warn(f"Found cached file {filename} with size {existing_file_length} > expected "
              f"size {length}.  The download is likely corrupted.")

And in the test, I try to test for it:

    caplog.clear()
    with warnings.catch_warnings(record=True) as ww:
        result = alma.download_files(['https://almascience.nao.ac.jp/dataPortal/member.uid___A001_X1284_X1353.qa2_report.html'], verify_only=True)
        assert result
        length = 66336
        existing_file_length = length + 10
        assert f"Found cached file {local_filepath} with size {existing_file_length} > expected size {length}.  The download is likely corrupted." in str(ww)

but it doesn't work:

FAILED astroquery/alma/tests/test_alma_remote.py::test_verify_html_file - AssertionError: assert 'Found cached file /home/adam/.astropy/cache/astroquery/Alma/member.uid___A001_X1284_X1353.qa2_report.html with size 66346 > expected size 66336.  The download is likely corrupted.'...

Adding a print statement gets me:

>>>print(f"WARNING: {str(ww)}")
WARNING: []

Am I doing the catching wrong?

@eerovaher
Copy link
Member

Testing that the code raises warnings is best done with the pytest.warns() function, see https://docs.pytest.org/en/stable/how-to/capture-warnings.html#warns

@keflavich
Copy link
Contributor Author

Thanks @eerovaher, that got it.

I added a new Warning class, which I think is useful - even though it's only presently used here, it could be used generally.

Copy link
Member

@bsipocz bsipocz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One minor comment, otherwise it looks good to go.

astroquery/alma/core.py Outdated Show resolved Hide resolved
@bsipocz
Copy link
Member

bsipocz commented Mar 18, 2022

Thanks.

I've also noticed that a few tests are skipped as they are known to fail. I'll come back to those and check how long they take to run, and if it's not super long, I would switch the skip to xfail following the logic in #2326.

@bsipocz bsipocz merged commit 97f6f30 into astropy:main Mar 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants