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

Allow to define link label for CALL links #3003

Merged
merged 1 commit into from
Jun 14, 2019

Conversation

sphuber
Copy link
Contributor

@sphuber sphuber commented Jun 13, 2019

Fixes #2559

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.

@sphuber sphuber requested review from ltalirz and giovannipizzi June 13, 2019 17:21
@sphuber sphuber force-pushed the fix_2559_define_call_link_label branch from 03cf7c2 to 73bd4d5 Compare June 13, 2019 18:11
@coveralls
Copy link

coveralls commented Jun 13, 2019

Coverage Status

Coverage increased (+6.1%) to 72.999% when pulling 43f91e3 on sphuber:fix_2559_define_call_link_label into 607f973 on aiidateam:develop.

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.')
Copy link
Member

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?

Copy link
Contributor Author

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 a WorkChain
  • Or when calling another process from within a workfunction
    The only way for the user to pass the desired link label is through the metadata.
    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 correct CALL link in the construction of the child process. So as you can see, the creation of the CALL link was already happening this way, I am merely adding the possibility for the user to change the link label through the metadata input.

I will add a test that also demonstrates and tests the example of something being called from within a work function.

Copy link
Member

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:

  1. When this process calls other processes, the link label should be X
  2. 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.

Copy link
Member

@ltalirz ltalirz Jun 14, 2019

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?

Copy link
Contributor Author

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

Copy link
Member

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 ;-)

@sphuber sphuber force-pushed the fix_2559_define_call_link_label branch from 73bd4d5 to a5bd97b Compare June 14, 2019 06:54
@sphuber
Copy link
Contributor Author

sphuber commented Jun 14, 2019

@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.

@sphuber sphuber force-pushed the fix_2559_define_call_link_label branch 2 times, most recently from f57cda3 to 83bdc1c Compare June 14, 2019 08:15
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.
@sphuber sphuber force-pushed the fix_2559_define_call_link_label branch from 83bdc1c to 43f91e3 Compare June 14, 2019 14:08
Copy link
Member

@ltalirz ltalirz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @sphuber !

@ltalirz
Copy link
Member

ltalirz commented Jun 14, 2019

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.

@sphuber sphuber merged commit 05bc02b into aiidateam:develop Jun 14, 2019
@sphuber sphuber deleted the fix_2559_define_call_link_label branch June 14, 2019 15:46
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.

Allow to specify the CALL link label when submitting processes
3 participants