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

818 stac requests resilience #1022

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

JeroenVerstraelen
Copy link
Contributor

I use a Poolmanager for the retry mechanism as stated in the urllib3 docs:
https://urllib3.readthedocs.io/en/stable/user-guide.html#making-requests

This did require me to create an extra mock class for Poolmanager.request.

Due to a bug in the original StacAPIIo class we were forced to create a custom implementation (stac-utils/pystac-client#706). See #818 for more information.
Given that we are using urllib3.Poolmanager.request instead of urllib3.request this required a different patch.
@JeroenVerstraelen JeroenVerstraelen linked an issue Jan 28, 2025 that may be closed by this pull request
Copy link
Member

@soxofaan soxofaan left a comment

Choose a reason for hiding this comment

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

some quick notes

openeogeotrellis/integrations/stac.py Outdated Show resolved Hide resolved
openeogeotrellis/integrations/stac.py Outdated Show resolved Hide resolved


class StacApiIO(DefaultStacIO):

Copy link
Member

Choose a reason for hiding this comment

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

Can you document what this class adds on top of the existing DefaultStacIO?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Copy link
Member

Choose a reason for hiding this comment

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

While checking some pystac details I stumbled on pystac.stac_io.RetryStacIO https://pystac.readthedocs.io/en/stable/api/stac_io.html#pystac.stac_io.RetryStacIO shouldn't we just use that instead?

Copy link
Member

@soxofaan soxofaan Jan 30, 2025

Choose a reason for hiding this comment

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

as discussed: RetryStacIO does not have timeout control.

I opened a ticket to feature-request that already:

I would add a technical debt comment to migrate to that solution in the future instead of having to maintain this home-grown wrapper/hack

openeogeotrellis/integrations/stac.py Show resolved Hide resolved
tests/test_api_result.py Outdated Show resolved Hide resolved
tests/test_api_result.py Outdated Show resolved Hide resolved

def get(self, href, data):
code = 200
self.urllib_mock.get(href, data, code)
if isinstance(data, str):
data = data.encode("utf-8")
self.requests_mock.get(href, content=data)

self.urlopen_mocker.get(href, data, code)
Copy link
Member

Choose a reason for hiding this comment

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

data is bytes here, is that ok?



class StacApiIO(DefaultStacIO):

Copy link
Member

Choose a reason for hiding this comment

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

While checking some pystac details I stumbled on pystac.stac_io.RetryStacIO https://pystac.readthedocs.io/en/stable/api/stac_io.html#pystac.stac_io.RetryStacIO shouldn't we just use that instead?

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.

STAC requests resilience
2 participants