Skip to content

Commit

Permalink
Merge pull request #535 from aiidalab/feature/code_entrypoint
Browse files Browse the repository at this point in the history
Adding dynamic visualization of codes
  • Loading branch information
mikibonacci authored Oct 27, 2023
2 parents e0f0e7e + ffce70f commit b731978
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
10 changes: 5 additions & 5 deletions src/aiidalab_qe/app/submission/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,10 +308,10 @@ def _observe_state(self, change):
with self.hold_trait_notifications():
self.submit_button.disabled = change["new"] != self.State.CONFIGURED

@tl.observe("previous_step_state")
@tl.observe("previous_step_state", "input_parameters")
def _observe_input_structure(self, _):
self._update_state()
self.udpate_codes_visibility()
self.update_codes_display()

@tl.observe("process")
def _observe_process(self, change):
Expand Down Expand Up @@ -348,18 +348,18 @@ def _get_code_uuid(code):
for name, code in self.codes.items():
code.value = _get_code_uuid(codes.get(name))

def udpate_codes_visibility(self):
def update_codes_display(self):
"""Hide code if no related property is selected."""
# hide all codes except pw
for name, code in self.codes.items():
if name == "pw":
continue
code.layout.visibility = "hidden"
code.layout.display = "none"
properties = self.input_parameters.get("workchain", {}).get("properties", [])
# show the code if the related property is selected.
for identifer in properties:
for code in self.code_entries.get(identifer, {}).values():
code.layout.visibility = "visible"
code.layout.display = "block"

def submit(self, _=None):
"""Submit the work chain with the current inputs."""
Expand Down
12 changes: 6 additions & 6 deletions tests/test_codes.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@ def test_set_selected_codes(submit_app_generator):
assert new_submit_step.get_selected_codes() == submit_step.get_selected_codes()


def test_udpate_codes_visibility():
"""Test udpate_codes_visibility method.
def test_update_codes_display():
"""Test update_codes_display method.
If the workchain property is not selected, the related code should be hidden.
"""
from aiidalab_qe.app.submission import SubmitQeAppWorkChainStep

submit = SubmitQeAppWorkChainStep(qe_auto_setup=False)
submit.udpate_codes_visibility()
assert submit.codes["dos"].layout.visibility == "hidden"
submit.update_codes_display()
assert submit.codes["dos"].layout.display == "none"
submit.input_parameters = {"workchain": {"properties": ["pdos"]}}
submit.udpate_codes_visibility()
assert submit.codes["dos"].layout.visibility == "visible"
submit.update_codes_display()
assert submit.codes["dos"].layout.display == "block"


def test_identify_submission_blockers(app):
Expand Down

0 comments on commit b731978

Please sign in to comment.