From ec0b41e61bd06828761bae9c106d10d8d47041ec Mon Sep 17 00:00:00 2001 From: gadorlhiac Date: Thu, 11 Apr 2024 08:06:46 -0700 Subject: [PATCH] BUG Attempt to fix database issue with TemplateParameters objects --- lute/io/db.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lute/io/db.py b/lute/io/db.py index 3165bdaa..e7ee9086 100644 --- a/lute/io/db.py +++ b/lute/io/db.py @@ -22,7 +22,7 @@ import logging from typing import List, Dict, Dict, Any, Tuple, Optional -from .models.base import TaskParameters +from .models.base import TaskParameters, TemplateParameters from ..tasks.dataclasses import TaskResult, TaskStatus, DescribedAnalysis if __debug__: @@ -188,13 +188,16 @@ def _dict_to_flatdicts( flat_key = key else: flat_key = f"{curr_key}.{key}" - if isinstance(value, dict): - x, y = _dict_to_flatdicts(value, curr_key=flat_key) + corrected_value: Any = value + if isinstance(corrected_value, TemplateParameters): + corrected_value = value.params + if isinstance(corrected_value, dict): + x, y = _dict_to_flatdicts(corrected_value, curr_key=flat_key) param_list.extend(x.items()) type_list.extend(y.items()) else: - param_list.append((flat_key, value)) - type_list.append((flat_key, _check_type(value))) + param_list.append((flat_key, corrected_value)) + type_list.append((flat_key, _check_type(corrected_value))) return dict(param_list), dict(type_list)