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

🔀 REFACTOR: workchain subprocess queing #5838

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

chrisjsewell
Copy link
Member

@chrisjsewell chrisjsewell commented Dec 14, 2022

A proposal to change how to add a subprocess in a workchain step
(sidenote: this PR is fully back-compatible)

On the user side, basically I think we should replace the use of self.submit/self.to_context/ToContext, with simply self.queue_subprocess.
This better describes what we are actually intending the user to do:

define a (sub/child)process, which will be run until termination, before the next step of the workchain commences, and whose resultant node/outputs will be available to the user in the next step, via a key on the workchain ctx

e.g. change this:

            def step(self):
                self.to_context(child1=append_(self.submit(SimpleWc, val=Int(1))))
                return ToContext(**{'nested.key.child2': self.submit(SimpleWc, val=Int(1))})

to this:

            def step(self):
                self.queue_subprocess("child1", SimpleWc, {"val": Int(1)}, ctx_append=True)
                self.queue_subprocess("nested.key.child2", SimpleWc, {"val": Int(1)})

On the internal code side:

  1. renamed some things to not use the term awaitable, which has a very definite meaning in python/plumpy (https://docs.python.org/3/library/collections.abc.html#collections.abc.Awaitable, https://docs.python.org/3/library/typing.html#typing.Awaitable) and instead refer to "process references"

  2. Use a dataclass instead of an AttributeDict, since this has various issues for type safety


Notes:

  • This currently is fully backward-compatible; it doesn't actually remove any of self.submit/self.to_context/ToContext.
    deprecation warnings could be added though.

  • Currently self.queue_subprocess works exactly the same as if you did self.submit then self.to_context.
    I don't think this technically correct, though, since I think subprocess submission should only really happen after all the code in the step has been run. Otherwise, you can submit a process, then except the step, and now you have a subprocess running that you don't actually want.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant