From f3a86bb8fc75164297ac1edc517c5d3f3c5a4fbc Mon Sep 17 00:00:00 2001 From: superstar54 Date: Wed, 10 Apr 2024 17:49:03 +0000 Subject: [PATCH 1/2] check if the code is installed and usable --- src/aiidalab_qe/app/submission/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/aiidalab_qe/app/submission/__init__.py b/src/aiidalab_qe/app/submission/__init__.py index 478ebbf02..ea4104170 100644 --- a/src/aiidalab_qe/app/submission/__init__.py +++ b/src/aiidalab_qe/app/submission/__init__.py @@ -347,7 +347,11 @@ def _get_code_uuid(code): with self.hold_trait_notifications(): for name, code in self.codes.items(): - code.value = _get_code_uuid(codes.get(name)) + # check if the code is installed and usable + # note: if code is imported from another user, it is not usable and thus will not be + # treated as an option in the ComputationalResourcesWidget. + if _get_code_uuid(codes.get(name)) in code.code_select_dropdown.options: + code.value = _get_code_uuid(codes.get(name)) def update_codes_display(self): """Hide code if no related property is selected.""" From 079fde7883da132ba076a307795b60e4643120be Mon Sep 17 00:00:00 2001 From: superstar54 Date: Wed, 10 Apr 2024 20:45:31 +0000 Subject: [PATCH 2/2] fix code options and unit test --- src/aiidalab_qe/app/submission/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/aiidalab_qe/app/submission/__init__.py b/src/aiidalab_qe/app/submission/__init__.py index ea4104170..9d0ff726b 100644 --- a/src/aiidalab_qe/app/submission/__init__.py +++ b/src/aiidalab_qe/app/submission/__init__.py @@ -350,7 +350,8 @@ def _get_code_uuid(code): # check if the code is installed and usable # note: if code is imported from another user, it is not usable and thus will not be # treated as an option in the ComputationalResourcesWidget. - if _get_code_uuid(codes.get(name)) in code.code_select_dropdown.options: + code_options = [o[1] for o in self.pw_code.code_select_dropdown.options] + if _get_code_uuid(codes.get(name)) in code_options: code.value = _get_code_uuid(codes.get(name)) def update_codes_display(self):