From fb3ff0148037e3e20038e828682ccf2e2537e0e4 Mon Sep 17 00:00:00 2001 From: Manjunath PV Date: Thu, 7 Sep 2023 14:28:56 +0530 Subject: [PATCH] minor bug & test case fix for qelecton feature --- CHANGELOG.md | 5 ++++ covalent_ui/api/v1/data_layer/electron_dal.py | 4 +++- covalent_ui/api/v1/models/electrons_model.py | 2 +- .../end_points/summary_test.py | 5 ---- .../utils/assert_data/electrons.py | 23 +------------------ 5 files changed, 10 insertions(+), 29 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c7b243dc..7d6c81e32 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [UNRELEASED] +### Fixed + +- Formatted executor block under Qelectron job details to handle any class-type values +- Fixed test-cases to handle latest pydantic version changes + ### Changed - Raised the minimum version of Pydantic from 1.10.1 to 2.1.1 in `requirements.txt` diff --git a/covalent_ui/api/v1/data_layer/electron_dal.py b/covalent_ui/api/v1/data_layer/electron_dal.py index 9a8aee7f5..25c61271d 100644 --- a/covalent_ui/api/v1/data_layer/electron_dal.py +++ b/covalent_ui/api/v1/data_layer/electron_dal.py @@ -199,7 +199,9 @@ def get_job_detail(self, dispatch_id, electron_id, job_id) -> JobDetailsResponse "name": selected_job["qexecutor"]["name"] if "qexecutor" in selected_job and "name" in selected_job["qexecutor"] else None, - "executor": str(selected_job["qexecutor"]) if "qexecutor" in selected_job else None, + "executor": str(selected_job["qexecutor"]) + if "qexecutor" in selected_job + else None, }, } diff --git a/covalent_ui/api/v1/models/electrons_model.py b/covalent_ui/api/v1/models/electrons_model.py index 586cb97f7..79deab719 100644 --- a/covalent_ui/api/v1/models/electrons_model.py +++ b/covalent_ui/api/v1/models/electrons_model.py @@ -67,7 +67,7 @@ class ElectronResponse(BaseModel): runtime: Union[int, None] = None description: Union[str, None] = None qelectron_data_exists: bool = False - qelectron: dict = None + qelectron: Union[dict, None] = None class ElectronFileResponse(BaseModel): diff --git a/tests/covalent_ui_backend_tests/end_points/summary_test.py b/tests/covalent_ui_backend_tests/end_points/summary_test.py index 007366e7e..c6c8bb6d2 100644 --- a/tests/covalent_ui_backend_tests/end_points/summary_test.py +++ b/tests/covalent_ui_backend_tests/end_points/summary_test.py @@ -127,11 +127,6 @@ def test_list_invalid_count(): query_data=test_data["request_data"]["query"], ) assert response.status_code == test_data["status_code"] - if "response_data" in test_data: - api_response = response.json() - mock_response = test_data["response_data"] - # del api_response["detail"][0]["url"] - assert api_response == mock_response def test_list_search(): diff --git a/tests/covalent_ui_backend_tests/utils/assert_data/electrons.py b/tests/covalent_ui_backend_tests/utils/assert_data/electrons.py index 6aeaa1586..1df3a31cb 100644 --- a/tests/covalent_ui_backend_tests/utils/assert_data/electrons.py +++ b/tests/covalent_ui_backend_tests/utils/assert_data/electrons.py @@ -277,28 +277,7 @@ def seed_electron_data(): }, "executor": { "name": "Simulator", - "executor": { - "persist_data": True, - "qnode_device_import_path": "pennylane.devices.default_qubit:DefaultQubit", - "qnode_device_shots": None, - "qnode_device_wires": 5, - "pennylane_active_return": True, - "device": "default.qubit", - "parallel": "thread", - "workers": 10, - "shots": 0, - "name": "Simulator", - "_backend": { - "persist_data": True, - "qnode_device_import_path": "pennylane.devices.default_qubit:DefaultQubit", - "qnode_device_shots": None, - "qnode_device_wires": 5, - "pennylane_active_return": True, - "device": "default.qubit", - "num_threads": 10, - "name": "BaseThreadPoolQExecutor", - }, - }, + "executor": "{'persist_data': True, 'qnode_device_import_path': 'pennylane.devices.default_qubit:DefaultQubit', 'qnode_device_shots': None, 'qnode_device_wires': 5, 'pennylane_active_return': True, 'device': 'default.qubit', 'parallel': 'thread', 'workers': 10, 'shots': 0, 'name': 'Simulator', '_backend': {'persist_data': True, 'qnode_device_import_path': 'pennylane.devices.default_qubit:DefaultQubit', 'qnode_device_shots': None, 'qnode_device_wires': 5, 'pennylane_active_return': True, 'device': 'default.qubit', 'num_threads': 10, 'name': 'BaseThreadPoolQExecutor'}}", }, }, },