-
Notifications
You must be signed in to change notification settings - Fork 93
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
feat(datasets): add wrapped dataset to store the response from a POST/PUT request #905
base: main
Are you sure you want to change the base?
Conversation
@property | ||
def _nested_dataset_type( | ||
self, | ||
) -> Type[JSONDataset | PickleDataset | MemoryDataset]: |
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.
There might be a better way to do this.
if self._extension == "json": | ||
self.wrapped_dataset.save(response.json()) #TODO(npfp): expose json loads arguments | ||
elif self._extension == "text": | ||
self.wrapped_dataset.save(response.text) | ||
elif self._extension: | ||
self.wrapped_dataset.save(response) |
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.
Might be better to check on the self.wrapped_dataset
type:
if self._extension == "json": | |
self.wrapped_dataset.save(response.json()) #TODO(npfp): expose json loads arguments | |
elif self._extension == "text": | |
self.wrapped_dataset.save(response.text) | |
elif self._extension: | |
self.wrapped_dataset.save(response) | |
elif isinstance(self.wrapped_dataset, JSONDataset): | |
self.wrapped_dataset.save(response.json()) #TODO(npfp): expose json loads arguments | |
elif isinstance(self.wrapped_dataset, TextDataset) | |
self.wrapped_dataset.save(response.text) | |
elif self._extension: | |
self.wrapped_dataset.save(response) |
2978b3c
to
dc433d1
Compare
…/PUT request Proof of concept to start discussions about design on how to store and use response. Signed-off-by: Nicolas Perrin <[email protected]>
dc433d1
to
e9980af
Compare
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.
Hi @npfp , sorry for the very long delay here. Thanks a lot for sending this pull request.
Is your idea to make APIDataset
wrap another dataset? (Similar to what you mentioned in #748 (comment))
I'm assuming that this is a breaking change on the API dataset right?
No worries. Thx for getting back to me! Yes, I chose the wrapped dataset mainly because it would avoid maintenance burden by relying on the implementation of the wrapped dataset rather than duplicating the logic there. Of course, it's a subjective opinion, so feel free to challenge this, if it doesn't follow kedro's guidelines. |
I don't think it's a breaking change of the API dataset: the wrapped dataset args are optionals. If not provided, the response is not saved as it's already the case. |
It's been a while since I looked at the issue this PR is for, but if I understand correctly the problem with APIDataset is that it only returns the response, but doesn't actually save it? And this PR aims to add a wrapper so a user can indicate what format to save the response in? On the original issue I said I didn't like the idea of importing other datasets, which I still agree with, but at the same time it does make sense now I see it in code 😜 I'll have to think about this a bit more to review it properly. |
Yes that's right:
Good to know, thx! (I'm a bit biased because we almost always use wrapped dataset for our custom datasets: we're lazy and like relying on a maintained classe :-) ) |
Proof of concept to start discussions about design on how to store and use the
response
object.Description
To pursue discussions on how we could store the
response
object from aPOST
orPUT
api request.Relates to #748
Development notes
Checklist
RELEASE.md
file