Skip to content

Commit

Permalink
More deprecated APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
unkcpz committed Nov 20, 2022
1 parent 4e6df77 commit b8c50d8
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 37 deletions.
2 changes: 1 addition & 1 deletion aiidalab_qe/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

import ipywidgets as ipw
import traitlets
from aiida.cmdline.utils.query.calculation import CalculationQueryBuilder
from aiida.orm import load_node
from aiida.tools.query.calculation import CalculationQueryBuilder


class WorkChainSelector(ipw.HBox):
Expand Down
5 changes: 3 additions & 2 deletions aiidalab_qe/report.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from aiida.orm import WorkChainNode
from aiida.plugins import WorkflowFactory

PwBaseWorkChain = WorkflowFactory("quantumespresso.pw.base")
Expand Down Expand Up @@ -25,8 +26,8 @@
}


def _generate_report_dict(qeapp_wc):
builder_parameters = qeapp_wc.get_extra("builder_parameters", {})
def _generate_report_dict(qeapp_wc: WorkChainNode):
builder_parameters = qeapp_wc.base.extras.get("builder_parameters", {})

# Properties
run_relax = builder_parameters.get("relax_type") != "none"
Expand Down
35 changes: 23 additions & 12 deletions aiidalab_qe/setup_codes.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import ipywidgets as ipw
import traitlets
from aiida.common.exceptions import NotExistent
from aiida.orm import InstalledCode, load_code, load_computer
from aiida.orm import load_code
from filelock import FileLock, Timeout

from aiidalab_qe.widgets import ProgressBar
Expand Down Expand Up @@ -67,18 +67,29 @@ def _setup_code(code_name, computer_name="localhost"):
try:
load_code(f"{code_name}-{QE_VERSION}@localhost")
except NotExistent:
localhost = load_computer(computer_name)
code = InstalledCode(
computer=localhost,
filepath_executable=CONDA_ENV_PREFIX.joinpath(
"bin", f"{code_name}.x"
).as_posix(),
default_calc_job_plugin=f"quantumespresso.{code_name}",
prepend_text=f'eval "$(conda shell.posix hook)"\nconda activate {CONDA_ENV_PREFIX}\nexport OMP_NUM_THREADS=1',
run(
[
"verdi",
"code",
"create",
"core.code.installed",
"--non-interactive",
"--label",
f"{code_name}-{QE_VERSION}",
"--description",
f"{code_name}.x ({QE_VERSION}) setup by AiiDAlab.",
"--default-calc-job-plugin",
f"quantumespresso.{code_name}",
"--computer",
computer_name,
"--prepend-text",
f'eval "$(conda shell.posix hook)"\nconda activate {CONDA_ENV_PREFIX}\nexport OMP_NUM_THREADS=1',
"--filepath-executable",
CONDA_ENV_PREFIX.joinpath("bin", f"{code_name}.x"),
],
check=True,
capture_output=True,
)
code.label = f"{code_name}-{QE_VERSION}"
code.description = f"{code_name}.x ({QE_VERSION} setup by AiiDAlab)"
code.store()
else:
raise RuntimeError(f"Code {code_name} (v{QE_VERSION}) is already setup!")

Expand Down
14 changes: 8 additions & 6 deletions aiidalab_qe/steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@
)
from aiidalab_qe_workchain import QeAppWorkChain

StructureData = DataFactory("structure")
Float = DataFactory("float")
Dict = DataFactory("dict")
Str = DataFactory("str")
StructureData = DataFactory("core.structure")
Float = DataFactory("core.float")
Dict = DataFactory("core.dict")
Str = DataFactory("core.str")


class WorkChainSettings(ipw.VBox):
Expand Down Expand Up @@ -768,7 +768,9 @@ def _observe_process(self, change):
process_node = change["new"]
if process_node is not None:
self.input_structure = process_node.inputs.structure
builder_parameters = process_node.get_extra("builder_parameters", None)
builder_parameters = process_node.base.extras.get(
"builder_parameters", None
)
if builder_parameters is not None:
self.set_selected_codes(builder_parameters)
self._update_state()
Expand Down Expand Up @@ -895,7 +897,7 @@ def update_builder(buildy, resources, npools):
with self.hold_trait_notifications():
self.process = submit(builder)
# Set the builder parameters on the work chain
self.process.set_extra("builder_parameters", parameters)
self.process.base.extras.set("builder_parameters", parameters)

def reset(self):
with self.hold_trait_notifications():
Expand Down
4 changes: 2 additions & 2 deletions aiidalab_qe/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,15 +295,15 @@ def _fetch_output(self, calcjob):
assert isinstance(calcjob, CalcJobNode)
if "retrieved" in calcjob.outputs:
try:
self.filename = calcjob.attributes["output_filename"]
self.filename = calcjob.base.attributes.get("output_filename")
with calcjob.outputs.retrieved.open(self.filename) as f:
return f.read().splitlines()
except OSError:
return list()

