-
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
Docs: add the "How to explore the provenance graph" section #4491
Docs: add the "How to explore the provenance graph" section #4491
Conversation
docs/source/howto/exploring.rst
Outdated
Incoming and outgoing links | ||
=========================== | ||
|
||
The provenance graph in AiiDA is a :ref:`directed acyclic graph <topics:provenance:concepts>`. |
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.
The provenance graph in AiiDA is a :ref:`directed acyclic graph <topics:provenance:concepts>`. | |
The provenance graph in AiiDA is a :ref:`directed graph <topics:provenance:concepts>`. |
docs/source/howto/exploring.rst
Outdated
|
||
The provenance graph in AiiDA is a :ref:`directed acyclic graph <topics:provenance:concepts>`. | ||
The vertices of the graph are the *nodes* and the edges that connect them are called *links*. | ||
Since the graph is directed, any node can have *incoming* and *outgoing* links that connects it to neighboring nodes. |
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.
Since the graph is directed, any node can have *incoming* and *outgoing* links that connects it to neighboring nodes. | |
Since the graph is directed, any node can have *incoming* and *outgoing* links that connect it to neighboring nodes. |
docs/source/howto/exploring.rst
Outdated
Since the graph is directed, any node can have *incoming* and *outgoing* links that connects it to neighboring nodes. | ||
|
||
To discover the neighbors of a given node, you can use the methods :meth:`~aiida.orm.nodes.node.Node.get_incoming` and :meth:`~aiida.orm.nodes.node.Node.get_outgoing`. | ||
They have the exact same interface but will return the neighbors from which the links are incoming, or to which the links are pointing, respectively. |
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.
They have the exact same interface but will return the neighbors from which the links are incoming, or to which the links are pointing, respectively. | |
They have the exact same interface but will return the neighbors connected to the current node with link coming into it, or with links going out of it, respectively. |
I feel this is a bit more clear (I hope)
docs/source/howto/exploring.rst
Outdated
The :meth:`~aiida.orm.nodes.node.Node.get_incoming` and :meth:`~aiida.orm.nodes.node.Node.get_outgoing` methods accept various arguments that allow one to filter what neighboring nodes should be matched: | ||
|
||
* ``node_class``: accepts a subclass of :class:`~aiida.orm.nodes.node.Node`, only neighboring nodes with a class that matches this will be returned | ||
* ``link_type``: accepts a vale of :class:`~aiida.common.links.LinkType`, only neighboring nodes that are linked with this link type will be returned |
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.
* ``link_type``: accepts a vale of :class:`~aiida.common.links.LinkType`, only neighboring nodes that are linked with this link type will be returned | |
* ``link_type``: accepts a value of :class:`~aiida.common.links.LinkType`, only neighboring nodes that are linked with this link type will be returned |
docs/source/howto/exploring.rst
Outdated
|
||
* ``node_class``: accepts a subclass of :class:`~aiida.orm.nodes.node.Node`, only neighboring nodes with a class that matches this will be returned | ||
* ``link_type``: accepts a vale of :class:`~aiida.common.links.LinkType`, only neighboring nodes that are linked with this link type will be returned | ||
* ``link_label_filter``: accepts a string regex (with optional wildcards), only neighboring nodes that are linked with a link label that matches the regex will be returned |
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.
* ``link_label_filter``: accepts a string regex (with optional wildcards), only neighboring nodes that are linked with a link label that matches the regex will be returned | |
* ``link_label_filter``: accepts a string expression (with optional wildcards using the syntax of SQL `LIKE` patterns, see below), only neighboring nodes that are linked with a link label that matches the regex will be returned |
I think regex means a specific thing - we shouldn't say that these are regexes.
These are called patterns e.g. in the postgres docs
docs/source/howto/exploring.rst
Outdated
outputs = process_node.outputs | ||
|
||
These properties do not return the actual inputs and outputs directly, but instead return an instance of :class:`~aiida.orm.utils.managers.NodeLinksManager` | ||
The reason is because through the manager, the inputs or outputs are accessible through their link label and it is tab-completed. |
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.
The reason is because through the manager, the inputs or outputs are accessible through their link label and it is tab-completed. | |
The reason is because through the manager, the inputs or outputs are accessible through their link label (that, for inputs and outputs of processes, is unique) and can be tab-completed. |
.. note:: | ||
|
||
The ``inputs`` and ``outputs`` properties are only defined for :class:`~aiida.orm.nodes.process.process.ProcessNode`'s. | ||
This means that you cannot *chain* these calls, because an input or output of a process node is guaranteed to be a :class:`~aiida.orm.nodes.data.Data` node, which does not have inputs or outputs. |
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.
I would put this comment below, after explaining creator, to say that inputs+creator allows to go up in the provenance graph as much as you want, chaining them. Instead, going down, you cannot for the reason you mention
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.
Not sure where exactly you intend this to be placed. It is true that chaining creator
and inputs
alternatively works, but that is just one example and not every node has a creator. Instead, I kept this as is and added another note after the explanation of creator
that gives the example you propose.
docs/source/howto/exploring.rst
Outdated
* :meth:`~aiida.orm.nodes.process.process.ProcessNode.called`: defined for :class:`~aiida.orm.nodes.process.process.ProcessNode`'s and returns the list of process nodes called by this node. | ||
If this process node did not call any other processes, this property returns an empty list. | ||
* :meth:`~aiida.orm.nodes.process.process.ProcessNode.caller`: defined for :class:`~aiida.orm.nodes.process.process.ProcessNode`'s and returns the process node that called this node. | ||
If this ndoe was not called by a process, this property returns ``None``. |
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.
If this ndoe was not called by a process, this property returns ``None``. | |
If this node was not called by a process, this property returns ``None``. |
|
||
Similar to the ``inputs`` and ``outputs`` properties of process nodes, there are some more properties that make exploring the provenance graph easier: | ||
|
||
* :meth:`~aiida.orm.nodes.process.process.ProcessNode.called`: defined for :class:`~aiida.orm.nodes.process.process.ProcessNode`'s and returns the list of process nodes called by this node. |
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.
Not relevant for this PR, but I realise now that we could have defined this only for WorkflowNodes, actually, since the list will always be empty for CalculationNodes
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.
Yeah, and I think the ProcessNode
should also have a inputs
and outputs
implementation. Now I cannot reference it
node.res.some_key | ||
|
||
In an interactive shell, the available keys are also tab-completed. | ||
If you type ``node.res.`` followed by the tab key twice, a list of the available keys is printed. |
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.
I would add that, if the default output node link label is output_parameters
, then node.res.some_key
is equivalent to node.outputs.output_parameters.dict.some_key
and stress that we are looking at the keys of a different node (this, together with the fact that verdi node outputcat/outputls
act on a different node, does not seem to be super intuitive at first for new users, in my experience)
This section adds completely new documentation on the graph exploring methods `get_incoming` and `get_outgoing` that were not yet documented. It also documents the `creator`, `caller` and `creator` properties that also weren't documented yet. The `working_with_aiida/resultmanager.rst` is removed and its content, that documents the `inputs` and `outputs` properties of process nodes as well as the `res` property of the `CalcJobNode` class, is added to the new section in heavily rewritten form.
3633cbf
to
808b262
Compare
@giovannipizzi addressed all your comments |
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!
Fixes #4464
This section adds completely new documentation on the graph exploring
methods
get_incoming
andget_outgoing
that were not yet documented.It also documents the
creator
,caller
andcreator
properties thatalso weren't documented yet.
The
working_with_aiida/resultmanager.rst
is removed and its content,that documents the
inputs
andoutputs
properties of process nodes aswell as the
res
property of theCalcJobNode
class, is added to thenew section in heavily rewritten form.