From f4d0add9457227e827411cbe61008f89a8adf2a7 Mon Sep 17 00:00:00 2001 From: Stanislaw Malinowski Date: Wed, 27 Mar 2024 09:19:14 +0000 Subject: [PATCH] solve cli error --- .vscode/launch.json | 9 ++++----- .vscode/settings.json | 6 ++++-- src/blueapi/cli/cli.py | 8 ++++---- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 9d2529db5..b31244175 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -35,7 +35,7 @@ }, { "name": "Run Service", - "type": "python", + "type": "debugpy", "request": "launch", "justMyCode": false, "module": "blueapi.cli", @@ -45,7 +45,7 @@ }, { "name": "Controller (get plans)", - "type": "python", + "type": "debugpy", "request": "launch", "justMyCode": false, "module": "blueapi.cli", @@ -56,7 +56,7 @@ }, { "name": "Controller (get devices)", - "type": "python", + "type": "debugpy", "request": "launch", "justMyCode": false, "module": "blueapi.cli", @@ -67,7 +67,7 @@ }, { "name": "Controller (sleep)", - "type": "python", + "type": "debugpy", "request": "launch", "justMyCode": false, "module": "blueapi.cli", @@ -75,7 +75,6 @@ "controller", "run", "sleep", - "-p", "{\"time\": 5}" ] } diff --git a/.vscode/settings.json b/.vscode/settings.json index 8bf638004..a21bc3399 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -3,14 +3,16 @@ "python.linting.flake8Enabled": true, "python.linting.mypyEnabled": true, "python.linting.enabled": true, - "python.testing.pytestArgs": [], + "python.testing.pytestArgs": [ + "tests" + ], "python.testing.unittestEnabled": false, "python.testing.pytestEnabled": true, "python.formatting.provider": "black", "python.languageServer": "Pylance", "editor.formatOnSave": true, "editor.codeActionsOnSave": { - "source.organizeImports": true + "source.organizeImports": "explicit" }, "esbonio.server.enabled": true, "esbonio.sphinx.confDir": "", diff --git a/src/blueapi/cli/cli.py b/src/blueapi/cli/cli.py index 0a8216ab9..23c78bba3 100644 --- a/src/blueapi/cli/cli.py +++ b/src/blueapi/cli/cli.py @@ -183,13 +183,13 @@ def store_finished_event(event: WorkerEvent) -> None: finished_event.append(event) parameters = json.loads(parameters) or "{}" - schema: PlanModel = client.get_plan(name) + plan_model: PlanModel = client.get_plan(name) progress_tracking = f"Trying to run plan: {name}." print(progress_tracking) try: text = "Checking supplied parameters against expected parameters..." print(text) - validated_data = parse_obj_as(type(schema), parameters) + validated_data = parse_obj_as(type(plan_model.parameter_schema), parameters) print("Plan params validation successful:", validated_data) except ValidationError as e: errors = e.errors() @@ -199,7 +199,7 @@ def store_finished_event(event: WorkerEvent) -> None: print(f"Input validation failed: {formatted_errors}") # Handle the case where the parameters are invalid according to the PlanModel - s = schema.parameter_schema + s = plan_model.parameter_schema if s: expected_params = s.get("properties") print( @@ -208,7 +208,7 @@ def store_finished_event(event: WorkerEvent) -> None: ) return - task = Task(name=name, params=json.loads(parameters)) + task = Task(name=name, params=parameters) resp = client.create_task(task) task_id = resp.task_id