elif "remote_folder" in calcjob.outputs:
try:
fn_out = calcjob.attributes["output_filename"]
fn_out = calcjob.base.attributes.get("output_filename")
self.filename = fn_out
with NamedTemporaryFile() as tmpfile:
calcjob.outputs.remote_folder.getfile(fn_out, tmpfile.name)
Expand Down
26 changes: 12 additions & 14 deletions qe.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "f17c6bb582de487ea6f9196a1b315165",
"model_id": "3dd5155dd0b74226be9eeddecf4621ed",
"version_major": 2,
"version_minor": 0
},
Expand All @@ -86,24 +86,22 @@
"name": "stderr",
"output_type": "stream",
"text": [
"/opt/conda/lib/python3.9/site-packages/aiida/cmdline/utils/query/calculation.py:15: AiidaDeprecationWarning: This module is deprecated, use `aiida.tools.query.calculation` instead. (this will be removed in v3)\n",
" warn_deprecation('This module is deprecated, use `aiida.tools.query.calculation` instead.', version=3)\n",
"/opt/conda/lib/python3.9/site-packages/aiida/cmdline/utils/query/formatting.py:15: AiidaDeprecationWarning: This module is deprecated, use `aiida.tools.query.formatting` instead. (this will be removed in v3)\n",
" warn_deprecation('This module is deprecated, use `aiida.tools.query.formatting` instead.', version=3)\n",
"/opt/conda/lib/python3.9/site-packages/aiida/plugins/entry_point.py:310: AiidaDeprecationWarning: The entry point `structure` is deprecated. Please replace it with `core.structure`. (this will be removed in v3)\n",
" warn_deprecation(\n",
"/opt/conda/lib/python3.9/site-packages/aiida/plugins/entry_point.py:310: AiidaDeprecationWarning: The entry point `float` is deprecated. Please replace it with `core.float`. (this will be removed in v3)\n",
" warn_deprecation(\n",
"/opt/conda/lib/python3.9/site-packages/aiida/plugins/entry_point.py:310: AiidaDeprecationWarning: The entry point `dict` is deprecated. Please replace it with `core.dict`. (this will be removed in v3)\n",
" warn_deprecation(\n",
"/opt/conda/lib/python3.9/site-packages/aiida/plugins/entry_point.py:310: AiidaDeprecationWarning: The entry point `str` is deprecated. Please replace it with `core.str`. (this will be removed in v3)\n",
" warn_deprecation(\n"
"/opt/conda/lib/python3.9/site-packages/aiida/orm/nodes/data/code/legacy.py:121: AiidaDeprecationWarning: This property is deprecated, use the `Code.is_hidden` property instead. (this will be removed in v3)\n",
" warn_deprecation('This property is deprecated, use the `Code.is_hidden` property instead.', version=3)\n",
"/opt/conda/lib/python3.9/site-packages/aiida/orm/nodes/data/code/legacy.py:121: AiidaDeprecationWarning: This property is deprecated, use the `Code.is_hidden` property instead. (this will be removed in v3)\n",
" warn_deprecation('This property is deprecated, use the `Code.is_hidden` property instead.', version=3)\n",
"/opt/conda/lib/python3.9/site-packages/aiida/orm/nodes/data/code/legacy.py:121: AiidaDeprecationWarning: This property is deprecated, use the `Code.is_hidden` property instead. (this will be removed in v3)\n",
" warn_deprecation('This property is deprecated, use the `Code.is_hidden` property instead.', version=3)\n",
"/opt/conda/lib/python3.9/site-packages/aiida/orm/nodes/data/code/legacy.py:121: AiidaDeprecationWarning: This property is deprecated, use the `Code.is_hidden` property instead. (this will be removed in v3)\n",
" warn_deprecation('This property is deprecated, use the `Code.is_hidden` property instead.', version=3)\n",
"/opt/conda/lib/python3.9/site-packages/aiida/orm/nodes/data/code/legacy.py:121: AiidaDeprecationWarning: This property is deprecated, use the `Code.is_hidden` property instead. (this will be removed in v3)\n",
" warn_deprecation('This property is deprecated, use the `Code.is_hidden` property instead.', version=3)\n"
]
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "ce3c3a2503cb4e359ff3e3b255a1db7b",
"model_id": "02aea8ac0d0f47e6b997d54f41a9ecf6",
"version_major": 2,
"version_minor": 0
},
Expand Down

0 comments on commit b8c50d8

Please sign in to comment.