aiidateam / aiida-core

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

Allow sorting within nested level for verdi work report #1103

Open sphuber opened 6 years ago

sphuber commented 6 years ago

Currently verdi work report will print all the log messages for a given WorkCalculation. These messages will be sorted by timestamp by default, which is usually desirable. However, for workchains, that launch multiple sub workchains in parallel, the nested log messages of the subworkchains will not be grouped together, but flow through one another, because the nesting level to which they belong, is not taken into account. It would be nice, to have a flag that when set will group all nested log messages within their respective groups. Example of current behavior:

[823 | REPORT]: [2727|PwRelaxWorkChain|run_relax]: launching PwBaseWorkChain<2741>
[823 | REPORT]: [2727|PwRelaxWorkChain|run_relax]: launching PwBaseWorkChain<2746>
[824 | REPORT]:   [2741|PwBaseWorkChain|run_calculation]: launching PwCalculation<2744> iteration #1
[824 | REPORT]:   [2746|PwBaseWorkChain|run_calculation]: launching PwCalculation<2749> iteration #1
[825 | REPORT]:   [2741|PwBaseWorkChain|inspect_calculation]: PwCalculation<2744> completed successfully
[825 | REPORT]:   [2746|PwBaseWorkChain|inspect_calculation]: PwCalculation<2749> completed successfully
[826 | REPORT]:   [2741|PwBaseWorkChain|results]: workchain completed after 1 iterations
[826 | REPORT]:   [2746|PwBaseWorkChain|results]: workchain completed after 1 iterations
[834 | REPORT]: [2727|PwRelaxWorkChain|results]: workchain completed after 1 iteration

Example of the new behavior when the flag is set:

[823 | REPORT]: [2727|PwRelaxWorkChain|run_relax]: launching PwBaseWorkChain<2741>
[824 | REPORT]:   [2741|PwBaseWorkChain|run_calculation]: launching PwCalculation<2744> iteration #1
[825 | REPORT]:   [2741|PwBaseWorkChain|inspect_calculation]: PwCalculation<2744> completed successfully
[826 | REPORT]:   [2741|PwBaseWorkChain|results]: workchain completed after 1 iterations
[823 | REPORT]: [2727|PwRelaxWorkChain|run_relax]: launching PwBaseWorkChain<2746>
[824 | REPORT]:   [2746|PwBaseWorkChain|run_calculation]: launching PwCalculation<2749> iteration #1
[825 | REPORT]:   [2746|PwBaseWorkChain|inspect_calculation]: PwCalculation<2749> completed successfully
[826 | REPORT]:   [2746|PwBaseWorkChain|results]: workchain completed after 1 iterations
[834 | REPORT]: [2727|PwRelaxWorkChain|results]: workchain completed after 1 iteration

Notice how in the second example the logs belonging to each PwBaseWorkChain are grouped together, making it clear which log belongs to which sub workchain

ltalirz commented 6 years ago

@sphuber In order to create the grouping that you desire, one needs some additional information which I don't know how to get (unless one does some heuristics/grepping).

Currently, the model is:

This allows to group reports by WorkCalculation, but it does not tell you, which log of the parent node is connected to which of its children.

One could do something like

[823 | REPORT]: [2727|PwRelaxWorkChain|run_relax]: launching PwBaseWorkChain<2741>
[823 | REPORT]: [2727|PwRelaxWorkChain|run_relax]: launching PwBaseWorkChain<2746>
[834 | REPORT]: [2727|PwRelaxWorkChain|results]: workchain completed after 1 iteration

[824 | REPORT]:   [2741|PwBaseWorkChain|run_calculation]: launching PwCalculation<2744> iteration #1
[825 | REPORT]:   [2741|PwBaseWorkChain|inspect_calculation]: PwCalculation<2744> completed successfully
[826 | REPORT]:   [2741|PwBaseWorkChain|results]: workchain completed after 1 iterations

[824 | REPORT]:   [2746|PwBaseWorkChain|run_calculation]: launching PwCalculation<2749> iteration #1
[825 | REPORT]:   [2746|PwBaseWorkChain|inspect_calculation]: PwCalculation<2749> completed successfully
[826 | REPORT]:   [2746|PwBaseWorkChain|results]: workchain completed after 1 iterations

But it's not very nice.

In my opinion, there is a decision to be made: If verdi work report is supposed to be about showing log files, then I guess we don't need the grouping and the basic sorting routines are fine. If verdi work report should show the logic of how things happened, then I guess we shouldn't be dealing with the log messages in the first place, but rather reconstruct the logic from the database (or wherever this information is stored).

I'm generally a bit confused about the division of tasks between verdi work status, verdi work report and verdi work list, perhaps you can clarify.