Repository navigation
Use ftp w/ TLS for default IERS download (CDDIS) - #9964
Conversation
|
Hello @eteq 👋! It looks like you've made some changes in your pull request, so I've checked the code again for style. There are no PEP8 style issues with this pull request - thanks! 🎉 Comment last updated at 2020-04-24 19:43:21 UTC |
|
interesting, test are complaining that they should be |
| """ | ||
| kwargs.setdefault('http_headers', {'User-Agent': 'astropy/iers', | ||
| 'Accept': '*/*'}) | ||
| kwarg.setdefault('ftp_tls', True) |
There was a problem hiding this comment.
it worked for me locally
Wait a minute, how did the test even pass with this typo?
There was a problem hiding this comment.
The tests did fail! (At least remote_data) That's how I found out.
There was a problem hiding this comment.
ah, yes, now you mention it, I wondered about that too!
There was a problem hiding this comment.
Good question. I think it's because I tested an earlier version to prove it works and was in a hurry at the end so didn't run the later versions with --remote-data... 🐑 - I cooked up a hacky version first, tested that, but then didn't with the cleaned-up version.
|
Certainly for a temporary work-around this looks fine. It is strange that CDDIS doesn't provide anonymous download via https. |
pllim
left a comment
There was a problem hiding this comment.
Yeah, does seem hacky and I don't know how I feel about download_data having more and more options. But like you pointed out, we do not have a lot of choices here other than creating our own mirror.
| http_headers = {} | ||
|
|
||
| if ftp_tls: | ||
| urlopener = urllib.request.build_opener(_FTPTLSHandler()) |
There was a problem hiding this comment.
Should there be a check to raise exception if this option is given but URL is not FTP?
There was a problem hiding this comment.
I don't think so. This is pretty deep into some hacky layers of urllib, but based on https://docs.python.org/3/library/urllib.request.html#urllib.request.build_opener it looks to me like this just replaces the default FTP handler with the new one. So if the user passes in a non-ftp url a different handler takes care of it and this one is just skipped.
|
I think this needs a change log too. |
|
Added changelog and typo fix. There's still one remaining error (see, I did run the tests this time!) which I'll have to debug later. Re: @mhvk's:
Yeah I thought so too. It's possible there's some undocumented way but I figured it was safer to use what they support on their web site instead... |
pllim
left a comment
There was a problem hiding this comment.
I think you code broke the monkeypatching in test_data.py.
| astropy.utils | ||
| ^^^^^^^^^^^^^ | ||
|
|
||
| - ``astropy.utils.data.download_file` now supports FTPS/FTP over TLS. (#9964) |
There was a problem hiding this comment.
Why is there a new feature entry? Also parenthesis should be square brackets.
There was a problem hiding this comment.
New feature entry because this really is a new feature of allowing FTPS for any use of download_file. And that's actually kinda a big deal. It's just we're forced to do that to enable the bug fix, otherwise I would have had this be 4.1.
(parenths was a typo - fixed in the rebased version)
There was a problem hiding this comment.
Do we have a precedence to add "new feature" in a bug fix change log? I'll let @bsipocz decide.
There was a problem hiding this comment.
I think it's fine. It's not an API change, but non user oriented utils feature that helps to resolve a bug.
We occasionally had utils new features in bugfix releases in the past, e.g. for the decorators. E.g. 2.0.12 or 1.3.1.
f15fa79 to
1a8036b
Compare
| astropy.utils | ||
| ^^^^^^^^^^^^^ | ||
|
|
||
| - The default IERS server has been updated to use the FTPS server hosted by |
There was a problem hiding this comment.
this has to come down to the 4.0.1 section, too
|
test failures are related |
|
@eteq , do you have plans to wrap this up and address the monkeypatching failure? |
1a8036b to
6bb2086
Compare
0de9fce to
989d3ef
Compare
pllim
left a comment
There was a problem hiding this comment.
Just a minor typo left on change log, otherwise LGTM. Thanks!
Co-Authored-By: P. L. Lim <[email protected]>
|
Added the changelog changes so this doesn't queue twice in CI |
|
Thanks @eteq! |
Use ftp w/ TLS for default IERS download (CDDIS)
Use ftp w/ TLS for default IERS download (CDDIS)
|
|
||
| req = urllib.request.Request(source_url, headers=http_headers) | ||
| with urllib.request.urlopen(req, timeout=timeout) as remote: | ||
| with urlopener.open(req, timeout=timeout) as remote: |
|
#10437 now defaults to "if no-TLS fails retry with TLS"; I think special handling of IERS URLs could go away. |
This is an attempt to address #9963. It is quite a bit hackier that I would like, but I don't really see an obvious way to do any better without circumventing the caching machinery. I'm also very curious to see if the tests pass - it worked for me locally, but some of these remote tests behave quite differently on the CI...
One subtle side-effect of this implementation is that any ftp IERS URLs now use TLS with no way to turn it off. There are some ways I can imagine to avoid that if we think it is important (e.g. use "ftps" instead of "ftp" to indicate the tls version), but I'm not really sure how/if it's important at all.