Metadata-Version: 2.1
Name: graphtik
Version: 7.1.2
Summary: A lightweight Python-3.6+ lib for solving & executing graphs of functions
Home-page: http://github.com/pygraphkit/graphtik
Author: Kostis Anagnostopoulos, Huy Nguyen, Arel Cordero, Pierre Garrigues, Rob Hess, Tobi Baumgartner, Clayton Mellina
Author-email: ankostis@gmail.com
License: Apache-2.0
Project-URL: Documentation, https://graphtik.readthedocs.io/
Project-URL: Release Notes, https://graphtik.readthedocs.io/en/latest/changes.html
Project-URL: Sources, https://github.com/pygraphkit/graphtik
Project-URL: Bug Tracker, https://github.com/pygraphkit/graphtik/issues
Keywords: graph,computation graph,DAG,directed acyclic graph,executor,scheduler,etl,workflow,pipeline
Platform: Windows
Platform: Linux
Platform: Solaris
Platform: Mac OS-X
Platform: Unix
Classifier: Development Status :: 4 - Beta
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: Natural Language :: English
Classifier: Operating System :: MacOS :: MacOS X
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: OS Independent
Classifier: Operating System :: POSIX
Classifier: Operating System :: Unix
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Scientific/Engineering
Classifier: Topic :: Software Development
Requires-Python: >=3.6
Description-Content-Type: text/x-rst
Requires-Dist: boltons
Requires-Dist: networkx (==2.2) ; python_version < "3.5"
Requires-Dist: contextvars ; python_version < "3.7"
Requires-Dist: networkx ; python_version >= "3.5"
Provides-Extra: all
Requires-Dist: pytest ; extra == 'all'
Requires-Dist: pytest-sphinx ; extra == 'all'
Requires-Dist: html5lib ; extra == 'all'
Requires-Dist: pytest-cov ; extra == 'all'
Requires-Dist: sphinx (>=2) ; extra == 'all'
Requires-Dist: readme-renderer ; extra == 'all'
Requires-Dist: jinja2 ; extra == 'all'
Requires-Dist: sphinxcontrib-spelling ; extra == 'all'
Requires-Dist: pydot ; extra == 'all'
Requires-Dist: dill ; extra == 'all'
Requires-Dist: matplotlib ; extra == 'all'
Requires-Dist: black ; extra == 'all'
Requires-Dist: pylint ; extra == 'all'
Requires-Dist: mypy ; extra == 'all'
Requires-Dist: importlib-resources ; (python_version < "3.7") and extra == 'all'
Provides-Extra: dev
Requires-Dist: pytest ; extra == 'dev'
Requires-Dist: pytest-sphinx ; extra == 'dev'
Requires-Dist: html5lib ; extra == 'dev'
Requires-Dist: pytest-cov ; extra == 'dev'
Requires-Dist: sphinx (>=2) ; extra == 'dev'
Requires-Dist: readme-renderer ; extra == 'dev'
Requires-Dist: jinja2 ; extra == 'dev'
Requires-Dist: sphinxcontrib-spelling ; extra == 'dev'
Requires-Dist: pydot ; extra == 'dev'
Requires-Dist: dill ; extra == 'dev'
Requires-Dist: matplotlib ; extra == 'dev'
Requires-Dist: black ; extra == 'dev'
Requires-Dist: pylint ; extra == 'dev'
Requires-Dist: mypy ; extra == 'dev'
Requires-Dist: importlib-resources ; (python_version < "3.7") and extra == 'dev'
Provides-Extra: dill
Requires-Dist: dill ; extra == 'dill'
Provides-Extra: matplot
Requires-Dist: pydot ; extra == 'matplot'
Requires-Dist: jinja2 ; extra == 'matplot'
Requires-Dist: matplotlib ; extra == 'matplot'
Requires-Dist: importlib-resources ; (python_version < "3.7") and extra == 'matplot'
Provides-Extra: plot
Requires-Dist: pydot ; extra == 'plot'
Requires-Dist: jinja2 ; extra == 'plot'
Requires-Dist: importlib-resources ; (python_version < "3.7") and extra == 'plot'
Provides-Extra: sphinx
Requires-Dist: pydot ; extra == 'sphinx'
Requires-Dist: jinja2 ; extra == 'sphinx'
Requires-Dist: sphinx (>=2) ; extra == 'sphinx'
Requires-Dist: importlib-resources ; (python_version < "3.7") and extra == 'sphinx'
Provides-Extra: test
Requires-Dist: pytest ; extra == 'test'
Requires-Dist: pytest-sphinx ; extra == 'test'
Requires-Dist: html5lib ; extra == 'test'
Requires-Dist: pytest-cov ; extra == 'test'
Requires-Dist: sphinx (>=2) ; extra == 'test'
Requires-Dist: readme-renderer ; extra == 'test'
Requires-Dist: jinja2 ; extra == 'test'
Requires-Dist: sphinxcontrib-spelling ; extra == 'test'
Requires-Dist: pydot ; extra == 'test'
Requires-Dist: dill ; extra == 'test'
Requires-Dist: matplotlib ; extra == 'test'
Requires-Dist: importlib-resources ; (python_version < "3.7") and extra == 'test'

