Skip to content

Commit d72bc83

Browse files
dizcologycopybara-github
authored andcommitted
feat: reraise exceptions from API calls
PiperOrigin-RevId: 494773031
1 parent bc9e2cf commit d72bc83

File tree

5 files changed

+8
-8
lines changed

5 files changed

+8
-8
lines changed

google/cloud/aiplatform/datasets/column_names_dataset.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ def _retrieve_gcs_source_columns(
157157
"There was a problem extracting the headers from the CSV file at '{}': {}".format(
158158
gcs_csv_file_path, err
159159
)
160-
)
160+
) from err
161161
finally:
162162
logger.removeFilter(logging_warning_filter)
163163

google/cloud/aiplatform/initializer.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,8 @@ def project(self) -> str:
212212

213213
try:
214214
_, project_id = google.auth.default()
215-
except GoogleAuthError:
216-
raise GoogleAuthError(project_not_found_exception_str)
215+
except GoogleAuthError as exc:
216+
raise GoogleAuthError(project_not_found_exception_str) from exc
217217

218218
if not project_id:
219219
raise ValueError(project_not_found_exception_str)

google/cloud/aiplatform/models.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -2508,10 +2508,10 @@ def training_job(self) -> Optional["aiplatform.training_jobs._TrainingJob"]:
25082508
location=self.location,
25092509
credentials=self.credentials,
25102510
)
2511-
except api_exceptions.NotFound:
2511+
except api_exceptions.NotFound as exc:
25122512
raise api_exceptions.NotFound(
25132513
f"The training job used to create this model could not be found: {job_name}"
2514-
)
2514+
) from exc
25152515

25162516
@property
25172517
def container_spec(self) -> Optional[model_v1.ModelContainerSpec]:

google/cloud/aiplatform/tensorboard/uploader.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -873,7 +873,7 @@ def flush(self):
873873
hasattr(e, "code")
874874
and getattr(e, "code")() == grpc.StatusCode.NOT_FOUND
875875
):
876-
raise ExperimentNotFoundError()
876+
raise ExperimentNotFoundError() from e
877877
logger.error("Upload call failed with error %s", e)
878878

879879
self._new_request()
@@ -1161,7 +1161,7 @@ def _validate(
11611161
"a bug in the process that wrote the tensor.\n\n"
11621162
"The tensor has tag '%s' and is at step %d and wall_time %.6f.\n\n"
11631163
"Original error:\n%s" % (value.tag, event.step, event.wall_time, error)
1164-
)
1164+
) from error
11651165
return True
11661166

11671167

google/cloud/aiplatform/tensorboard/uploader_main.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def main(argv):
110110
raise app.UsageError(
111111
"Tensorboard resource %s not found" % FLAGS.tensorboard_resource_name,
112112
exitcode=0,
113-
)
113+
) from rpc_error
114114
raise
115115

116116
if tensorboard.blob_storage_path_prefix:

0 commit comments

Comments
 (0)