-
Notifications
You must be signed in to change notification settings - Fork 124
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
Simplify online check of data API client #627
Conversation
This fixes an issue where the online check would ignore proxy settings (whereas the regular downloading does not). * Use 'requests' for online check instead of 'socket'. * Make 'Client.online' a property method instead of a fixed propery.
Oh? Wasn't aware of that. How do the system wide proxy settings inhibit online query? The reason why And yes, no real unit tests. All the tests for the |
Ah, I missed that!
We do not have this use case often but I would rather have |
Sorry, I almost forgot this question 🙈 I noticed the issue on my MeteoSwiss machine, where I have to use their proxy. Downloading data actually works just fine but the online query of the data API client fails. This is because the |
I still think we should stick to the current behavior, exactly because a lot can happen to the internet. |
I do not agree 😬 If you are working offline, And in the other case where a connection was there when the Client was created and later is not (or vice versa), the new behavior is vastly more useful. |
Really? Not for me, it doesn't. Just checked again (went offline and did requests.head) and it took about 10 seconds. 🧐 |
Wow, even with the latest timout addition? 😳 |
Sadly yes, even with |
You are working on Windows, right? Maybe the behavior differs for each OS. I'll roll it back to the 'static' attribute! |
Wouldn't surprise me. |
Co-authored-by: Lukas Riedel <34276446+peanutfun@users.noreply.github.com>
I've just made a manual offline test and it failed: from climada.util.api_client import Client
client = Client()
client.get_dataset_info(name=ds_name, status='test_dataset') got this:
|
Sorry, I can't follow that. What do you mean by "manual offline test", where does the error occur, what is the complete traceback? |
I just went offline and ran the 3 lines.
|
Thanks! I guess we can simply wrap the request into a try-catch block and return false if we catch a |
Co-authored-by: Lukas Riedel <34276446+peanutfun@users.noreply.github.com>
it's even faster now 😍 |
This fixes an issue where the online check would ignore system-wide proxy settings. The issue is due to the
socket
interface ignoring system-wide proxy settings by default, whereasrequests
does consider them. So I propose to remove any use ofsocket
. This simplifies the online query a lot.Changes proposed in this PR:
requests
for online check instead ofsocket
.Client.online
a property method instead of a fixed property.Open questions:
PR Author Checklist
develop
)PR Reviewer Checklist