Skip to content

Commit

Permalink
fix(ingest/lookml): add view load failures to cache (#10923)
Browse files Browse the repository at this point in the history
  • Loading branch information
hsheth2 committed Jul 17, 2024
1 parent 7f3da47 commit 90f0743
Showing 1 changed file with 6 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,12 @@ def __init__(
reporter: LookMLSourceReport,
liquid_variable: Dict[Any, Any],
) -> None:
self.viewfile_cache: Dict[str, LookerViewFile] = {}
self.viewfile_cache: Dict[str, Optional[LookerViewFile]] = {}
self._root_project_name = root_project_name
self._base_projects_folder = base_projects_folder
self.reporter = reporter
self.liquid_variable = liquid_variable

def is_view_seen(self, path: str) -> bool:
return path in self.viewfile_cache

def _load_viewfile(
self, project_name: str, path: str, reporter: LookMLSourceReport
) -> Optional[LookerViewFile]:
Expand All @@ -56,17 +53,15 @@ def _load_viewfile(
)
return None

if self.is_view_seen(str(path)):
if path in self.viewfile_cache:
return self.viewfile_cache[path]

try:
with open(path) as file:
raw_file_content = file.read()
except Exception as e:
logger.debug(f"An error occurred while reading path {path}", exc_info=True)
self.reporter.report_failure(
path, f"failed to load view file {path} from disk: {e}"
)
self.reporter.failure("Failed to read lkml file", path, exc=e)
self.viewfile_cache[path] = None
return None
try:
logger.debug(f"Loading viewfile {path}")
Expand All @@ -91,8 +86,8 @@ def _load_viewfile(
self.viewfile_cache[path] = looker_viewfile
return looker_viewfile
except Exception as e:
logger.debug(f"An error occurred while parsing path {path}", exc_info=True)
self.reporter.report_failure(path, f"failed to load view file {path}: {e}")
self.reporter.failure("Failed to parse lkml file", path, exc=e)
self.viewfile_cache[path] = None
return None

def load_viewfile(
Expand Down

0 comments on commit 90f0743

Please sign in to comment.