-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: document the workchain context nesting
- Loading branch information
Showing
2 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
...urce/topics/workflows/include/snippets/workchains/run_workchain_submit_parallel_nested.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# -*- coding: utf-8 -*- | ||
from aiida.engine import WorkChain | ||
|
||
|
||
class SomeWorkChain(WorkChain): | ||
|
||
@classmethod | ||
def define(cls, spec): | ||
super().define(spec) | ||
spec.outline( | ||
cls.submit_workchains, | ||
cls.inspect_workchains, | ||
) | ||
|
||
def submit_workchains(self): | ||
for i in range(3): | ||
future = self.submit(SomeWorkChain) | ||
key = f'workchain.sub{i}' | ||
self.to_context(**{key: future}) | ||
|
||
def inspect_workchains(self): | ||
for i in range(3): | ||
assert self.ctx.workchain[f'sub{i}'].is_finished_ok |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters