Skip to content

Commit 5ca92eb

Browse files
committed
DOC(net,REF): explain UNVARYING, sphinx selective Net API
1 parent 378ec7e commit 5ca92eb

File tree

3 files changed

+44
-16
lines changed

3 files changed

+44
-16
lines changed

docs/source/operations.rst

Lines changed: 37 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,36 @@
11
Operations
22
==========
33

4-
At a high level, an operation is a node in a computation graph. Graphtik uses an ``operation`` class to represent these computations.
4+
At a high level, an operation is a node in a computation graph.
5+
Graphtik uses an :class:`.Operation` class to abstractly represent these computations.
6+
The class specifies the *requirments* for a function to participate
7+
in a computation graph; those are its input-data **needs**, and the output-data
8+
it **provides**.
59

6-
The ``operation`` class
7-
-----------------------
10+
The :class:`FunctionalOperation` provides a lightweight wrapper
11+
around an arbitrary function to define those specifications.
812

9-
The ``operation`` class specifies an operation in a computation graph, including its input data dependencies as well as the output data it provides. It provides a lightweight wrapper around an arbitrary function to make these specifications.
13+
.. autoclass:: graphtik.op.Operation
14+
:members: compute
15+
:noindex:
1016

11-
There are many ways to instantiate an ``operation``, and we'll get into more detail on these later. First off, though, here's the specification for the ``operation`` class:
17+
There is a better way to instantiate an ``FunctionalOperation`` than simply constructing it,
18+
and we'll get to it later.
19+
First off, though, here's the specifications for the `operation` classes:
1220

13-
.. autoclass:: graphtik.operation
14-
:members: __init__, __call__
21+
.. autoclass:: graphtik.op.FunctionalOperation
22+
:members: __init__, __call__, compute
1523
:member-order: bysource
1624
:special-members:
25+
:noindex:
1726

1827

1928
Operations are just functions
2029
------------------------------
2130

22-
At the heart of each ``operation`` is just a function, any arbitrary function. Indeed, you can instantiate an ``operation`` with a function and then call it just like the original function, e.g.::
31+
At the heart of each ``operation`` is just a function, any arbitrary function.
32+
Indeed, you can instantiate an ``operation`` with a function and then call it
33+
just like the original function, e.g.::
2334

2435
>>> from operator import add
2536
>>> from graphtik import operation
@@ -33,13 +44,24 @@ At the heart of each ``operation`` is just a function, any arbitrary function.
3344
Specifying graph structure: ``provides`` and ``needs``
3445
------------------------------------------------------
3546

36-
Of course, each ``operation`` is more than just a function. It is a node in a computation graph, depending on other nodes in the graph for input data and supplying output data that may be used by other nodes in the graph (or as a graph output). This graph structure is specified via the ``provides`` and ``needs`` arguments to the ``operation`` constructor. Specifically:
47+
Of course, each ``operation`` is more than just a function.
48+
It is a node in a computation graph, depending on other nodes in the graph for input data and
49+
supplying output data that may be used by other nodes in the graph (or as a graph output).
50+
This graph structure is specified via the ``provides`` and ``needs`` arguments
51+
to the ``operation`` constructor. Specifically:
3752

38-
* ``provides``: this argument names the outputs (i.e. the returned values) of a given ``operation``. If multiple outputs are specified by ``provides``, then the return value of the function comprising the ``operation`` must return an iterable.
53+
* ``provides``: this argument names the outputs (i.e. the returned values) of a given ``operation``.
54+
If multiple outputs are specified by ``provides``, then the return value of the function
55+
comprising the ``operation`` must return an iterable.
3956

40-
* ``needs``: this argument names data that is needed as input by a given ``operation``. Each piece of data named in needs may either be provided by another ``operation`` in the same graph (i.e. specified in the ``provides`` argument of that ``operation``), or it may be specified as a named input to a graph computation (more on graph computations :ref:`here <graph-computations>`).
57+
* ``needs``: this argument names data that is needed as input by a given ``operation``.
58+
Each piece of data named in needs may either be provided by another ``operation``
59+
in the same graph (i.e. specified in the ``provides`` argument of that ``operation``),
60+
or it may be specified as a named input to a graph computation
61+
(more on graph computations :ref:`here <graph-computations>`).
4162

42-
When many operations are composed into a computation graph (see :ref:`graph-composition` for more on that), Graphtik matches up the values in their ``needs`` and ``provides`` to form the edges of that graph.
63+
When many operations are composed into a computation graph (see :ref:`graph-composition` for more on that),
64+
Graphtik matches up the values in their ``needs`` and ``provides`` to form the edges of that graph.
4365

4466
Let's look again at the operations from the script in :ref:`quick-start`, for example::
4567

@@ -142,8 +164,9 @@ by creating an operation "builder pattern"::
142164
Modifiers on ``operation`` inputs and outputs
143165
---------------------------------------------
144166

145-
Certain modifiers are available to apply to input or output values in ``needs`` and ``provides``, for example to designate an optional input. These modifiers are available in the ``graphtik.modifiers`` module:
146-
167+
Certain modifiers are available to apply to input or output values in ``needs`` and ``provides``,
168+
for example, to designate optional inputs, or "ghost" sideffects inputs & outputs.
169+
These modifiers are available in the ``graphtik.modifiers`` module:
147170

148171
Optionals
149172
^^^^^^^^^

docs/source/reference.rst

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,12 @@ Module: `network`
3232
=================
3333

3434
.. automodule:: graphtik.network
35-
:members:
35+
:members: AbortedException, abort_run, is_abort, is_skip_evictions, set_evictions_skipped, _execution_configs
36+
.. autoclass:: graphtik.network.Network
37+
:private-members:
38+
:undoc-members:
39+
.. autoclass:: graphtik.network.ExecutionPlan
40+
:private-members:
3641
:undoc-members:
3742

3843
Module: `plot`

graphtik/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def jetsam(ex, locs, *salvage_vars: str, annotation="jetsam", **salvage_mappings
6464
by calling ``value(locs)``.
6565
They take precendance over`salvae_vars`.
6666
67-
:raise:
67+
:raises:
6868
any exception raised by the wrapped function, annotated with values
6969
assigned as atrributes on this context-manager
7070

0 commit comments

Comments
 (0)