From c53a3413fbc3cbe62f478ede637a2b369d8081fd Mon Sep 17 00:00:00 2001 From: Pere Miquel Brull Date: Thu, 27 Apr 2023 11:42:16 +0200 Subject: [PATCH] Fixes #11307 - Handle exceptions if LookML model is invalid (#11320) * Fix dynamo docs * Handle data model fetch exceptions * Format * Add example for Private Key format --- .../source/dashboard/looker/metadata.py | 47 +++++++++++++------ .../public/locales/en-US/Database/BigQuery.md | 19 ++++++++ 2 files changed, 52 insertions(+), 14 deletions(-) diff --git a/ingestion/src/metadata/ingestion/source/dashboard/looker/metadata.py b/ingestion/src/metadata/ingestion/source/dashboard/looker/metadata.py index cb5f4a71842..3336f412600 100644 --- a/ingestion/src/metadata/ingestion/source/dashboard/looker/metadata.py +++ b/ingestion/src/metadata/ingestion/source/dashboard/looker/metadata.py @@ -178,27 +178,47 @@ class LookerSource(DashboardServiceSource): """ if self.source_config.includeDataModels: # First, pick up all the LookML Models - all_lookml_models: Sequence[LookmlModel] = self.client.all_lookml_models() + try: + all_lookml_models: Sequence[ + LookmlModel + ] = self.client.all_lookml_models() + yield from self.fetch_lookml_explores(all_lookml_models) + except Exception as err: + logger.debug(traceback.format_exc()) + logger.error(f"Unexpected error fetching LookML models - {err}") - # Then, fetch the explores for each of them - for lookml_model in all_lookml_models: - # Each LookML model have a list of explores we'll be ingesting - for explore_nav in ( - cast(Sequence[LookmlModelNavExplore], lookml_model.explores) or [] + def fetch_lookml_explores( + self, all_lookml_models: Sequence[LookmlModel] + ) -> Iterable[LookmlModelExplore]: + """ + Based on the LookML models, iterate over the explores + they contain and filter if needed + """ + # Then, fetch the explores for each of them + for lookml_model in all_lookml_models: + # Each LookML model have a list of explores we'll be ingesting + for explore_nav in ( + cast(Sequence[LookmlModelNavExplore], lookml_model.explores) or [] + ): + if filter_by_datamodel( + self.source_config.dataModelFilterPattern, lookml_model.name ): - if filter_by_datamodel( - self.source_config.dataModelFilterPattern, lookml_model.name - ): - self.status.filter( - lookml_model.name, "Data model (Explore) filtered out." - ) - continue + self.status.filter( + lookml_model.name, "Data model (Explore) filtered out." + ) + continue + try: explore = self.client.lookml_model_explore( lookml_model_name=lookml_model.name, explore_name=explore_nav.name, ) yield explore + except Exception as err: + logger.debug(traceback.format_exc()) + logger.warning( + f"Error fetching LookML Explore [{explore_nav.name}] in model [{lookml_model.name}] - {err}" + ) def yield_bulk_datamodel( self, model: LookmlModelExplore @@ -237,7 +257,6 @@ class LookerSource(DashboardServiceSource): # We will only try and fetch if we have the credentials if self.github_credentials: for view in model.joins: - if filter_by_datamodel( self.source_config.dataModelFilterPattern, view.name ): diff --git a/openmetadata-ui/src/main/resources/ui/public/locales/en-US/Database/BigQuery.md b/openmetadata-ui/src/main/resources/ui/public/locales/en-US/Database/BigQuery.md index 29ec5ba8a81..77a7bdc2c08 100644 --- a/openmetadata-ui/src/main/resources/ui/public/locales/en-US/Database/BigQuery.md +++ b/openmetadata-ui/src/main/resources/ui/public/locales/en-US/Database/BigQuery.md @@ -84,6 +84,25 @@ $$section ### Private Key $(id="privateKey") This is the private key associated with the service account that is used to authenticate and authorize access to GCP. To fetch this key, look for the value associated with the `private_key` key in the service account file. + +Make sure you are passing the key in a correct format. If your private key looks like this: + +``` +-----BEGIN ENCRYPTED PRIVATE KEY----- +MII.. +MBQ... +CgU.. +8Lt.. +... +h+4= +-----END ENCRYPTED PRIVATE KEY----- +``` + +You will have to replace new lines with `\n` and the final private key that you need to pass should look like this: + +``` +-----BEGIN ENCRYPTED PRIVATE KEY-----\nMII..\nMBQ...\nCgU..\n8Lt..\n...\nh+4=\n-----END ENCRYPTED PRIVATE KEY-----\n +``` $$ $$section