Skip to main content

No project description provided

Project description

Nodeflow

Warp

Nodeflow if a framework to make pipelines from nodes.

Status

GitHub commit activity GitHub contributors GitHub Actions Workflow Status PyPI - Downloads GitHub License GitHub Discussions PyPI - Python Version GitHub repo size GitHub forks GitHub Repo stars GitHub watchers GitHub Tag

Usage

Warp

Installing

Requires python version 3.10 or later

pip3 install nodeflow

Import it to your code using:

import nodeflow

Types

In Nodeflow, everything is a subclass of the Node class.

Dev note: This is an old documentation. Newest versions of Nodeflow contain adapters from any2any types.

Variable

Each node encapsulates information for a specific type and functions as a container. The code snippet below is taken from the built-in types:

from nodeflow import Variable

class Integer(Variable):
    def __init__(self, value: int):
        super().__init__(value)
    
    # optional
    def __add__(self, other: 'Integer') -> 'Integer':
        return Integer(self.value + other.value)
    
    # optional
    def __mul__(self, other: 'Integer') -> 'Integer':
        return Integer(self.value * other.value)

Function

A Function node accepts several Variable nodes to perform computations and must return exactly one Variable. You can define your own function in the following manner:

from nodeflow import Function

class Sum(Function):
    def compute(self, a: Integer, b: Integer) -> Integer:
        return a + b

However, in practical applications, we recommend using a converter to transform a Python function into a NodeFlow function:

from nodeflow import func2node

def sum_of_integers(a: Integer, b: Integer) -> Integer:
    return a + b

Sum = func2node(sum_of_integers)

It is essential to include all type hints since the NodeFlow framework has the capability to derive implicit adapters.

Adapter

This is a subclass of Function. The computations primarily involve converting the types of Variable nodes. Refer to the examples for clarification.

Dispenser

How can we define our pipeline? If the function takes a single parameter, you can follow this pattern:

my_variable >> my_function

If the function requires multiple values, utilize an instance of the Dispenser:

from nodeflow import Dispenser, func2node

def increment(a: Integer) -> Integer:
    return Integer(a.value + 1)

def sum_of_integers(a: Integer, b: Integer) -> Integer:
    return a + b

result = Dispenser(
    a = Integer(5) >> func2node(increment),
    b = Integer(10),
) >> func2node(sum_of_integers)
# results.value == 16

Converter

A few words about deriving implicit adapters. The core of NodeFlow provides a solution for identifying the shortest path of explicit adapters that can convert one type to another when possible.

The conversion pipeline may sometimes lead to information loss, but the following priority list can guide the process:

  • Shortest pipeline without losing information
  • Shortest pipeline with information loss
  • Long pipeline without losing information better than short pipeline with information loss

Contributing

See CONTRIBUTING.md file.

Licence

MIT

Special thanks

Thank you for your interest in the project description!

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

nodeflow-0.1.1.tar.gz (8.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nodeflow-0.1.1-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

File details

Details for the file nodeflow-0.1.1.tar.gz.

File metadata

  • Download URL: nodeflow-0.1.1.tar.gz
  • Upload date:
  • Size: 8.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.12.8 Linux/6.5.0-1025-azure

File hashes

Hashes for nodeflow-0.1.1.tar.gz
Algorithm Hash digest
SHA256 e14cd4a47e93b4fee6b5abeddee5bc37724256d77d7066040917ab7f440338c1
MD5 08ef35856403a2e67a029032314c76fb
BLAKE2b-256 4bcfdfa19d826670995dad62e17b4085ae2168c53ee5380787d0733ce58d2a2f

See more details on using hashes here.

File details

Details for the file nodeflow-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: nodeflow-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 13.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.12.8 Linux/6.5.0-1025-azure

File hashes

Hashes for nodeflow-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c415eae50426e174f6ea04ceee2b97d67cc88477cc2d5a9865e3222cb7529ba7
MD5 daa76a65d2f085a038657007d4a42cb4
BLAKE2b-256 2dfe25e79c1d5d56e24c8be5557e1a19a4908452183f0bec84f3f90c9b696421

See more details on using hashes here.

Supported by

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