-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Remove unnecessary remote_data in (mostly) coordinates. #10474
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
Remove unnecessary remote_data in (mostly) coordinates. #10474
Conversation
|
Hmm, the double test fails too, so there must be another place where the configuration gets changed... And still the mysterious error from the docs... |
|
Docs error is unrelated but the double one definitely is. Turns out the "double run" command is very different from the rest: I don't know why yet, but I have a feeling that it is not completely equivalent to running |
|
@pllim - indeed, that may be a hack to get things to pass, but, really, |
Here, it should not assume that the configuration is all stored in a file, but include any configuration done programmatically. This is particularly useful to keep utils.iers.conf.auto_download to any setting done in conftest.py.
0cd11ce to
bb1368e
Compare
|
OK, I think it was a combination of |
|
Hmm... Looks like some of the tests might be relying on the old behavior... The diff makes no sense at a glance. |
|
And then I clearly didn't bother to check the normal testing still worked! |
|
Actually, very weird. I cannot reproduce the travis failures. What has |
|
So, that was funny: it turned out I couldn't reproduce the travis failures because locally I have a normal, all-default astropy config file. When I replaced that with the temporary one created in |
| # Check CC variable | ||
| - echo "CC="$CC | ||
|
|
||
| # Write configuration items to standard location to make sure they are |
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'm not completely sure why, but with the other changes that ensure the configuration never needs to be reloaded, this writing of a configuration file now causes failures, so I 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.
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.
What about... Instead of removing this, we add a line to the astropy.cfg here to set auto_download = False?
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 wondered about it, but it seemed to me that your solution of a change in astropy/conftest.cfg was really more elegant, and works for everybody.
Do you think we still need this at all? It doesn't seem to give failures, and it is hard to see how we can mess up the configuration on travis.
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.
Oh, I didn't realize I made it unnecessary. I'll have to remember what I did and get back to you.
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 am curious... You said this command made the tests fail in Travis CI. However, the same command was also added in #8727 to CircleCI and that didn't affect your PR. How could that be? 🤔
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'm totally confused! But with this still in place (one but last commit), both Initial tests on travis failed (see https://travis-ci.org/github/astropy/astropy/builds/696611940). I'm actually not quite sure why they failed, but trying to determine why the tests passed locally I realized that the only difference was the config file (and locally tests also fail if I use the now-removed lines as config).
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.
Given that it still exists in CircleCI for "32 bit and parallel" tests and things pass there, probably okay to remove here. If @astrofrog disagrees when he is available again, we can always do a follow-up PR.
| from .configuration import _cfgobjs | ||
|
|
||
| path = super().__enter__() | ||
| self._cfgobjs_copy = _cfgobjs.copy() |
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.
The changes here are to keep the configuration instead of deleting it at the end so that it gets reloaded from the configuration file. This is because some config items can have been set programmatically (in particular, utils.iers.conf.auto_download)
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.
Is the "reset all the cached config objects" comment on L243 above still accurate? If not, should remove/modify it.
And this is a subtle API change for set_temp_config, right? I wonder if it warrants a change log.
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, I guess you are right. I now updated the comment and added a changelog entry.
| OLD_CONFIG = {} | ||
|
|
||
|
|
||
| def setup_module(): |
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.
Arguably, all the test in this file should be written such that they do not change the configuration, but this was easier...
|
|
||
| assert not os.path.exists(temp_config_dir) | ||
| # Check that we have returned to our old configuration. | ||
| assert configuration._cfgobjs == OLD_CONFIG |
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.
This verifies that set_temp_config does not destroy the old configuration.
|
I added some comments to make review easier. Beyond the first few files, everything is just removal of |
pllim
left a 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, I agree we you that we might not need to write out the astropy.cfg anymore in CI. Let's just leave it as you implemented and we're early in the dev cycle for 4.2 anyway, so hopefully anything we overlooked would be flushed out before its release.
Hmm, I have no idea why these failed in the remote data job. Are they related?
FAILED ../../.tox/py37-test-devdeps/lib/python3.7/site-packages/astropy/coordinates/tests/test_intermediate_transformations.py::test_earth_orientation_table
FAILED ../../.tox/py37-test-devdeps/lib/python3.7/site-packages/astropy/time/tests/test_basic.py::test_scale_conversion
|
|
||
| def setup_module(): | ||
| OLD_CONFIG.clear() | ||
| OLD_CONFIG.update(configuration._cfgobjs) |
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.
The need to call "hidden" stuff might indicate that we should expose the API properly? But that is discussion for another day.
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, or one should have a context manager option that ensures the configuration gets returned in its original state. But I'd indeed like to keep that for another PR.
| # Check CC variable | ||
| - echo "CC="$CC | ||
|
|
||
| # Write configuration items to standard location to make sure they are |
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 am curious... You said this command made the tests fail in Travis CI. However, the same command was also added in #8727 to CircleCI and that didn't affect your PR. How could that be? 🤔
|
@pllim - thanks for noticing the remote data failures - they are indeed related, since those two specifically test that an up-to-date IERS file is used. They have |
astropy/time/tests/test_basic.py
Outdated
| def test_scale_conversion(): | ||
| def test_scale_conversion(monkeypatch): | ||
| monkeypatch.setattr('astropy.utils.iers.conf.auto_download', True) | ||
| with iers.earth_orientation_table.set(iers.IERS_B.open()): |
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.
Note: I was very surprised about the single line in the test as written so rewrite to make it similar to the original purpose of this test (which was removed because it seemed tricky to do; indeed, resulting in a discussion that was not actually resolved... https://github.com/astropy/astropy/pull/6606/files#r140902373).
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.
Hmm, that new test for exception with bundled table doesn't need to be marked as remote data, right? Can it be in its own function? Or does it still somehow needs internet?
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.
Looking at this again, there really is no point in testing the exception, so I removed it again. Instead, I now added a comment so it is clearer why the test exists.
|
@pllim - you may want to look just at the last commit, which will hopefully fix the remote-data failures (though I fear some numpy-dev stuff may be coming...). |
| Use the here and now to be sure we get a difference. | ||
| """ | ||
| monkeypatch.setattr('astropy.utils.iers.conf.auto_download', True) |
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.
Usually not a fan of monkeypatching but it does seem less clunky than the try ... finally ... implementation I did in #10311, so 👍
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.
There is also with iers.iers.Conf.auto_download.set_temp(True) but I felt this was a bit more natural. I actually rather liked your setup_class and teardown_class, but it seemed too much effort for a single function.
|
Darn, getting that thing that even using |
21a0586 to
09acba0
Compare
|
OK, by removing the Anyway, should now be ready! |
pllim
left a 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.
A few minor comments. I'll approve after they are resolved. We're really close. Thank you!
| # Check CC variable | ||
| - echo "CC="$CC | ||
|
|
||
| # Write configuration items to standard location to make sure they are |
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.
Given that it still exists in CircleCI for "32 bit and parallel" tests and things pass there, probably okay to remove here. If @astrofrog disagrees when he is available again, we can always do a follow-up PR.
| from .configuration import _cfgobjs | ||
|
|
||
| path = super().__enter__() | ||
| self._cfgobjs_copy = _cfgobjs.copy() |
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.
Is the "reset all the cached config objects" comment on L243 above still accurate? If not, should remove/modify it.
And this is a subtle API change for set_temp_config, right? I wonder if it warrants a change log.
|
|
||
| with iers.earth_orientation_table.set(iers.IERS_B.open()): | ||
| with catch_warnings() as w: | ||
| with pytest.warns(AstropyWarning, match='after IERS data'): |
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 must be going crazy. Pretty sure I needed some .* in the regex when I worked on it, but tests passed here without. 🤷
| with catch_warnings() as w: | ||
| with pytest.warns(AstropyWarning, match='after IERS data'): | ||
| altaz_b = sc.transform_to(altaz) | ||
| assert len(w) == 1 |
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 you don't want to check to see if this is the only warning emitted anymore?
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 think it is fine to just test that we get the right warning. If there are others, pytest would presumably 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.
Not really. Consider this example:
import warnings
import pytest
def myfunc():
warnings.warn('Catch this', UserWarning)
warnings.warn('Nope', UserWarning) # Even if you change the warning type, same result below
def test1():
with pytest.warns(UserWarning, match='Catch this'):
myfunc() # passes
def test2():
with pytest.warns(UserWarning, match='Catch this') as w:
myfunc()
assert len(w) == 1 # failsThere 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.
It comes down to whether you care if the functionality emits other warnings you are not checking for or not.
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 think in this case we check the code enough in other places that I don't worry, but clearly that is not the behaviour I had expected....
Both in a comment and in the changelog.
pllim
left a 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.
Definitely an improvement to be able to run more tests without remote data. Thank you!
|
Yes, this was a nice collaboration on getting rid of the need for remote data! |
In #10311, @pllim made the tests run by default using no download for IERS. This means that a lot of tests can now be run (again) without
remote_data. It turned out, though, that the tests ofastropy.configmessed up the configuration setting. This PR fixes that, and removes the now no longer neededremote_data(I hope I didn't miss any... do we need a test thatremote_dataactually tries to access the internet???)Note that the first commit is a missed item in #10337, which I include here since without the work here, the fix would not get tested (which was why it passed by in the first place). As such: fixes #10471
EDIT: Close #10469