-
Notifications
You must be signed in to change notification settings - Fork 191
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 to define link label for CALL
links
#3003
Allow to define link label for CALL
links
#3003
Conversation
03cf7c2
to
73bd4d5
Compare
spec.input('{}.label'.format(spec.metadata_key), valid_type=six.string_types[0], required=False, | ||
help='Label to set on the process node.') | ||
spec.input('{}.call_link_label'.format(spec.metadata_key), valid_type=six.string_types[0], default='CALL', | ||
help='The label to use for the `CALL` link if the process is called by another process.') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, the process being called sets the label of the link - not the one calling?
From a naive perspective this seems a bit strange since the calling process is the one "acting"... but maybe this comes from a specific use case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is simply due to the user-facing API. A user never explicitly adds a CALL
link, but this is done automatically. Currently there is two ways:
- Through
self.submit
in aWorkChain
- Or when calling another process from within a
workfunction
The only way for the user to pass the desired link label is through themetadata
.
Now note also that it is never the "parent" process literally calling the child. It just so happens that the child will be in "the scope" of the parent. Since this scope always corresponds to a unique parent, we can use this fact to set the correctCALL
link in the construction of the child process. So as you can see, the creation of theCALL
link was already happening this way, I am merely adding the possibility for the user to change the link label through themetadata
input.
I will add a test that also demonstrates and tests the example of something being called from within a work function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, just from a logical point of view, I still think that both of the following statements are statements a user may want to make:
- When this process calls other processes, the link label should be X
- When this process is called by other processes, the link label should be Y
We may choose to only support one of them in order not to run into conflicts, but I still find 1. more "natural".
Anyhow, perhaps the example will show which one is more practically useful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I see the examples are still "abstract".
Can you describe (just in a comment) a real-life example to understand what these labels are used for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Imagine in a WorkChain
I launch multiple CalcJobs
. Currently there is no way to set the CALL
link label, so they will all have CALL
as default. For example calling verdi process show
on such a work chain will show:
Called PK Type
--------- ------ ----------------
CALL_CALC 138252 CalcJobNode
CALL_CALC 133813 CalcJobNode
CALL_CALC 127091 CalcJobNode
CALL_CALC 120598 CalcJobNode
CALL_CALC 120594 CalcFunctionNode
This is not necessarily bad, but with this new feature you can have it such that it will be:
Called PK Type
--------- ------ ----------------
create_kpoints 120594 CalcFunctionNode
iteration_01 120598 CalcJobNode
iteration_02 127091 CalcJobNode
iteration_03 133813 CalcJobNode
iteration_04 138252 CalcJobNode
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this example makes total sense, and I understand now that it is actually the calling process that defines the label (because it will pass the label when creating the processes it calls).
I believe it was a bit too late in the day when I did the review ;-)
73bd4d5
to
a5bd97b
Compare
@ltalirz I have added two more tests to verify that calling a process function from a work chain and another process function also works when passing the label in the metadata. |
f57cda3
to
83bdc1c
Compare
The `Process` class defines a new metadata input `call_link_label` that when set for a process that is called by another, will be used as the link label for the `CALL` link, instead of the default.
83bdc1c
to
43f91e3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @sphuber !
One last comment (not a problem): This means a Process class can define a default CALL label that is different from the standard one, which might come a bit unexpected to users of the process class. Anyhow, I guess this is unlikely, and even then it will be done in the Process spec. |
Fixes #2559
The
Process
class defines a new metadata inputcall_link_label
thatwhen set for a process that is called by another, will be used as the
link label for the
CALL
link, instead of the default.