-
Notifications
You must be signed in to change notification settings - Fork 27
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
update titiler-pgstac version and forward Request
in reader
#91
Conversation
@@ -49,6 +67,10 @@ class MosaicSTACReader(pgstac_mosaic.CustomSTACReader): | |||
|
|||
reader: Type[BaseReader] = attr.ib(default=CustomCOGReader) | |||
|
|||
# We make request an optional attribute to avoid re-writing | |||
# the whole list of attribute | |||
request: Optional[Request] = attr.ib(default=None) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With request
now optionally on MosaicSTACReader
, I expected to be able to access self.reader.request
within methods of PGSTACBackend
(like assets_for_tiles
), but I get the error
AttributeError: type object 'MosaicSTACReader' has no attribute 'request'
The type annotations suggest this is possible, is that the expected usage? I can confirm that ReaderParams
was initialized with a request correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you share some code, I have hard to to follow 😓
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, sorry! One use case for having the request available is to use it for our logging within backend/reader methods, e.g., grabbing a trace id from the header so all logs can be associated with a single request. Usage would be like this: f461009, but it doesn't seem like request is available from there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
latest commit should add self.request
(in the Backend)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works great - I can access the request in both the reader and the backend 👍
This PR does:
Request
in readers attribute and use titilerreader_dependency
to inject the Request object in the reader at request time