Skip to main content

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.

Metadata

Release files for flojoy 0.4.1

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

Source distribution (sdist)

Source distribution for flojoy 0.4.1
File Size Uploaded Provenance Actions
flojoy-0.4.1.tar.gz 44.2 kB Without provenance Details for flojoy-0.4.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for flojoy 0.4.1
File Interpreter ABI Platform Actions
flojoy-0.4.1-py3-none-any.whl Python 3 none any Details for flojoy-0.4.1-py3-none-any.whl

Total release size: 95.5 kB

Release files / flojoy-0.4.1.tar.gz

Download URL flojoy-0.4.1.tar.gz
Size 44.2 kB
Tags Source
SHA-256 checksum
How to use checksums
c29ba6d7e498ccfe6e45a2382fae1fbeec14411364ac7ecb5d37b2388bf331a3
BLAKE2b-256 checksum
How to use checksums
7530e828eeda1049dfda983476580d3ca57ed16384d69352b8476cd7393db7bc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.2 CPython/3.11.9 Darwin/23.4.0

Release files / flojoy-0.4.1-py3-none-any.whl

Download URL flojoy-0.4.1-py3-none-any.whl
Size 51.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4a15f195d4feca055c4ec111a17edd541f73007c8755e6a6e6d65fee94f27d29
BLAKE2b-256 checksum
How to use checksums
383878e44fd59cdee85867073affe1932ace7e63b33cb617c09566cb62926381
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.2 CPython/3.11.9 Darwin/23.4.0

Security for flojoy 0.4.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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