Skip to content

Commit

Permalink
solve cli error
Browse files Browse the repository at this point in the history
  • Loading branch information
stan-dot committed Mar 27, 2024
1 parent bec80e0 commit f4d0add
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
9 changes: 4 additions & 5 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
},
{
"name": "Run Service",
"type": "python",
"type": "debugpy",
"request": "launch",
"justMyCode": false,
"module": "blueapi.cli",
Expand All @@ -45,7 +45,7 @@
},
{
"name": "Controller (get plans)",
"type": "python",
"type": "debugpy",
"request": "launch",
"justMyCode": false,
"module": "blueapi.cli",
Expand All @@ -56,7 +56,7 @@
},
{
"name": "Controller (get devices)",
"type": "python",
"type": "debugpy",
"request": "launch",
"justMyCode": false,
"module": "blueapi.cli",
Expand All @@ -67,15 +67,14 @@
},
{
"name": "Controller (sleep)",
"type": "python",
"type": "debugpy",
"request": "launch",
"justMyCode": false,
"module": "blueapi.cli",
"args": [
"controller",
"run",
"sleep",
"-p",
"{\"time\": 5}"
]
}
Expand Down
6 changes: 4 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "",
Expand Down
8 changes: 4 additions & 4 deletions src/blueapi/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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(
Expand All @@ -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
Expand Down

0 comments on commit f4d0add

Please sign in to comment.