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
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 16 additions & 12 deletions marketplace/app/v0/object_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.)

return self._client.put(
self._proxy_path("createOrUpdateCollection"),
params={"collection_name": collection_name} if collection_name else {},
headers=_encode_metadata(metadata),
).text
).json()

@check_capability_availability
def delete_collection(self, collection_name: object_storage.CollectionName):
Expand All @@ -58,7 +58,6 @@ def delete_collection(self, collection_name: object_storage.CollectionName):
params={"collection_name": collection_name},
)

# NOTE: change to GET for the meeting if proxy doesn't support HEAD requests
@check_capability_availability
def get_collection_metadata(
self, collection_name: object_storage.CollectionName
Expand All @@ -74,12 +73,12 @@ def create_collection(
self,
collection_name: object_storage.CollectionName = None,
metadata: dict = None,
) -> str:
) -> Union[Dict, str]:
return self._client.put(
self._proxy_path("createCollection"),
params={"collection_name": collection_name} if collection_name else {},
headers=_encode_metadata(metadata),
).text
).json()

@check_capability_availability
def create_dataset(
Expand Down Expand Up @@ -107,15 +106,15 @@ def create_dataset_metadata(
collection_name: object_storage.CollectionName,
dataset_name: object_storage.DatasetName = None,
metadata: dict = None,
) -> str:
) -> Union[Dict, str]:
params = {"collection_name": collection_name}
if dataset_name:
params.update({"dataset_name": dataset_name})
return self._client.post(
self._proxy_path("createDatasetMetadata"),
params=params,
headers=_encode_metadata(metadata),
).text
).json()

@check_capability_availability
def get_dataset(
Expand All @@ -125,7 +124,10 @@ def get_dataset(
) -> Union[Dict, str]:
return self._client.get(
self._proxy_path("getDataset"),
params={"collection_name": collection_name, "dataset_name": dataset_name},
params={
"collection_name": collection_name,
"dataset_name": dataset_name,
},
).json()

def create_or_replace_dataset(
Expand Down Expand Up @@ -153,12 +155,15 @@ def create_or_replace_dataset_metadata(
collection_name: object_storage.CollectionName,
dataset_name: object_storage.DatasetName,
metadata: dict = None,
) -> str:
) -> Union[Dict, str]:
return self._client.put(
self._proxy_path("createOrReplaceDatasetMetadata"),
params={"collection_name": collection_name, "dataset_name": dataset_name},
params={
"collection_name": collection_name,
"dataset_name": dataset_name,
},
headers=_encode_metadata(metadata),
).text
).json()

@check_capability_availability
def delete_dataset(
Expand All @@ -171,7 +176,6 @@ def delete_dataset(
params={"collection_name": collection_name, "dataset_name": dataset_name},
)

# NOTE: change to GET for the meeting if proxy doesn't support HEAD requests
@check_capability_availability
def get_dataset_metadata(
self,
Expand Down