Graphtik
========

|python-ver| |dev-status| |gh-version| |pypi-version|
(build-version: v7.1.2, build-date: 2020-05-06T17:03:45.585278)
|travis-status| |doc-status| |cover-status| |codestyle| |proj-lic|

|gh-watch| |gh-star| |gh-fork| |gh-issues|

.. epigraph::

    It's a DAG all the way down!

    |sample-plot|

Lightweight computation graphs for Python
-----------------------------------------

**Graphtik** is an an understandable and lightweight Python module for building,
running and plotting graphs of functions (a.k.a pipelines).

- The API posits a fair compromise between features and complexity, without precluding any.
- It can be used as is to build machine learning pipelines for data science projects.
- It should be extendable to act as the core for a custom ETL engine, a workflow-processor
  for interdependent files like GNU Make, or an Excel-like spreadsheet.

.. Note::
    *Graphtik* `sprang <https://docs.google.com/spreadsheets/d/1HPgtg2l6v3uDS81hLOcFOZxIBLCnHGrcFOh3pFRIDio/edit#gid=0>`_
    from `Graphkit`_ (summer 2019, v1.2.2) to `experiment
    <https://github.com/yahoo/graphkit/issues/>`_ with Python 3.6+ features,
    but has diverged significantly with enhancements ever since.


Quick start
-----------

Here’s how to install:

::

   pip install graphtik

OR with various "extras" dependencies, such as, for plotting::

   pip install graphtik[plot]

. Tip::
    Supported extras:

    **plot**
        for plotting with `Graphviz`_,
    **matplot**
        for plotting in *maplotlib* windows
    **sphinx**
        for embedding plots in *sphinx*\-generated sites,
    **test**
        for running *pytest*\s,
    **dill**
        may help for pickling `parallel` tasks - see `marshalling` term
        and ``set_marshal_tasks()`` configuration.
    **all**
        all of the above, plus development libraries, eg *black* formatter.
    **dev**
        like *all*

Let's build a *graphtik* computation graph that produces x3 outputs
out of 2 inputs `a` and `b`:

- `a x b`
- `a - a x b`
- `|a - a x b| ^ 3`

..

>>> from graphtik import compose, operation
>>> from operator import mul, sub

>>> @operation(name="abs qubed",
...            needs=["a_minus_ab"],
...            provides=["abs_a_minus_ab_cubed"])
... def abs_qubed(a):
...     return abs(a) ** 3

Compose the ``abspow`` function along the ``mul`` & ``sub``  built-ins
into a computation graph:

