Skip to content
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

Add timeout option to Client #463

Merged
merged 10 commits into from
Apr 25, 2023
Merged

Conversation

jpolchlo
Copy link
Contributor

@jpolchlo jpolchlo commented Mar 28, 2023

Related Issue(s):
Closes #127

Description:
In order to set an explicit timeout for some requests, this PR adds a timeout parameter to Client.open. This is still a work in progress, but I've been able to add a functioning timeout parameter; the remaining work includes proper test coverage (at the moment, it's not clear how to catch the error raised by this feature) and an additional pass over the API to see other places where this feature would need to be added.

PR Checklist:

  • Code is formatted
  • Tests pass
  • Changes are added to the CHANGELOG

tests/test_client.py Outdated Show resolved Hide resolved
Copy link
Member

@gadomski gadomski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The timeout type signature is complicated enough that it's probably worth defining a type alias, a la https://github.com/python/typeshed/blob/47ce3cb8dbf564130701b2344c24ff248675f6a2/stubs/requests/requests/sessions.pyi#L106. It should be a "public" type alias, unlike the typeshed (i.e. Timeout, not _Timeout).

tests/test_client.py Outdated Show resolved Hide resolved
pystac_client/client.py Outdated Show resolved Hide resolved
@codecov-commenter
Copy link

codecov-commenter commented Mar 31, 2023

Codecov Report

Patch coverage: 81.81% and project coverage change: -0.14 ⚠️

Comparison is base (0a43803) 87.51% compared to head (df8f496) 87.38%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #463      +/-   ##
==========================================
- Coverage   87.51%   87.38%   -0.14%     
==========================================
  Files          12       12              
  Lines         857      864       +7     
==========================================
+ Hits          750      755       +5     
- Misses        107      109       +2     
Impacted Files Coverage Δ
pystac_client/stac_api_io.py 91.20% <77.77%> (-1.18%) ⬇️
pystac_client/client.py 81.96% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Member

@gadomski gadomski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, I added a drop-dead simple smoke test just to ensure things don't break when you provide a timeout. Thanks!

@gadomski gadomski enabled auto-merge (squash) April 21, 2023 13:33
@gadomski gadomski disabled auto-merge April 21, 2023 13:34
@gadomski gadomski self-requested a review April 21, 2023 13:35
Copy link
Member

@gadomski gadomski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I pushed "approve" prematurely. One inline change, and also Client.open needs timeout added to its docstring.

pystac_client/client.py Show resolved Hide resolved
@gadomski gadomski merged commit 114724d into stac-utils:main Apr 25, 2023
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for 'timeout' parameter
3 participants