From a8b6c0daa5f8b3e55bde33d5c94accc59d6795b8 Mon Sep 17 00:00:00 2001 From: Justin Terry Date: Thu, 12 Sep 2024 11:42:15 -0400 Subject: [PATCH] Workaround GTC-2986 by checking if version is successfully created after getting 5XX response --- src/datapump/clients/data_api.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/datapump/clients/data_api.py b/src/datapump/clients/data_api.py index b91c7dc..672b794 100644 --- a/src/datapump/clients/data_api.py +++ b/src/datapump/clients/data_api.py @@ -129,16 +129,26 @@ 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"] + return self.get_version(ValidMethods.post, uri, payload)["data"] def append( self, dataset: str, version: str, source_uris: List[str]