GeezerVison is showing github.com — feat: reraise exceptions from API calls · googleapis/python-aiplatform@d72bc83
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: google/cloud/aiplatform/datasets/column_names_dataset.py +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -157,7 +157,7 @@ def _retrieve_gcs_source_columns( |
157 | 157 | "There was a problem extracting the headers from the CSV file at '{}': {}".format( |
158 | 158 | gcs_csv_file_path, err |
159 | 159 | ) |
160 | | - ) |
| 160 | + ) from err |
161 | 161 | finally: |
162 | 162 | logger.removeFilter(logging_warning_filter) |
163 | 163 |
|
|
Collapse file
Copy file name to clipboardExpand all lines: google/cloud/aiplatform/initializer.py +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -212,8 +212,8 @@ def project(self) -> str: |
212 | 212 |
|
213 | 213 | try: |
214 | 214 | _, 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 |
217 | 217 |
|
218 | 218 | if not project_id: |
219 | 219 | raise ValueError(project_not_found_exception_str) |
|
Collapse file
Copy file name to clipboardExpand all lines: google/cloud/aiplatform/models.py +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -2508,10 +2508,10 @@ def training_job(self) -> Optional["aiplatform.training_jobs._TrainingJob"]: |
2508 | 2508 | location=self.location, |
2509 | 2509 | credentials=self.credentials, |
2510 | 2510 | ) |
2511 | | - except api_exceptions.NotFound: |
| 2511 | + except api_exceptions.NotFound as exc: |
2512 | 2512 | raise api_exceptions.NotFound( |
2513 | 2513 | f"The training job used to create this model could not be found: {job_name}" |
2514 | | - ) |
| 2514 | + ) from exc |
2515 | 2515 |
|
2516 | 2516 | @property |
2517 | 2517 | def container_spec(self) -> Optional[model_v1.ModelContainerSpec]: |
|
Collapse file
Copy file name to clipboardExpand all lines: google/cloud/aiplatform/tensorboard/uploader.py +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -873,7 +873,7 @@ def flush(self): |
873 | 873 | hasattr(e, "code") |
874 | 874 | and getattr(e, "code")() == grpc.StatusCode.NOT_FOUND |
875 | 875 | ): |
876 | | - raise ExperimentNotFoundError() |
| 876 | + raise ExperimentNotFoundError() from e |
877 | 877 | logger.error("Upload call failed with error %s", e) |
878 | 878 |
|
879 | 879 | self._new_request() |
@@ -1161,7 +1161,7 @@ def _validate( |
1161 | 1161 | "a bug in the process that wrote the tensor.\n\n" |
1162 | 1162 | "The tensor has tag '%s' and is at step %d and wall_time %.6f.\n\n" |
1163 | 1163 | "Original error:\n%s" % (value.tag, event.step, event.wall_time, error) |
1164 | | - ) |
| 1164 | + ) from error |
1165 | 1165 | return True |
1166 | 1166 |
|
1167 | 1167 |
|
|
Collapse file
Copy file name to clipboardExpand all lines: google/cloud/aiplatform/tensorboard/uploader_main.py +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -110,7 +110,7 @@ def main(argv): |
110 | 110 | raise app.UsageError( |
111 | 111 | "Tensorboard resource %s not found" % FLAGS.tensorboard_resource_name, |
112 | 112 | exitcode=0, |
113 | | - ) |
| 113 | + ) from rpc_error |
114 | 114 | raise |
115 | 115 |
|
116 | 116 | if tensorboard.blob_storage_path_prefix: |
|