Skip to main content

Summary

python pipeline coverage report github gitlab pypi-release License: MIT

The DAGModelling software is a python implementation of the dataflow programming with the lazy graph evaluation approach.

Main goals:

  • Lazy evaluated directed acyclic graph;
  • Concise connection syntax;
  • Plotting with graphviz;
  • Flexibility. The goal of DAG-Modelling is not to be efficient, but rather flexible.

The framework is intended to be used for the statistical analysis of the data of JUNO and Daya Bay neutrino oscillation experiments.

Installation

For regular use, it's best to install the latest version of the project that's available on PyPi:

pip install dag-modelling

For developers

We recommend that developers install the package locally in editable mode:

git clone https://github.com/dagflow-team/dag-modelling.git
cd dag-modelling
pip install -e .

This way, the system will track all the changes made to the source files. This means that developers won't need to reinstall the package or set environment variables, even when a branch is changed.

Cython acceleration (optional)

Building

Compilation is opt-in: pip install dag-modelling (and pip install .) gives pure Python. To build the .so extensions, install Cython first and disable build isolation, otherwise the build does not see it:

pip install cython
pip install --no-build-isolation ".[cython]"                              # from a checkout
pip install --no-build-isolation --no-binary dag-modelling dag-modelling  # from PyPI

The cython extra alone does not compile anything. From PyPI, --no-binary is needed too, since the published wheel is pure Python.

When editing .pyx sources, rebuild in place:

python setup.py build_ext --inplace

Three files per compiled class

File Role
x.pxd C-level field/signature declarations, for cimport
x.pyx cdef class, hot path only (cpdef/cdef)
x.py pure-Python fallback, same interface
x_methods.py shared cold-path mixin _XMethods (__slots__ = ())

At import time Python prefers the compiled x.<abi>.so over x.py, so from dag_modelling.core.node import Node works either way.

Switching to pure Python

Set DGM_DISABLE_CYTHON=1 to use the .py core even when .so files are built, e.g. to run tests in both modes:

pytest                         # compiled core (if built)
DGM_DISABLE_CYTHON=1 pytest    # pure-Python core

The variable is read on the first import dag_modelling, so a running process cannot switch. To check which core is loaded, look at dag_modelling.core.node_eval.__file__ (.so or .py).

Example

For example, let's consider a sum of three input nodes and then a product of the result with another array.

from numpy import arange

from dag_modelling.core.graph import Graph
from dag_modelling.plot.graphviz import savegraph
from dag_modelling.lib.common import Array
from dag_modelling.lib.arithmetic import Sum, Product

# Define a source data
array = arange(3, dtype="d")

# Check predefined Array, Sum and Product
with Graph(debug=debug) as graph:
    # Define nodes
    (in1, in2, in3, in4) = (Array(name, array) for name in ("n1", "n2", "n3", "n4"))
    s = Sum("sum")
    m = Product("product")

    # Connect nodes
    (in1, in2, in3) >> s
    (in4, s) >> m
    graph.close()

    print("Result:", m.outputs["result"].data) # must print [0. 3. 12.]
    savegraph(graph, "dag_modelling_example_1a.png")

The printed result must be [0. 3. 12.], and the created image looks as

graph example

For more examples see example/example.py or tests.

Please, note, that examples are using pygraphviz package, which is optional and not requested by default.

Additional modules

Supplementary python modules:

Metadata

Release files for dag-modelling 0.16.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dag-modelling 0.16.0
File Size Uploaded
dag_modelling-0.16.0.tar.gz 2.1 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for dag-modelling 0.16.0
File Interpreter ABI Platform
dag_modelling-0.16.0-py3-none-any.whl Python 3 none any Details

Total release size: 2.3 MB

Release files / dag_modelling-0.16.0.tar.gz

Download URL dag_modelling-0.16.0.tar.gz
Size 2.1 MB
Tags Source
SHA-256 checksum
How to use checksums
023b6f7f141047ebea01393757ae8a22662f2428c8927a38360db777b2d5aa30
BLAKE2b-256 checksum
How to use checksums
1fb2e210955f39b7b59f9a0d825f47d33bbb89385b90338eb5e12c58317c06ce
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.14

Release files / dag_modelling-0.16.0-py3-none-any.whl

Download URL dag_modelling-0.16.0-py3-none-any.whl
Size 219.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a415f3369025dbca8bc410dc4278e01ef70ce083cc2041df8025f7689d8edaaf
BLAKE2b-256 checksum
How to use checksums
22b473ef00188696c17e1846fa3e69ef0161f5d326dedefad89ebe657020c29b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.14

Release history Release notifications | RSS feed

This release

0.16.0 This release

2 release files

0.15.0

2 release files

0.14.3

2 release files

0.14.2

2 release files

0.14.0

2 release files

0.12

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page