Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ingest/lookml): add view load failures to cache #10923

Merged
merged 4 commits into from
Jul 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading