Skip to content

Commit

Permalink
add checks for template validity
Browse files Browse the repository at this point in the history
  • Loading branch information
nathandf committed Oct 18, 2023
1 parent 7f2c251 commit 3c93b6f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,6 @@ def _set_tasks(self, tasks):
def _prepare_pipeline(self):
# Create all of the directories needed for the pipeline to run and persist results and cache
self._prepare_pipeline_fs()
print(self.state.ctx)

# template_mapper = TemplateMapper(cache_dir=self.state.ctx.pipeline.git_cache_dir)
# if self.state.ctx.pipeline.uses != None:
Expand Down
19 changes: 9 additions & 10 deletions src/engine/src/helpers/TemplateRepository.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,22 @@ def get_by_uses(self, uses: Uses):
)

template_root_dir = os.path.join(self.cache_dir, git_repo_dir)

print("USES", uses)

try:
# Open the owe-config.json file
with open(os.path.join(template_root_dir, "owe-config.json")) as file:
owe_config = json.loads(file.read())
print("OWECONFIG", owe_config)

# Open the etl pipeline schema.json
print("TEMPLATE DIR", template_root_dir)
with open(
os.path.join(
template_root_dir,
owe_config.get(uses.name).get("path")
)
) as file:
template_ref = owe_config.get(uses.name, None)
if template_ref == None:
raise Exception(f"Template reference for key '{uses.name}' not found in the config file")

path_to_template = template_ref.get("path", None)
if path_to_template == None:
raise Exception(f"The template reference object for template '{uses.name}' is undefined")

with open(os.path.join(template_root_dir, path_to_template)) as file:
template = json.loads(file.read())
except Exception as e:
raise Exception(f"Templating configuration Error (owe-config.json): {str(e)}")
Expand Down

0 comments on commit 3c93b6f

Please sign in to comment.