Skip to main content

No project description provided

Project description

Flojoy / Python

The Python repo for Flojoy infrastructure. Including the client for Flojoy's desktop app, the @flojoy decorator, and various utilities for node creation.

The @flojoy decorator

Usage:

from scipy import signal
import numpy as np
from flojoy import flojoy, DataContainer

@flojoy
def BUTTER(v, params):
    ''' Apply a butterworth filter to an input vector '''

    logger.debug('Butterworth inputs:', v)

    x = v[0].x
    sig = v[0].y

    sos = signal.butter(10, 15, 'hp', fs=1000, output='sos')
    filtered = signal.sosfilt(sig, sig)

    return DataContainer(x = x, y = filtered)

The @flojoy decorator automatically injects vector(s) passed from the previous node, as well as any control parameters set in the CTRL panel UI.

Please see https://github.com/flojoy-io/flojoy-desktop/tree/main/PYTHON/FUNCTIONS for more usage examples.

Supported data types

See https://github.com/flojoy-io/flojoy-python/issues/4

Reconcilers

Flojoy nodes should try to accomodate any reasonable combination of inputs that a first-time Flojoy Studio user might try.

For example, the ADD node should make a best effort to do something reasonable when a matrix is added to a DataFrame, or a 2 matrices of a different size are added.

For this reason, we've created the Reconciler class to handle the process of turning different data types into compatible, easily added objects.

An Example

Here's an example of the Reconciler in action from the ADD node. Just initialize the Reconciler and pass it pairs of primitives from within your DataContainers.

def ADD(dc_inputs: list[DataContainer], params: dict) -> DataContainer:
  ...

    dc_reconciler = Reconciler()
    cur_sum = dc_inputs[0]
    for operand_n in dc_inputs[1:]:
        # reconcile the types of the inputs before calling numpy
        reconciled_lhs, reconciled_rhs = dc_reconciler.reconcile(cur_sum.y, operand_n.y)
        cur_sum = np.add(reconciled_lhs, reconciled_rhs)
    return DataContainer(x=dc_inputs[0].x, y=cur_sum)

Customizing your Reconcilers for different Node Categories

Have a different idea about how you want your DataContainers to be interoperable? Subclass Reconciler and override the specific type pairs you're interested in.

For example, let's say we're writing image processing nodes, and we want special behavior when dealing with certain image-like DataContainers.

class ImageProcessingReconciler(Reconciler):
    def __init__():
        super().__init__()
    # override only for the pair of types you're interested in!
    def image__image(self, lhs, rhs):
      # special handling for reconciling two different images
      ...
      return reconciled_lhs, reconciled_rhs
    def grayscale__image(self, lhs, rhs):
      # special handling for reconciling a grayscale and an image
      ...
      return reconciled_lhs, reconciled_rhs

Publish Package on PYPI

Uploading file via Twine

You have to install twine package first if not installed already. To install twine run following command: pip install twine

  • Update version in setup.py. For example: version = '0.0.1' for prod version and version = '0.0.1-dev' for dev version release,
  • Run following command to make a distribution file: python3 setup.py sdist
  • To upload files on PYPI, run following command: twine upload dist/*

Note: You'll need username and password to make a release. Please get in touch with the team for credentials.

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

flojoy-0.4.1.tar.gz (44.2 kB view details)

Uploaded Source

Built Distribution

flojoy-0.4.1-py3-none-any.whl (51.2 kB view details)

Uploaded Python 3

File details

Details for the file flojoy-0.4.1.tar.gz.

File metadata

  • Download URL: flojoy-0.4.1.tar.gz
  • Upload date:
  • Size: 44.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.11.9 Darwin/23.4.0

File hashes

Hashes for flojoy-0.4.1.tar.gz
Algorithm Hash digest
SHA256 c29ba6d7e498ccfe6e45a2382fae1fbeec14411364ac7ecb5d37b2388bf331a3
MD5 017a4af998d72a24e47f726a35fc6006
BLAKE2b-256 7530e828eeda1049dfda983476580d3ca57ed16384d69352b8476cd7393db7bc

See more details on using hashes here.

File details

Details for the file flojoy-0.4.1-py3-none-any.whl.

File metadata

  • Download URL: flojoy-0.4.1-py3-none-any.whl
  • Upload date:
  • Size: 51.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.11.9 Darwin/23.4.0

File hashes

Hashes for flojoy-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4a15f195d4feca055c4ec111a17edd541f73007c8755e6a6e6d65fee94f27d29
MD5 a25ce1c11f0c2b086cf9f6122acdaf7c
BLAKE2b-256 383878e44fd59cdee85867073affe1932ace7e63b33cb617c09566cb62926381

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