Skip to main content

A small toolkit for building dataflow-based framework.

Project description

CRayGraph

A toolkit for defining dataflow-based frameworks. Intended for use in CRayNN (network definitions) and CRayFlow (dataflow definitions).

Installation

via PyPi

pip install craygraph

via git

CRayGraph can be installed directly from gitlab.com:

pip install git+https://gitlab.com/craynn/craygraph.git

however, as repository updates quite often, it is recommend to clone the repository and install the package in development mode:

git clone git@gitlab.com:craynn/craygraph.git
cd craygraph/
pip install -e .

Usage

This package provides three main functions:

  • cragraph.graph : utilities for constructing easily readable definitions of directed acyclic graphs (DAGs);
  • cragraph.meta : functions that help quickly adopt custom classes to work with cragraph.graph.

DAG definition language

The main feature of craygraph is intuitive and readable DAG definition language.

Quick introduction

Below, functions like a, b, c, d represent node (subgraph) constructors, i.e. (*Node) -> Node or (*Node) -> list[Nodes], x, y, z represent input nodes.

Tuple of functions = composition

achain(a, b, c, d)(x)

is equivalent to:

d(c(b(a(x))))

and produces:

linear graph

List of functions = independent application:

result = achain(a, [b, c], d)(x)

is equivalent to:

a_x = a(x)
result = d(b(a_x), c(a_x))

and results in the following graph:

linear graph

craygraph.graph contains some helper functions. select[items](body) selects inputs according to items and applies body

select[item](f)(*args) == f(args[item]) 

for example:

result = achain(
  select[0, -1](a, b),
  c
)(x, y, z)

is equivalent to:

result = c(b(a(x, z)))

which results in (node y is omitted since it is not used):

linear graph

with_inputs[items](body) is similar to select, but it takes inputs and replaces selected inputs with the result of body:

result = achain(
  with_inputs[0, -1](a, b),
  c
)(x, y, z)

is equivalent to:

result = c(b(a(x, z)))

which results in:

linear graph

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

craygraph-0.3.0.tar.gz (15.0 kB view details)

Uploaded Source

File details

Details for the file craygraph-0.3.0.tar.gz.

File metadata

  • Download URL: craygraph-0.3.0.tar.gz
  • Upload date:
  • Size: 15.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.3.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.3

File hashes

Hashes for craygraph-0.3.0.tar.gz
Algorithm Hash digest
SHA256 d7bfae14f17899d4c8fd52432f7a2327d8d2d04bfa9aabf5f4d1971f671a2bb8
MD5 b1b54fa24478d04317c8b2be8412dbb4
BLAKE2b-256 a304fe5a2d9a9d11ad4fb5b902cf1bdbb8329a9cd78094c3f8b04b12a1a797d2

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page