diff --git a/qualibrate_runner/api/routes/submit.py b/qualibrate_runner/api/routes/submit.py index 52b7570..3373768 100644 --- a/qualibrate_runner/api/routes/submit.py +++ b/qualibrate_runner/api/routes/submit.py @@ -22,6 +22,7 @@ run_workflow, validate_input_parameters, ) +from qualibrate_runner.core.types_parsing import types_conversion submit_router = APIRouter(prefix="/submit") @@ -43,10 +44,13 @@ def submit_node_run( status_code=status.HTTP_422_UNPROCESSABLE_ENTITY, detail="Already running", ) + converted_parameters = types_conversion( + input_parameters, node.parameters_class.serialize() + ) validate_input_parameters( - cast(Type[BaseModel], node.parameters_class), input_parameters + cast(Type[BaseModel], node.parameters_class), converted_parameters ) - background_tasks.add_task(run_node, node, input_parameters, state) + background_tasks.add_task(run_node, node, converted_parameters, state) return f"Node job {node.name} is submitted" diff --git a/qualibrate_runner/core/run_job.py b/qualibrate_runner/core/run_job.py index cac5f93..35e003f 100644 --- a/qualibrate_runner/core/run_job.py +++ b/qualibrate_runner/core/run_job.py @@ -10,7 +10,6 @@ from qualibrate_runner.config import State from qualibrate_runner.core.models.last_run import LastRun, RunError, RunStatus -from qualibrate_runner.core.types_parsing import types_conversion def validate_input_parameters( @@ -47,11 +46,8 @@ def run_node( try: library = get_active_library_or_error() node = library.nodes[node.name] - converted_parameters = types_conversion( - passed_input_parameters, node.parameters_class.serialize() - ) result = library.run_node( - node.name, node.parameters_class(**converted_parameters) + node.name, node.parameters_class(**passed_input_parameters) ) except Exception as ex: state.last_run = LastRun( diff --git a/qualibrate_runner/core/types_parsing.py b/qualibrate_runner/core/types_parsing.py index 257d777..fe448b6 100644 --- a/qualibrate_runner/core/types_parsing.py +++ b/qualibrate_runner/core/types_parsing.py @@ -63,6 +63,15 @@ def parse_float(value: VALUE_TYPES_WITHOUT_REC) -> VALUE_TYPES_WITHOUT_REC: def parse_str(value: VALUE_TYPES_WITHOUT_REC) -> VALUE_TYPES_WITHOUT_REC: + if ( + isinstance(value, str) + and len(value) > 1 + and ( + (value.startswith('"') and value.endswith('"')) + or (value.startswith("'") and value.endswith("'")) + ) + ): + return value[1:-1] return value