From f4e3bba96c706e684398b963b56b5b5864cc4724 Mon Sep 17 00:00:00 2001 From: Mike DeAngelo Date: Wed, 18 Dec 2024 14:19:55 -0500 Subject: [PATCH] fix: handle NotFound error when fetching explore against internal fields --- henry/modules/fetcher.py | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/henry/modules/fetcher.py b/henry/modules/fetcher.py index bf6e8de..7392790 100644 --- a/henry/modules/fetcher.py +++ b/henry/modules/fetcher.py @@ -157,17 +157,31 @@ def get_explores( assert isinstance(m.name, str) assert isinstance(m.explores, list) explores.extend( - [ - self.sdk.lookml_model_explore(m.name, cast(str, e.name)) - for e in m.explores - ] + list( + filter(None, + [ + self.lookml_model_explore(m.name, cast(str, e.name)) + for e in m.explores + ] + ) + ) ) except error.SDKError: raise exceptions.NotFoundError( - "An error occured while getting models/explores." + f"An error occured while getting model:{model}/explore:{explore}." ) return explores + def lookml_model_explore(self, model: str, explore: str): + try: + return self.sdk.lookml_model_explore(model, explore) + except error.SDKError as e: + if e.message == 'Not found': + print(f"No Data Found while getting model {model}/explore {explore}.") + else: + raise + return [] + def get_used_explores( self, *, model: Optional[str] = None, explore: str = "" ) -> Dict[str, int]: