-
Notifications
You must be signed in to change notification settings - Fork 192
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
Allow WorkChains to expose the inputs/outputs of a sub WorkChain #660
Comments
Dear All, this new topic rises a question I also had in mind: What is best way to achieve modular structure for workflows? For example, if the same scf-cycle is called through workflow outline, |
Note: This is a continuation of the discussion on PR #544. |
@vdikan, can you explain your use case in a bit more detail? Are you trying to use the same SCF sub-workflow in different workflows, or different SCF sub-workflows in the same workflow? The Another requirement for modular WFs is that you can easily change which sub-WF is actually called. For example, you might want to change which code calculates some value, but then the rest of the workflow remains the same. For this purpose I created #640, so that you can give a workflow class as input. I'm planning to write up how modular WFs are done in my tight-binding extraction project. If / when all the features for that are in |
@sphuber Another note on the "wrapping" (namespace) of input variables: I found some cases where it's quite desirable to have both "wrapped" and "unwrapped" inputs, from the same Sub-WF. The reason for this is that there are some inputs (e.g. the structure) which are shared among many WFs, and others which are specific to one. In my "working" branch, I implemented it such that having multiple |
@greschd I guess all that you mention is needed, as elementary workflows tend to be "building blocks" for more sophisticated ones. Consider such a straightforward example: So, a few things come to mind:
|
Ok, I think these changes (together with #640) can help you with 1. and 2. I've never looked into the graph generation, so I wouldn't know how hard this would be to do. |
@greschd Thanks a lot! |
@vdikan That code is currently in our group's gitlab instance. I'm planning on publishing it / moving it to github some time in September. In the meantime I can privately send you some part that should show the workflow design principles. @sphuber Another feature that would be great is to not only have an
instead of
which is an anti-pattern (that I've found myself doing) because every time SubWF adds an input you have to go through the Workflows that wrap it. |
@sphuber You wrote "expose inputs/outputs" in the title: I think we haven't talked about outputs before, but it seems like a great idea. Is there a function to simultaneously do
and in the step
where It's not quite clear to me whether the |
No we didn't, but when writing the implementation I realized that when we had been discussing Originally I was thinking that when defining Regarding the namespace, it might make sense to then use that namespace as a prefix when generating the output return links. For example
What do you think? Do you see any problems here? |
Yeah, I think that makes a lot of sense. I'm a bit concerned about automatically attaching the outputs. How do we determine which sub-workflow to actually take the outputs from? We could go through the CALL links, but what happens if there's more than one such sub-workflow? Something like this could be problematic: in define:
and in the step
I think we would want something like
So, maybe we need the option to "override" the namespace when actually attaching the outputs? |
Automatically adding the outputs (if there's only a single sub-wf of this type) could be an option given to the |
Yeah, you are right about the automatic adding. If you run multiple instances of the same sub workchain it becomes unclear which outputs to automatically link. So in your example:
the |
Actually no it does.
The output calls:
Will yield the following outputs:
|
Well, my initial idea was to still have it in |
Yeah, that makes sense.. but this raises another question: What should we do if the names of the outputs are determined only at runtime? Say you want to run N instances of some workchain, and put the output for each in a separate "namespace". In the spec you can't really have all outputs because it's not known at |
Maybe there should be a separate keyword for this kind of thing.. or a special placeholder/dynamic namespace.
and then
which gives
|
So there are sort of two ways in which we want to use "namespace" in the |
So maybe this:
and then
I don't really know what should happen to the |
Hmm it is becoming kind of complex now. I went through several iterations of the namespaced ports for the spec and am finishing up on the current one. I will push it soon to my fork so you can already have a look at the way it is setup now. |
Yeah I agree... but maybe we don't need to do anything about the ports here? For this |
The basic functionality has now been implemented and merged in PR #1170 |
A common design pattern that occurs when developing
WorkChains
is that a certainWorkChain
is wrapped by anotherWorkChain
. As a result the wrappingWorkChain
also needs to add the exact same input port as theWorkChain
that it will be calling. For aWorkChain
that wraps many otherWorkChains
this can become quite messy. We need a way for a wrappingWorkChain
to "expose" the inputs of the subWorkChain
that it calls under the hood.The text was updated successfully, but these errors were encountered: