Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement optimade widget in Qeapp #632

Merged
merged 4 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ install_requires =
aiida-core~=2.2,<3
Jinja2~=3.0
aiida-quantumespresso~=4.4.0
aiidalab-widgets-base~=2.1
aiidalab-widgets-base[optimade]~=2.2.0a0
aiida-pseudo~=1.4
filelock~=3.8
importlib-resources~=5.2
Expand Down
16 changes: 7 additions & 9 deletions src/aiidalab_qe/app/structure/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import aiida
import ipywidgets as ipw
import traitlets
import traitlets as tl
from aiidalab_widgets_base import (
BasicCellEditor,
BasicStructureEditor,
Expand Down Expand Up @@ -37,8 +37,6 @@
("ETFA molecule", file_path / "examples" / "ETFA.xyz"),
]

OptimadeQueryWidget.title = "OPTIMADE" # monkeypatch


class StructureSelectionStep(ipw.VBox, WizardAppWidgetStep):
"""Integrated widget for the selection and edition of structure.
Expand All @@ -47,8 +45,8 @@ class StructureSelectionStep(ipw.VBox, WizardAppWidgetStep):
structure importers and the structure editors can be extended by plugins.
"""

structure = traitlets.Instance(aiida.orm.StructureData, allow_none=True)
confirmed_structure = traitlets.Instance(aiida.orm.StructureData, allow_none=True)
structure = tl.Instance(aiida.orm.StructureData, allow_none=True)
confirmed_structure = tl.Instance(aiida.orm.StructureData, allow_none=True)

def __init__(self, description=None, **kwargs):
importers = [
Expand Down Expand Up @@ -121,7 +119,7 @@ def __init__(self, description=None, **kwargs):
**kwargs,
)

@traitlets.default("state")
@tl.default("state")
def _default_state(self):
return self.State.INIT

Expand All @@ -137,7 +135,7 @@ def _update_state(self):
else:
self.state = self.State.SUCCESS

@traitlets.observe("structure")
@tl.observe("structure")
def _observe_structure(self, change):
structure = change["new"]
with self.hold_trait_notifications():
Expand All @@ -148,12 +146,12 @@ def _observe_structure(self, change):
self.structure_name_text.value = str(self.structure.get_formula())
self._update_state()

@traitlets.observe("confirmed_structure")
@tl.observe("confirmed_structure")
def _observe_confirmed_structure(self, _):
with self.hold_trait_notifications():
self._update_state()

@traitlets.observe("state")
@tl.observe("state")
def _observe_state(self, change):
with self.hold_trait_notifications():
state = change["new"]
Expand Down
Loading