Skip to content

Commit 20ce658

Browse files
authored
♻️ refactor: Replace ToContext with dicts in return values #18
Replace the usage of ToContext with standard Python dictionaries in function return values. This simplifies the data structure, removes unnecessary dependency on the ToContext wrapper for simple returns, and improves code readability.
1 parent d15dfff commit 20ce658

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

src/aiida_epw/workflows/prep.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from aiida import orm
66
from aiida.common import AttributeDict
77

8-
from aiida.engine import WorkChain, ToContext, if_
8+
from aiida.engine import WorkChain, if_
99
from aiida_quantumespresso.workflows.ph.base import PhBaseWorkChain
1010
from aiida_quantumespresso.workflows.protocols.utils import ProtocolMixin
1111

@@ -378,7 +378,7 @@ def run_wannier90(self):
378378
workchain_node = self.submit(w90_class, **inputs)
379379
self.report(f"launching {w90_class.get_name()}<{workchain_node.pk}>")
380380

381-
return ToContext(workchain_w90_bands=workchain_node)
381+
return {'workchain_w90_bands': workchain_node}
382382

383383
def inspect_wannier90(self):
384384
"""Verify that the wannier90 workflow finished successfully."""
@@ -411,7 +411,7 @@ def run_ph(self):
411411
workchain_node = self.submit(PhBaseWorkChain, **inputs)
412412
self.report(f"launching PhBaseWorkChain<{workchain_node.pk}>")
413413

414-
return ToContext(workchain_ph=workchain_node)
414+
return {'workchain_ph': workchain_node}
415415

416416
def inspect_ph(self):
417417
"""Verify that the `PhBaseWorkChain` finished successfully."""
@@ -463,7 +463,7 @@ def run_epw(self):
463463
f"launching EpwBaseWorkChain<{workchain_node.pk}> in transformation mode"
464464
)
465465

466-
return ToContext(workchain_epw=workchain_node)
466+
return {'workchain_epw': workchain_node}
467467

468468
def inspect_epw(self):
469469
"""Verify that the `EpwBaseWorkChain` finished successfully."""

src/aiida_epw/workflows/supercon.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from aiida import orm
66
from aiida.common import AttributeDict
7-
from aiida.engine import WorkChain, ToContext, while_, if_, append_
7+
from aiida.engine import WorkChain, while_, if_, append_
88

99
from aiida_quantumespresso.workflows.protocols.utils import ProtocolMixin
1010

@@ -384,7 +384,7 @@ def run_conv(self):
384384
f"launching EpwBaseWorkChain<{workchain_node.pk}> in a2f mode: convergence #{self.ctx.iteration}"
385385
)
386386

387-
return ToContext(epw_interp=append_(workchain_node))
387+
return {'epw_interp': append_(workchain_node)}
388388

389389
def inspect_conv(self):
390390
"""Verify that the EpwBaseWorkChain in interpolation mode finished successfully."""
@@ -440,7 +440,7 @@ def run_final_epw_iso(self):
440440
f"launching EpwBaseWorkChain<{workchain_node.pk}> in isotropic mode"
441441
)
442442

443-
return ToContext(final_epw_iso=workchain_node)
443+
return {'final_epw_iso': workchain_node}
444444

445445
def inspect_final_epw_iso(self):
446446
"""Verify that the final EpwBaseWorkChain in isotropic mode finished successfully."""
@@ -469,7 +469,7 @@ def run_final_epw_aniso(self):
469469
f"launching EpwBaseWorkChain<{workchain_node.pk}> in anisotropic mode"
470470
)
471471

472-
return ToContext(final_epw_aniso=workchain_node)
472+
return {'final_epw_aniso': workchain_node}
473473

474474
def inspect_final_epw_aniso(self):
475475
"""Verify that the final EpwBaseWorkChain in anisotropic mode finished successfully."""

0 commit comments

Comments
 (0)