Skip to main content

Dataflow

Python framework to record and validate data pre-processing steps in Data Science and AI workflows. Still in ⚠️Development⚠️

Installation

pip install data-flow

❓ How it works

If you have some raw data you often apply some functions that change your data to fit a specific problem. The problem is that there is no simple tool that can record and validate all the changes that happened to your data while you were working with it. It becomes a bigger problem when you have lots of pre-processing steps or work in a team with other developers.

By using Dataflow, you can easily wrap your functions with decorators and record/validate all the changes. You can think of Dataflow as a migration tool, but for data pipelines.

Example

Without Dataflow, your code can look like this:

raw_data = [1, 2, 3, ...]

unique_data = list(set(raw_data))
sorted_data = sorted(unique_data)
final_data = [
    value for value in sorted_data if value >= 5
]

print(final_data)   # [2, 3, 4, 5]

It is a simple example, buy you can imagine your Torch, Tensorflow, Pandas or Numpy pre-processing here. However, there are some problems:

  1. Are we sure the data is correctly processed?
  2. What changes were made and in what order?
  3. Can we replicate the changes easily?

These problems have haunted many, but you can solve them easily with Dataflow:

from dataflow.mutations import mutation
from dataflow.validations.pipelines.after import after
from dataflow.validations.pipelines.before import before


@mutation()     # Mutation is a step in your pipeline
@before(lambda data: len(data) > 0, hint="Data is empty")    # Data is not empty before we run the mutation
@after(lambda data: len(data) > 5, hint="Data size is less than 5")  # Data has enough entries after the mutation
def remove_duplicates(data: list[float]) -> list[float]:
    return list(set(data))


@mutation()     # Another mutation without any validations
def sort(data: list[float], reverse: bool = False) -> list[float]:
    return sorted(data, reverse=reverse)


@mutation()     # Mutation with a simple validation
@after(not_lambda_validation)
def remove_under_threshold(data: list[float], threshold: float) -> list[float]:
    return [value for value in data if value >= threshold]


mutation_pipeline = sort() >> remove_duplicates() >> remove_under_threshold(threshold=2)
final_data = mutation_pipeline(data=[1, 2, 3, 4, 5] * 100)    # final data = [2, 3, 4, 5]
print(mutation_pipeline)    # sort() >> remove_duplicates() >> remove_under_threshold(threshold=2)

As you can see, we don't change much in the data pre-processing itself, but only add some decorators and use some new syntax to validate that the changes are correct. Dataflow enables users to easily find pitfalls and issues in their pipelines.

Features

  • Friendly -> you can use Dataflow with any environment and run mutations in various data-sources. Mutations and validations can be extended to work anywhere.
  • Easy to master -> you only need to learn a few basic commands and don't have to rewrite your whole codebase to fit this framework.
  • Extendable -> write your custom mutations, validations, pipelines without worrying about breaking something internal. Dataflow has very few rules on how to write the code.

License

MIT

Metadata

Release files for python-dataflow 0.0.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 python-dataflow 0.0.1
File Size Uploaded Provenance
python_dataflow-0.0.1.tar.gz 14.9 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for python-dataflow 0.0.1
File Interpreter ABI Platform
python_dataflow-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 34.2 kB

Release files / python_dataflow-0.0.1.tar.gz

Download URL python_dataflow-0.0.1.tar.gz
Size 14.9 kB
Tags Source
SHA-256 checksum
How to use checksums
04a4b8a6c45dbd1b5260d92df5965ce2f6d9408c46c0de006279c91d7ff3dab1
BLAKE2b-256 checksum
How to use checksums
82c2b8315d18f9df25816b05935ada0c0d4877adc5d058edef7c2dda0809c979
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.0rc1

Release files / python_dataflow-0.0.1-py3-none-any.whl

Download URL python_dataflow-0.0.1-py3-none-any.whl
Size 19.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
18763929fde0ca8a53ea6f7716820740e71e42a7122a44a9ab6330bb16d80663
BLAKE2b-256 checksum
How to use checksums
a7b9182c11396da89b0c8fa2b04656e0e408a9aa05050f296e6e4b8c65e8c948
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.0rc1

Security for python-dataflow 0.0.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.

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files No provenance

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