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

Fixing json response #43

Merged
merged 1 commit into from
Aug 25, 2022
Merged
Show file tree
Hide file tree
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
11 changes: 4 additions & 7 deletions marketplace/app/v0/base.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import json
from typing import Optional
from urllib.parse import urljoin

Expand Down Expand Up @@ -37,10 +36,8 @@ def global_search(
self, q: str, limit: int = 100, offset: int = 0
) -> GlobalSearchResponse:
return GlobalSearchResponse.parse_obj(
json.loads(
self._client.get(
self._proxy_path("globalSearch"),
params={"q": q, "limit": limit, "offset": offset},
)
)
self._client.get(
self._proxy_path("globalSearch"),
params={"q": q, "limit": limit, "offset": offset},
).json()
)
24 changes: 10 additions & 14 deletions marketplace/app/v0/object_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,12 @@ def create_dataset(
if dataset_name:
params.update({"dataset_name": dataset_name})
return object_storage.DatasetCreateResponse.parse_obj(
json.loads(
self._client.put(
self._proxy_path("createDataset"),
params=params,
headers=_encode_metadata(metadata),
data=file.file,
)
)
self._client.put(
self._proxy_path("createDataset"),
params=params,
headers=_encode_metadata(metadata),
data=file.file,
).json()
)

@check_capability_availability
Expand Down Expand Up @@ -202,10 +200,8 @@ def get_semantic_mapping(
self, semantic_mapping_id: str
) -> object_storage.SemanticMappingModel:
return object_storage.SemanticMappingModel.parse_obj(
json.loads(
self._client.get(
self._proxy_path("getSemanticMapping"),
params={"semantic_mapping_id": semantic_mapping_id},
)
)
self._client.get(
self._proxy_path("getSemanticMapping"),
params={"semantic_mapping_id": semantic_mapping_id},
).json()
)
52 changes: 20 additions & 32 deletions marketplace/app/v0/transformation.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import json

import marketplace_standard_app_api.models.transformation as transformation

from ..utils import check_capability_availability
Expand All @@ -12,37 +10,31 @@ def get_transformation_list(
self, limit: int = 100, offset: int = 0
) -> transformation.TransformationListResponse:
return transformation.TransformationListResponse.parse_obj(
json.loads(
self._client.get(
self._proxy_path("getTransformationList"),
params={"limit": limit, "offset": offset},
)
)
self._client.get(
self._proxy_path("getTransformationList"),
params={"limit": limit, "offset": offset},
).json()
)

@check_capability_availability
def new_transformation(
self, new_transformation: transformation.NewTransformationModel
) -> transformation.TransformationCreateResponse:
return transformation.TransformationCreateResponse.parse_obj(
json.loads(
self._client.post(
self._proxy_path("newTransformation"), json=new_transformation
)
)
self._client.post(
self._proxy_path("newTransformation"), json=new_transformation
).json()
)

@check_capability_availability
def get_transformation(
self, transformation_id: transformation.TransformationId
) -> transformation.TransformationModel:
return transformation.TransformationModel.parse_obj(
json.loads(
self._client.get(
self._proxy_path("getTransformation"),
params={"transformation_id": transformation_id},
)
)
self._client.get(
self._proxy_path("getTransformation"),
params={"transformation_id": transformation_id},
).json()
)

@check_capability_availability
Expand All @@ -59,13 +51,11 @@ def _update_transformation(
update: transformation.TransformationUpdateModel,
) -> transformation.TransformationUpdateResponse:
return transformation.TransformationUpdateResponse.parse_obj(
json.loads(
self._client.patch(
self._proxy_path("updateTransformation"),
params={"transformation_id": transformation_id},
json=update,
)
)
self._client.patch(
self._proxy_path("updateTransformation"),
params={"transformation_id": transformation_id},
json=update,
).json()
)

def start_transformation(
Expand Down Expand Up @@ -107,10 +97,8 @@ def get_transformation_state(
self, transformation_id: transformation.TransformationId
) -> transformation.TransformationState:
return transformation.TransformationStateResponse.parse_obj(
json.loads(
self._client.get(
self._proxy_path("getTransformationState"),
params={"transformation_id": transformation_id},
)
)
self._client.get(
self._proxy_path("getTransformationState"),
params={"transformation_id": transformation_id},
).json()
).state