Repository navigation
TST: Minimize calls to remote sites.json for testing - #10304
Conversation
|
I'm 👎 for expanding |
This comment has been minimized.
This comment has been minimized.
|
|
||
| >>> from astropy.coordinates import EarthLocation, SkyCoord | ||
| >>> loc = EarthLocation.of_site('Royal Observatory Greenwich', force_builtin=True) | ||
| >>> keck = EarthLocation.of_site('Keck', force_builtin=True) |
There was a problem hiding this comment.
instead of relying on of_site() here, you could use it's coordinates hard wired (or append the local sites.json on the fly if Keck is missing from it during doctest)
There was a problem hiding this comment.
Oh yeah, I guess hardcoding lon/lat at testsetup would be even better.
Hmmm! This means maybe I don't need to expose force_builtin after all...
There was a problem hiding this comment.
yes, I think if that's an acceptable hack we can avoid both force_builtin and the extension of the files. It's a bit of a cheat as the users will see different code than what's tested, but I suppose this one instance it's forgivable.
mhvk
left a comment
There was a problem hiding this comment.
I like the use of test setup, but am not that keen on the added keyword argument and wonder whether cannot be cleverer still. Inline a suggestion for the sites (untested...).
For the sky coordinates, since caching was just implemented for them, would it be possible to check the URL that gets created by name_resolve.get_icrs_coordinates and simply insert that in the cache as part of the test setup? The advantage is that there will not be any need for doctest skip (and the doctest is thus much closer to reality)
Actually, a related alternative would be to populate the site registry with 'Keck', etc., inside the test setup, so that you can leave the built-in file alone.
Anyway, not sure if it is worth the extra work - though getting rid of these remote_data tests is definitely nice!
| .. testsetup:: | ||
|
|
||
| >>> from astropy.coordinates import EarthLocation, SkyCoord | ||
| >>> loc = EarthLocation.of_site('Royal Observatory Greenwich', force_builtin=True) |
There was a problem hiding this comment.
I like this idea of a test setup, but couldn't for the locations at least it be done simpler with:
from astropy.coordinates import EarthLocation
EarthLocation._get_site_registry(force_builtin=True)
There was a problem hiding this comment.
Re: caching -- I don't think #9162 affects of_site?
There was a problem hiding this comment.
EarthLocation._get_site_registry(force_builtin=True) is problematic because I need to use force_download to undo it, which defeats the purpose of not hitting data server.
There was a problem hiding this comment.
I think in the other thread you're converging on hard-coding, which would be OK, though how about even more cheekily setting EarthLocation._site_registry = None at the end of tests? Probably overkill...
p.s. Yes, caching is only for SkyCoord. But only useful if the sites works too. My sense: go with @bsipocz suggestion and have an issue about perhaps prepopulating the cache instead.
There was a problem hiding this comment.
I don't know how to pre-populate cache on CI. I was under the impression that we need to store the tarball of the cache somewhere and then have the CI pull it but I have no idea how to set up the tarball in the first place.
Yes, I am in the works to hardcode stuff. Will push a commit soon.
|
So it seems like I shouldn't been exposing |
| >>> target.radial_velocity_correction(obstime=obstime, location=keck).to('km/s') # doctest: +REMOTE_DATA +FLOAT_CMP | ||
| >>> target = SkyCoord.from_name('M31') # doctest: +SKIP | ||
| >>> keck = EarthLocation.of_site('Keck') # doctest: +SKIP | ||
| >>> target.radial_velocity_correction(obstime=obstime, location=keck).to('km/s') # doctest: +FLOAT_CMP +REMOTE_DATA |
There was a problem hiding this comment.
If we can figure out the IERS stuff, we can remove +REMOTE_DATA here too but that is a battle for another day.
| ... observer=alma, target=ttau) # doctest: +IGNORE_WARNINGS +REMOTE_DATA | ||
| >>> sc_ttau # doctest: +REMOTE_DATA +FLOAT_CMP | ||
| ... observer=alma, target=ttau) # doctest: +IGNORE_WARNINGS | ||
| >>> sc_ttau # doctest: +FLOAT_CMP +REMOTE_DATA |
There was a problem hiding this comment.
Like the other example above, +REMOTE_DATA here is due to IERS leap seconds table, not of_site anymore.
There was a problem hiding this comment.
I wonder if we cannot set tests to execute with an offline or auto_download=False config - really, the bundled IERS is good enough for these tests so it should not download anything. But obviously Time cannot know this... Anyway, separate issue!
|
Now, that this is rescoped to test refactoring only, I think it can even go back to 4.0.2. What do you think? |
|
@bsipocz , I moved the milestone to 4.1.1 because half the stuff I touched here were added for 4.1. |
This comment has been minimized.
This comment has been minimized.
Satellites example need remote data after all.
|
Weird, the The |
StuartLittlefair
left a comment
There was a problem hiding this comment.
Looks good to me; a very tedious job of going through and coding everything by hand so thanks!
| tree = dict(location=rog) | ||
| assert_roundtrip_tree(tree, tmpdir) | ||
| finally: | ||
| EarthLocation._site_registry = orig_sites |
There was a problem hiding this comment.
Maybe we should just make this a context manager as it seems like a useful thing to have?
There was a problem hiding this comment.
Possibly just as a setup_class, teardown_class, though for now this would seem good enough.
There was a problem hiding this comment.
I briefly thought about turning it into a test class but decided that the line count would blow up and maybe not worth it. 🤷
I thought I opened an issue a long time ago to request changes to API allowing user to specify their own local sites.json but I cannot find that anymore. I think changing the API to context manager is out of scope here.
mhvk
left a comment
There was a problem hiding this comment.
I'd be quite happy to get this in - only two small comments that may be good to address.
| tree = dict(location=rog) | ||
| assert_roundtrip_tree(tree, tmpdir) | ||
| finally: | ||
| EarthLocation._site_registry = orig_sites |
There was a problem hiding this comment.
Possibly just as a setup_class, teardown_class, though for now this would seem good enough.
| ... observer=alma, target=ttau) # doctest: +IGNORE_WARNINGS +REMOTE_DATA | ||
| >>> sc_ttau # doctest: +REMOTE_DATA +FLOAT_CMP | ||
| ... observer=alma, target=ttau) # doctest: +IGNORE_WARNINGS | ||
| >>> sc_ttau # doctest: +FLOAT_CMP +REMOTE_DATA |
There was a problem hiding this comment.
I wonder if we cannot set tests to execute with an offline or auto_download=False config - really, the bundled IERS is good enough for these tests so it should not download anything. But obviously Time cannot know this... Anyway, separate issue!
|
@pllim - if it would help clarify the other PRs, go ahead and merge, I think this is a good solution for now! |
|
Hmm, I'll leave the merging to others. I try not to merge my own PR unless it is trivial. 😬 |
TST: Minimize calls to remote sites.json for testing
Description
This pull request is to
exposeminimize calls toforce_builtinoption inEarthLocationwhen looking upsites.jsontosites.jsonthat resides on the remote data server.The portion of the tests that require IERS leap seconds table download still are marked as remote data.
Fixes #10298
Address part of #10255(Nope, removing call toof_sitedid not change anything for this one.)TODO
Add change log when new section is available.