Skip to content

Commit

Permalink
Merge pull request #153 from wri/batman/workaround_gtc-2986
Browse files Browse the repository at this point in the history
Workaround GTC-2986 by checking if version is successfully created after get 5XX response from API
  • Loading branch information
jterry64 authored Sep 16, 2024
2 parents 2e8370e + e35fc95 commit 3df7213
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/datapump/clients/data_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,24 @@ def create_vector_version(
def create_version(
self, dataset: str, version: str, payload: Dict[str, Any]
) -> Dict[str, Any]:

uri = f"{GLOBALS.data_api_uri}/dataset/{dataset}/{version}"
return self._send_request(ValidMethods.put, uri, payload)["data"]
try:
uri = f"{GLOBALS.data_api_uri}/dataset/{dataset}/{version}"
return self._send_request(ValidMethods.put, uri, payload)["data"]
except DataApiResponseError as e:
# Workaround for GTC-2986
# Getting a 500 response when creating version, but version is still created
# causing a 400 response on subsequent retries since we're trying to PUT
# an already existing version.
# For now, let's just return the version if it exists.
# Otherwise, propagate original exception.
try:
return self.get_version(dataset, version)
except DataApiResponseError:
raise e

def create_aux_asset(
self, dataset: str, version: str, payload: Dict[str, Any]
) -> Dict[str, Any]:

uri = f"{GLOBALS.data_api_uri}/dataset/{dataset}/{version}/assets"
return self._send_request(ValidMethods.post, uri, payload)["data"]

Expand Down

0 comments on commit 3df7213

Please sign in to comment.