Expand --remote-data to allow different modes#5506
Conversation
4ae7a83 to
79e29bd
Compare
|
I think Otherwise: no objections. But I haven't looked to closely on the code. |
Ok, that would be fine by me, as long as we can set |
|
So the failure seems to happen because data.astropy.org gets translated into an IP address at some point, so we need to also find a way to whitelist the current IP address of data.astropy.org. |
| if allow_astropy_data: | ||
| data_astropy_org_ip = socket.gethostbyname('data.astropy.org') | ||
| valid_hosts += ('data.astropy.org', 'astropy.stsci.edu', data_astropy_org_ip) | ||
| for valid_host in ('data.astropy.org', 'astropy.stsci.edu'): |
There was a problem hiding this comment.
Huh. I am not aware that we have astropy.stsci.edu. Is this a planned addition for 1.3?
There was a problem hiding this comment.
data.astropy.org is astropy.stsci.edu :)
There was a problem hiding this comment.
Hmm. Could you please email me the details? Thanks!
astropy/tests/command.py
Outdated
| before distutils/setuptools try to parse the command-line options. | ||
| """ | ||
| def __init__(cls, name, bases, dct): | ||
| for i in range(len(sys.argv)): |
There was a problem hiding this comment.
The range(len(...)) is something of a do-not in my opinion, I think a more elegant way would be:
try:
idx = sys.argv.index('--remote-data')
except ValueError:
pass
else:
sys.argv[idx] = '--remote-data=any'
but it just does exactly the same, so keep whichever you like more.
astropy/tests/runner.py
Outdated
| run these tests. | ||
| remote_data : {'none', 'astropy', 'any'}, optional | ||
| Controls whether to run tests marked with @remote_data. This can be | ||
| set to run no tests with remote data (``no``), only ones that use |
astropy/tests/pytest_plugins.py
Outdated
| parser.addoption("--remote-data", action="store_true", | ||
|
|
||
| # The following means that if --remote-data is not specified, the default | ||
| # is 'astropy', but if it is specified without arguments, it defaults to |
There was a problem hiding this comment.
I thought the default is none.
There was a problem hiding this comment.
Ah but if you do --remote-data on its own, it does the old behavior and defaults to any
There was a problem hiding this comment.
I meant the first sentence: The following means that if --remote-data is not specified, the default is 'astropy'.
astropy/tests/pytest_plugins.py
Outdated
| raise ValueError("source should be 'astropy' or 'any'") | ||
|
|
||
| if remote_data_config == 'none': | ||
| if source in ('astropy', 'any'): |
There was a problem hiding this comment.
This is always true because you already raised an exception if source not in ('astropy', 'any').
284308a to
0e227d4
Compare
…odes. The --remote-data flag takes three possible options: 'none', 'astropy' (for data from data.astropy.org) and 'any'. If --remote-data is not specified, it defaults to 'astropy', and if it is specified without a mode, it defaults to 'any'
0e227d4 to
abe39c4
Compare
| assert True | ||
| if pytestconfig.getoption('remote_data') == 'none': | ||
| pytest.fail('@remote_data was not skipped with remote_data=none') | ||
| else: |
There was a problem hiding this comment.
This else clause is superfluous, no? The same package data gets downloaded on line 42.
|
Had a look only now, but this looks very good. One nitpicky comment only. |
|
One more comment: I think this would warrant a changelog entry. |
|
@mhvk - I've added a changelog entry |
|
OK, great. I'm happy for this to be merged once the tests have passed. |
|
This is in principal 👍 from me, and I didn't see any issues in a quick review. But one thing I'm concerned about: how does this affect affiliated packages that may be using the |
|
Answered my own question: if I add the following to an affiliated package's with the current master, this correctly causes the default But with this PR, I can get it all working again by doing So the fix is pretty easy. Moreover, I think this PR is an improvement on this behavior, because before there was no way to override the The question is: do we accept this subtle backwards incompatibility? I know I've talked to some people about using |
…data = 1 in setup.cfg, but emit a deprecation warning to get them to change it.
|
@eteq - I think it should now be fixed to be backward-compatible, with a deprecation warning. |
|
Looks great. The one remaining test is delayed (for an unclear amount of time) due to a travis OS X problem. Hard to see how that could be an issue here, so will merge to let #5496 get its test updated APAP. |
|
I stopped the OSX build to free some workers for the other PRs. |
|
@astrofrog - I'm fairly certain that this PR broke the coverage reporting (see #5701). The PR merged just before this still gets the report on coveralls, while this one looks perfectly normal on travis, doesn't trigger a report on coveralls. Any ideas? |
|
@bsipocz - good catch! The issue is that the following comparison now fails: We should just check for the presence of Sorry for breaking things! :-/ |
(This came out of a discussion in #5496)
This was a bit of work to get right, but with this pull request, it is now possible to optionally decorate remote tests using:
@remote_data(source='astropy')Such tests are run by default but will fail if the test tries to access non-astropy data (i.e. data not on data.astropy.org). The
--remote-dataoption can now take three values:The first skips all tests with
@remote_data, the second (which is the default) skips remote tests that don't specifysource='astropy'(or specifysource='any'explicitly), and the third runs all remote tests.Note that this also preserves backward-compatibility with the plain option:
which is translated to
--remote-data=any.So this is backward-compatible and now allows tests such as those for WCSAxes to run on Travis without enabling ALL the remote tests. Since the data.astropy.org server is pretty stable (unlike e.g. VO services), I don't think this should cause any issues.
Note that this can be expanded in future to allow more modes now that it is a string option!
cc @mhvk @eteq @bsipocz @pllim @MSeifert04 @keflavich @Cadair