-
-
Notifications
You must be signed in to change notification settings - Fork 401
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
Fixed failing test in HEASARC module, adding local test data #2250
Conversation
Codecov Report
@@ Coverage Diff @@
## main #2250 +/- ##
==========================================
+ Coverage 62.95% 63.41% +0.45%
==========================================
Files 131 131
Lines 17038 17043 +5
==========================================
+ Hits 10727 10808 +81
+ Misses 6311 6235 -76
📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more |
Yes, I think copying over all the remote tests to a non-remote variant would be helpful - it would be great if you could do that! The other thing we'd like to do is have remote tests that test that we get the right results but are robust against upstream changes. So in this case, we might test that the number of results is |
It just seems like almost complete code repetition.
Yeah, something like that, unfortunately. I could narrow-down the query a bit, but it's still not guaranteed, basically no way to be certain, unless the service promises this sort of consistency.
|
True, there would be some code repetition, but there is real value in storing the output data needed for the tests locally, and that's more than a simple copy-paste. It would really be great if we could set up an automated system to do that (write only remote tests, but cache the results and run the tests locally), but I fear such a system, while elegant, would have too many failure corner cases to be worth the effort. |
Hello @volodymyrss! 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-25 07:13:36 UTC |
0e470a9
to
27ad069
Compare
As I understood it, it's still a complete repetition of the entire test code. I am be wrong. So I made an attempt to keep the options for harvesting data, running tests remotely and locally by parallelization (i.e. keeping single test source, no repetition).
Hopefully the implementation is not too convoluted, actually it's hardly more than the advised Please let me know what you think! I was just curious to make an attempt, I do not really suggest it's completely generic, and I hope it's sufficiently noninvasive. Meanwhile, while applying this, the CI tests for this module started to run for the first time, and fail... I will get to that. |
60d2217
to
27ad069
Compare
This is brilliant - thanks! Yes, I think if you can make this work (looks like you have, but I haven't reviewed carefully yet), this is the best solution! Could you make the 'parametrization' code general and move it into the |
Good to hear!
I think I rather prefer the second option: that way I test everything carefully on one case, while also fixing the case, and them move it in another PR. |
Ok, I am done with tests, though I am not sure the approach is the best possible. Concerning the parametrization, after this is done we can discuss more in another PR? For example, maybe it's strange that the A minor challenge I found here, is that sometimes, with different dependencies, for the same test the request was slightly different (some rounding/converting assumptions), even if the response is the same.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I get an error for a missing file, and there are a few fixable issues (and some nitpick comments). Overall looks great, thanks!
E FileNotFoundError: [Errno 2] No such file or directory: '/private/var/folders/dc/hsm7tqpx2d57n7vb3k1l81xw0000gq/T/astroquery-test-sqy_voa0/lib/python3.9/site-packages/astroquery/heasarc/tests/data/8fe6c881.dat'
), | ||
], | ||
), | ||
], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My pet peeve nitpick, but it would be nice not to use black to avoid things like this, basically, all 10 lines could be condensed into ~3-4 and that would even improve readability.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I personally find the black's version here quite readable, for such a nested structure.
Of course no problem to adjust as you wish!
But I struggle to put it in 3-4 short and readable lines. I made it to 10.
Could you please make a suggestion?
return data_path(fileid, output=output) | ||
|
||
|
||
# TODO: are get_mockreturn args up-to-date in example in https://astroquery.readthedocs.io/en/latest/testing.html ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
possibly the docs in that link is outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should I make a separate issuePR and delete this comment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, and let's correct the get_mockreturn
documentation at that URL at the same time (https://github.com/astropy/astroquery/blob/main/docs/testing.rst)
astroquery/heasarc/core.py
Outdated
@@ -15,6 +16,14 @@ | |||
__all__ = ['Heasarc', 'HeasarcClass'] | |||
|
|||
|
|||
def Table_read(*args, **kwargs): | |||
# why does if commons.ASTROPY_LT_5_0 not work on Windows? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That should work, I can't recall running into issues with it for previous PRs. Though for unit_parse_strict
I think it should be LT_5_1 as it's a new feature for the upcoming version rather than the already released 5.0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So if needed, do add an ASTROPY_LT_5_1
and use that for if/else rather than the try/except.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, sorry, I had a problem with some recent minversion
elsewhere, so I misinterpreted this.
So you suggest I add ASTROPY_LT_5_1
in utils
? It will not be satisfied before 5.1 release, right? Is it ok that the devastropy
test will fail?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed as suggested and it does fail astropy dev, as expected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I think we better hack it around temporarily until the 5.1 release is out.
As I see this is the only remaining issue, and that there are a few merge commits, so I go ahead, rebase the PR and a commit that address this variable and we're good to go. Ultimately we better fix the unit parsings as the issue came up recently in #2333, too
README.rst
Outdated
@@ -1,196 +0,0 @@ | |||
`Documentation`_ | Blog_ | `View on Github`_ | `Download Stable ZIP`_ | `Download Stable TAR`_ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pls do not remove this file. If possible stash the add back commit into the one that removed it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, file restored. I already squashed. I will squash at the and too, right? Then an extra commit now does not matter.
@volodymyrss - to reflect to your question about local vs remote tests. Yes, currently we only fail builds on non-remote test failures. But we run the remote tests from cron (weekly) cron and also manually. E.g here is a list of modules with failing remotes #2203, as you see we fixed the wast majority already, but unfortunately for |
Good to know! But only with one python, one platform, right? For me, it would be very useful for me to know if at So I suppose it's still quite useful to add all possible responses for multi-platform multi-version mock tests? So what do you think about adding this parametrization to utils? I could propose a change for some other ones for which I care. In part some of those from #2203.
Thanks for the information! I am not from HEASARC, so I can not be fully responsible for this. |
Should there be a changelog entry for heasarc? It's only tests - no functionality is added or changed. As suggested by @bsipocz, I added |
OK, so I've rebased this PR to remove the merge commits as well as to squash all the commits into one that add and remove and otherwise manipulate the added datasets to avoid unnecessary size up of the git repository. However, I'm unable to push back to the branch of the PR as it was opened from under an org (maintainers get write access to branches of the PRs if a tickbox is checked at the time of opening a PR, however as far as I know, it only works for the cases when the PR is opened for forks under personal accounts rather than from under orgs.) @volodymyrss - there are two ways to work around, please let me know which one you prefer:
|
ee7932c
to
d421fcb
Compare
@bsipocz perfect, thank you! I force-pushed the branch, and also gave you access to oda-hub/astroquery. |
Thanks @volodymyrss! |
@volodymyrss - could you have a look at these failing CI builds? e.g. https://github.com/astropy/astroquery/runs/5726304297?check_suite_focus=true It all was passing before merging this, but I suspect there maybe a bug with the hashing part as now a few tests are failing with missing files, all the while they are fine for most of the version combinations, as well as I'm unable to reproduce the failure locally. |
The problem is that the requests are actually different. The difference is in the rounding of floats when degrees are converted from astropy SkyCoord degrees. It might have some effect on actual response too. So perhaps it's good it's caught. This should help: It's tricky to reproduce, and also not obvious from the error. |
The test fails with astropy==5.0. Which indicates correctly that most of the module functionality breaks.
There is some complexity in astropy with version check in 5.0, but I noticed everything works fine with the latest astropy
main
branch.Meanwhile, and nevertheless, might be good to just always specify the unit, this will work with all relevant astropy versions.
I also update test according to some server-side change.
I wonder how to prevent this sort of problem from emerging at some point.
It would be good to have non-remote tests I guess. Only non-remotes ones are likely to continue passing?
I could just copy the entire
astroquery/heasarc/tests/test_heasarc_remote_isdc.py
toastroquery/heasarc/tests/test_heasarc_remote_isdc.py
and add monkeypatches according to the doc, is this the recommended way?