>>> graphop = compose("graphop",
...     operation(needs=["a", "b"], provides=["ab"])(mul),
...     operation(needs=["a", "ab"], provides=["a_minus_ab"])(sub),
...     abs_qubed,
... )
>>> graphop
NetworkOperation('graphop', needs=['a', 'b', 'ab', 'a_minus_ab'],
                    provides=['ab', 'a_minus_ab', 'abs_a_minus_ab_cubed'],
                    x3 ops: mul, sub, abs qubed)

Run the graph and request all of the outputs:

>>> graphop(a=2, b=5)
{'a': 2, 'b': 5, 'ab': 10, 'a_minus_ab': -8, 'abs_a_minus_ab_cubed': 512}

... or request a subset of outputs:

>>> solution = graphop.compute({'a': 2, 'b': 5}, outputs=["a_minus_ab"])
>>> solution
{'a_minus_ab': -8}

... and plot the results (if in *jupyter*, no need to create the file):

>>> solution.plot('graphop.svg')    # doctest: +SKIP

|sample-sol|
|plot-legend|

.. |sample-plot| image:: docs/source/images/sample.svg
    :alt: sample graphtik plot
    :width: 120px
    :align: middle
.. |sample-sol| image:: docs/source/images/executed_3ops.svg
    :alt: sample graphtik plot
    :width: 120px
    :align: middle
.. |plot-legend| image:: docs/source/images/GraphtikLegend.svg
    :alt: graphtik legend
    :align: middle


.. _Graphkit: https://github.com/yahoo/graphkit
.. _Graphviz: https://graphviz.org
.. _badges_substs:

.. |travis-status| image:: https://img.shields.io/travis/pygraphkit/graphtik
    :alt: Travis continuous integration testing ok? (Linux)
    :target: https://travis-ci.org/pygraphkit/graphtik/builds

.. |doc-status| image:: https://img.shields.io/readthedocs/graphtik?branch=master
    :alt: ReadTheDocs ok?
    :target: https://graphtik.readthedocs.org

.. |cover-status| image:: https://img.shields.io/codecov/c/github/pygraphkit/graphtik
    :target: https://codecov.io/gh/pygraphkit/graphtik

.. |gh-version| image::  https://img.shields.io/github/v/release/pygraphkit/graphtik?label=GitHub%20release&include_prereleases
    :target: https://github.com/pygraphkit/graphtik/releases
    :alt: Latest release in GitHub

.. |pypi-version| image::  https://img.shields.io/pypi/v/graphtik?label=PyPi%20version
    :target: https://pypi.python.org/pypi/graphtik/
    :alt: Latest version in PyPI

.. |python-ver| image:: https://img.shields.io/pypi/pyversions/graphtik?label=Python
    :target: https://pypi.python.org/pypi/graphtik/
    :alt: Supported Python versions of latest release in PyPi

.. |dev-status| image:: https://img.shields.io/pypi/status/graphtik
    :target: https://pypi.python.org/pypi/graphtik/
    :alt: Development Status

.. |codestyle| image:: https://img.shields.io/badge/code%20style-black-black
    :target: https://github.com/ambv/black
    :alt: Code Style

.. |gh-watch| image:: https://img.shields.io/github/watchers/pygraphkit/graphtik?style=social
    :target: https://github.com/pygraphkit/graphtik
    :alt: Github watchers

.. |gh-star| image:: https://img.shields.io/github/stars/pygraphkit/graphtik?style=social
    :target: https://github.com/pygraphkit/graphtik
    :alt: Github stargazers

.. |gh-fork| image:: https://img.shields.io/github/forks/pygraphkit/graphtik?style=social
    :target: https://github.com/pygraphkit/graphtik
    :alt: Github forks

.. |gh-issues| image:: http://img.shields.io/github/issues/pygraphkit/graphtik?style=social
    :target: https://github.com/pygraphkit/graphtik/issues
    :alt: Issues count

.. |proj-lic| image:: https://img.shields.io/pypi/l/graphtik
    :target:  https://www.apache.org/licenses/LICENSE-2.0
    :alt: Apache License, version 2.0


