|
32 | 32 | from splitgraph.cloud.models import ( |
33 | 33 | AddExternalCredentialRequest, |
34 | 34 | AddExternalRepositoriesRequest, |
| 35 | + AddExternalRepositoriesResponse, |
35 | 36 | AddExternalRepositoryRequest, |
36 | 37 | ExportJobStatus, |
37 | 38 | ExternalResponse, |
|
75 | 76 | from splitgraph.config.management import patch_and_save_config |
76 | 77 | from splitgraph.exceptions import ( |
77 | 78 | AuthAPIError, |
| 79 | + DataSourceError, |
78 | 80 | GQLAPIError, |
79 | 81 | GQLRepoDoesntExistError, |
80 | 82 | GQLUnauthenticatedError, |
@@ -535,17 +537,33 @@ def bulk_upsert_external( |
535 | 537 | self, |
536 | 538 | repositories: List[AddExternalRepositoryRequest], |
537 | 539 | introspection_mode: IntrospectionMode = IntrospectionMode.EMPTY, |
538 | | - ): |
| 540 | + raise_errors: bool = False, |
| 541 | + ) -> None: |
539 | 542 | request = AddExternalRepositoriesRequest( |
540 | 543 | repositories=repositories, introspection_mode=introspection_mode |
541 | 544 | ) |
542 | | - self._perform_request( |
| 545 | + response = self._perform_request( |
543 | 546 | "/bulk-add", |
544 | 547 | self.access_token, |
545 | 548 | request, |
546 | 549 | endpoint=self.externals_endpoint, |
547 | 550 | jsonschema_endpoint=True, |
| 551 | + response_class=AddExternalRepositoriesResponse, |
548 | 552 | ) |
| 553 | + assert response |
| 554 | + if response.errors: |
| 555 | + for repo_errors in response.errors: |
| 556 | + for error in repo_errors.errors: |
| 557 | + logging.warning( |
| 558 | + "Error adding table %s/%s/%s: %s (%s)", |
| 559 | + repo_errors.namespace, |
| 560 | + repo_errors.repository, |
| 561 | + error.table_name, |
| 562 | + error.error, |
| 563 | + error.error_text, |
| 564 | + ) |
| 565 | + if raise_errors: |
| 566 | + raise DataSourceError("Error introspecting some tables!") |
549 | 567 |
|
550 | 568 |
|
551 | 569 | def AuthAPIClient(*args, **kwargs): |
|
0 commit comments