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

feat(datasets): add wrapped dataset to store the response from a POST/PUT request #905

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

npfp
Copy link

@npfp npfp commented Oct 23, 2024

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 a POST or PUT api request.

Relates to #748

Development notes

  • Only poc code
  • Tests to be implemented

Checklist

  • Opened this PR as a 'Draft Pull Request' if it is work-in-progress
  • Updated the documentation to reflect the code changes
  • Added a description of this change in the relevant RELEASE.md file
  • Added tests to cover my changes
  • Received approvals from at least half of the TSC (required for adding a new, non-experimental dataset)

@property
def _nested_dataset_type(
self,
) -> Type[JSONDataset | PickleDataset | MemoryDataset]:
Copy link
Author

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.

Comment on lines +243 to +250
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)
Copy link
Author

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:

Suggested change
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)

@npfp npfp force-pushed the feature/save-response-in-api-dataset branch from 2978b3c to dc433d1 Compare October 23, 2024 12:54
@npfp npfp changed the title feat(api_dataset): add wrapped dataset to store the response from a POST/PUT request feat(dataset): add wrapped dataset to store the response from a POST/PUT request Oct 23, 2024
@npfp npfp changed the title feat(dataset): add wrapped dataset to store the response from a POST/PUT request feat(datasets): add wrapped dataset to store the response from a POST/PUT request Oct 23, 2024
…/PUT request

Proof of concept to start discussions about design on how to store and use response.

Signed-off-by: Nicolas Perrin <[email protected]>
@npfp npfp force-pushed the feature/save-response-in-api-dataset branch from dc433d1 to e9980af Compare October 23, 2024 13:14
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.

1 participant