diff --git a/rest/clients/database.py b/rest/clients/database.py index 271a314..48689e1 100644 --- a/rest/clients/database.py +++ b/rest/clients/database.py @@ -2,6 +2,7 @@ from sqlalchemy.orm import sessionmaker from contextlib import contextmanager import ast +import json from db.models import User, DataSource, Run @@ -108,7 +109,7 @@ def get_run_info(self, run_id): "lastRun": obj.last_run, "status": obj.status, "dataSourceName": data_source.name, - "metadata": ast.literal_eval(obj.metadata_), + "metadata": json.loads(obj.metadata_), "logs": obj.logs, "outputPath": obj.output_path } diff --git a/rest/routes/sorting.py b/rest/routes/sorting.py index 9f77ff2..cc97a7d 100644 --- a/rest/routes/sorting.py +++ b/rest/routes/sorting.py @@ -45,7 +45,6 @@ async def route_run_sorting(data: SortingData, background_tasks: BackgroundTasks run_identifier = datetime.now().strftime("%Y%m%d%H%M%S") else: run_identifier = data.run_identifier - payload = data.dict() try: # Create Database entries db_client = DatabaseClient(connection_string=settings.DB_CONNECTION_STRING) @@ -67,13 +66,17 @@ async def route_run_sorting(data: SortingData, background_tasks: BackgroundTasks status="running", data_source_id=data_source.id, user_id=user.id, - metadata=str(payload), + metadata=str(data.json()), output_destination=data.output_destination, output_path=data.output_path, ) # Run sorting job - background_tasks.add_task(sorting_background_task, payload, run_identifier=run_identifier) + background_tasks.add_task( + sorting_background_task, + payload=data.dict(), + run_identifier=run_identifier + ) except Exception as e: print(e)