Skip to content

Commit

Permalink
bugfix templatemapper
Browse files Browse the repository at this point in the history
  • Loading branch information
nathandf committed Oct 18, 2023
1 parent cec5cb8 commit f5fdd20
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/engine/src/helpers/TemplateMapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
TapisActorTask
)

from pprint import pprint

class TemplateMapper:
def __init__(self, cache_dir: str):
self.task_map_by_type = {
Expand All @@ -35,15 +37,16 @@ def map(self, obj: Union[Pipeline, Task], uses: Uses) -> Union[Pipeline, Task]:

# Clone git repository specified on the pipeline.uses if exists
template = self.template_repo.get_by_uses(uses)

print("TEMPLATE TO BE MAPPED")
pprint()
# Resolve which class the final object should have
obj_class = Pipeline
if not issubclass(obj.__class__, Pipeline):
obj_class = self.task_map_by_type.get(obj.type, None)
obj_class = self.task_map_by_type.get(template.get("type", None), None)

# Raise exception if no class could be resolved from the template
if obj_class == None:
raise Exception(f"Invalid Template: Unable to resolve object type from Template. Task template object 'type' property must be one of [{self.task_map_by_type.keys()}]")
raise Exception(f"Invalid Template: Unable to resolve object type from Template. Task template object 'type' property must be one of {list(self.task_map_by_type.keys())} | Recieved: {template.get('type', 'None')}")

dict_obj = obj.dict()

Expand Down

0 comments on commit f5fdd20

Please sign in to comment.