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

return json instead of str #45

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

singhpranjali
Copy link
Contributor

Per discussion: #43 (review)
Changing from string response to json

@singhpranjali singhpranjali force-pushed the fix/response-handling branch from 50f1163 to 304622b Compare August 25, 2022 15:21
@singhpranjali singhpranjali requested a review from csadorf August 25, 2022 15:21
@csadorf csadorf linked an issue Aug 25, 2022 that may be closed by this pull request
Copy link
Collaborator

@csadorf csadorf left a comment

Choose a reason for hiding this comment

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

Thank you for the quick fix, however it missing the data models for the return types as pointed out inline.

marketplace/app/v0/object_storage.py Outdated Show resolved Hide resolved
marketplace/app/v0/object_storage.py Outdated Show resolved Hide resolved
marketplace/app/v0/object_storage.py Outdated Show resolved Hide resolved
marketplace/app/v0/object_storage.py Outdated Show resolved Hide resolved
@singhpranjali singhpranjali requested a review from csadorf August 26, 2022 18:05
Copy link
Collaborator

@csadorf csadorf left a comment

Choose a reason for hiding this comment

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

The functions are still missing the appropriate response models. I am very sorry that my previous comment was in so far easy to misunderstand.

As an example, the correct response model for the create_dataset function is DatasetCreateResponse. This can be inferred from the standard-app-api definition. In other cases it might be a bit less obvious, e.g., for the get_dataset_metadata function I would expect to simply receive a plain dict.

The standard-app-api implements the API specification and also serves as a prototype for the actual server implementation. The server expects Response types, because it is a web server. However, the SDK is to be used by application developers. They do not need to worry about the HTTP responses anymore, here we should work with Python types as appropriate. So, coming back to the original example, getDatasetMetadata function is to be used to actually obtain the dataset metadata (as a dict), not to generate a server response.

@@ -44,12 +44,12 @@ def create_or_update_collection(
self,
metadata: dict = None,
collection_name: object_storage.CollectionName = None,
) -> str:
) -> Union[Dict, str]:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there still a path where this function would return str?

(Same question for all other similar occurrences.)

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.

Some operations return str, but there are proper response models
2 participants