A-Pipe
A-Pipe allows to create data pipelines with lazy computation and caching.
Features:
- Lazy computation and cache loading
- Pickle and parquet serialization
- Support for hashing of
numpyarrays andpandasDataFrames - Support for
dask.Delayedobjects
Installation
pip install apipe
Examples
Simple function caching
import time
import apipe
import numpy as np
from loguru import logger
@apipe.eager_cached()
def load_data(table: str):
time.sleep(1)
arr = np.ones(5)
logger.debug(f"transferred array data from table={table}")
return arr
logger.info("start loading data")
# --- First pass: transfer data and save on disk
data = load_data("weather-ldn")
logger.info(f"finished loading data: {load_data()}")
# --- Second pass: load data from disk
data = load_data("weather-ldn")
logger.info(f"finished loading data: {load_data()}")
Data pipeline with lazy execution and caching
import apipe
import pandas as pd
import numpy as np
from loguru import logger
# --- Define data transformations via step functions (similar to dask.delayed)
@apipe.delayed_cached() # lazy computation + caching on disk
def load_1():
df = pd.DataFrame({"a": [1., 2.], "b": [0.1, np.nan]})
logger.debug("Loaded {} records".format(len(df)))
return df
@apipe.delayed_cached() # lazy computation + caching on disk
def load_2(timestamp):
df = pd.DataFrame({"a": [0.9, 3.], "b": [0.001, 1.]})
logger.debug("Loaded {} records".format(len(df)))
return df
@apipe.delayed_cached() # lazy computation + caching on disk
def compute(x, y, eps):
assert x.shape == y.shape
diff = ((x - y).abs() / (y.abs()+eps)).mean().mean()
logger.debug("Difference is computed")
return diff
# --- Define pipeline dependencies
ts = pd.Timestamp(2019, 1, 1)
eps = 0.01
s1 = load_1()
s2 = load_2(ts)
diff = compute(s1, s2, eps)
# --- Trigger pipeline execution (first pass: compute everything and save on disk)
logger.info("diff: {:.3f}".format(apipe.delayed_compute((diff, ))[0]))
# --- Trigger pipeline execution (second pass: load from disk the end result only)
logger.info("diff: {:.3f}".format(apipe.delayed_compute((diff, ))[0]))
See more examples in a notebook.
Metadata
Release files for apipe 0.1.9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| apipe-0.1.9.tar.gz | 12.2 kB | Without provenance | Details for apipe-0.1.9.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| apipe-0.1.9-py3-none-any.whl | Python 3 | none | any | Details for apipe-0.1.9-py3-none-any.whl |
Total release size: 28.4 kB
Release files / apipe-0.1.9.tar.gz
| Download URL | apipe-0.1.9.tar.gz |
|---|---|
| Size | 12.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6fb8916f1d09878801daad17a58019c8ee8e220021085eb55f7393e4e88cf1b3
|
|
BLAKE2b-256 checksum How to use checksums |
2bc96a8be4aa4929e817b741ae82062e957f4aa073127f7177f1d7d95658c815
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.2 CPython/3.9.19 Linux/6.5.0-1018-azure
|
Release files / apipe-0.1.9-py3-none-any.whl
| Download URL | apipe-0.1.9-py3-none-any.whl |
|---|---|
| Size | 16.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ff84fc3fcbd652b7d97403cbcac8969d59c954b4e3ae0f481c170bb29249f39e
|
|
BLAKE2b-256 checksum How to use checksums |
ece08628d9a07755418ad35e84317b7f5d3bcd50c285ec2ff20b09c602943fb3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.2 CPython/3.9.19 Linux/6.5.0-1018-azure
|
Security for apipe 0.1.9
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.