Skip to main content

No project description provided

Project description

from nodeflow.builtin import Integer

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

pip install nodeflow

Import it to your code using:

import nodeflow

Types

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

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.0.4.tar.gz (11.3 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.0.4-py3-none-any.whl (11.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: nodeflow-0.0.4.tar.gz
  • Upload date:
  • Size: 11.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.12.7 Linux/6.5.0-1025-azure

File hashes

Hashes for nodeflow-0.0.4.tar.gz
Algorithm Hash digest
SHA256 f31ec20908e60acc8c758a2609ed6c3c8410c467ae4ba285efff0736403f668f
MD5 a098d0272c55c465964fd6d5a3417da8
BLAKE2b-256 732538c6cb2b7ffd52c846e019b0f464f2e9e3995bd01112ad421b1e277a4ecc

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for nodeflow-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 170117a1df854c9942f89004de718bc3d35a7c80324f6b6552671451f42c58d9
MD5 005e38321d4f9fe8041c4e8296669d19
BLAKE2b-256 d8c87599fbe1a37c2755fde4de77c8414a2ec01b495883392ee1e479d4fbb038

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