aiidateam / aiida-core

The official repository for the AiiDA code
https://aiida-core.readthedocs.io
Other
426 stars 187 forks source link

Positional argument does not work anymore using `run` #6246

Open superstar54 opened 7 months ago

superstar54 commented 7 months ago

aiida-core: 2.5.0

from aiida.engine import calcfunction, run
from aiida.orm import Int

@calcfunction
def add(x, y):
    return Int(x * y)

run(add, 1, 2)

will raise

TypeError: run() takes from 1 to 2 positional arguments but 3 were given

Same to run_get_node etc.

This does not happened before v2.5.0. This is introduced by #6202 .

sphuber commented 7 months ago

This came up during the discussion in on of the AiiDA core meetings. We realized that #6202 would indeed break positional arguments for run, but we accepted this breaking change as the changes in #6202 were overall an improvement and had become necessary due to another breaking change. Since this only affects process functions, I think this is ok. There is no real reason to use run for process functions. You can still directly call them, e.g., add(1, 2).

Now, if we can find a workaround to keep support for positional arguments in run without reverting the changes of #6202 , then that would be great. But I am not sure it is possible.