From 5ce58efe96ed32e58f2008020e063c7b8ee39d5e Mon Sep 17 00:00:00 2001 From: Nathan Freeman Date: Thu, 10 Oct 2024 15:43:37 -0500 Subject: [PATCH 1/2] Attempt fix of template mapper and debug --- src/engine/src/templating/TemplateMapper.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/engine/src/templating/TemplateMapper.py b/src/engine/src/templating/TemplateMapper.py index b39f62ce..b03e2fb7 100644 --- a/src/engine/src/templating/TemplateMapper.py +++ b/src/engine/src/templating/TemplateMapper.py @@ -53,6 +53,8 @@ def map( None ) + print(f"TYPE map_target_class: {map_target_class.__name__}") + # Raise exception if no class could be resolved from the template if map_target_class == None: 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')}") @@ -61,6 +63,8 @@ def map( # map target tmp_obj = map_target.dict() + print(f"TYPE tmp_obj: {type(tmp_obj)}") + # Create a dictionary of the map target object and map the properties of # the template onto the dictionary for attr in template.keys(): @@ -108,17 +112,17 @@ def map( # map target object new_obj = map_target_class(**tmp_obj) - # Now update all of the properties to the map target object from the tmp + # Now update all of the properties to the map target object from the new # object. # NOTE this allows us to return the exact same object that was passed as - # and argument but with the modifications, there by maintaining the + # and argument but with the modifications, thereby maintaining the # objects identity. for attr in new_obj.dict().keys(): if attr == "tasks": continue updated_value = getattr(new_obj, attr) - if getattr(map_target, attr) != updated_value: + if getattr(map_target, attr, None) != updated_value: setattr(map_target, attr, updated_value) return map_target From 7379e6e39515660c9e7f8876ca7eca4e01de0bf8 Mon Sep 17 00:00:00 2001 From: Nathan Freeman Date: Thu, 10 Oct 2024 17:26:27 -0500 Subject: [PATCH 2/2] Remove debug --- src/engine/src/templating/TemplateMapper.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/engine/src/templating/TemplateMapper.py b/src/engine/src/templating/TemplateMapper.py index b03e2fb7..78167223 100644 --- a/src/engine/src/templating/TemplateMapper.py +++ b/src/engine/src/templating/TemplateMapper.py @@ -53,8 +53,6 @@ def map( None ) - print(f"TYPE map_target_class: {map_target_class.__name__}") - # Raise exception if no class could be resolved from the template if map_target_class == None: 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')}") @@ -63,8 +61,6 @@ def map( # map target tmp_obj = map_target.dict() - print(f"TYPE tmp_obj: {type(tmp_obj)}") - # Create a dictionary of the map target object and map the properties of # the template onto the dictionary for attr in template.keys():