Skip to main content

SciLineage

Lineage tracking for Python data pipelines.

SciLineage is a lightweight library for building data processing pipelines with automatic provenance tracking. It captures the full computational lineage of your results, enabling reproducibility and intelligent caching.

Features

  • Automatic Lineage Tracking: Every computation captures its inputs and function, building a complete provenance graph
  • Input Classification: Automatically distinguishes variable inputs from constants for accurate lineage
  • Pluggable Caching: Register a backend via configure_backend() to enable cache lookups via lineage hashes
  • Lightweight: Core dependency is only scicanonicalhash
  • Type Safe: Full type hints throughout

Installation

pip install scilineage

Quick Start

Basic Usage

from scilineage import lineage_fcn

@lineage_fcn
def process(data, factor):
    return data * factor

# Call returns a LineageFcnResult, not the raw result
result = process([1, 2, 3], 2)

# Access the computed value
print(result.data)  # [2, 4, 6]

# Access lineage information
print(result.invoked.inputs)         # {'arg_0': [1, 2, 3], 'arg_1': 2}
print(result.invoked.fcn.fcn.__name__)  # 'process'

Multi-Output Functions

@lineage_fcn(unpack_output=True)
def split_data(data):
    mid = len(data) // 2
    return data[:mid], data[mid:]

first, second = split_data([1, 2, 3, 4])
print(first.data)   # [1, 2]
print(second.data)  # [3, 4]

Chaining Computations

@lineage_fcn
def normalize(data):
    max_val = max(data)
    return [x / max_val for x in data]

@lineage_fcn
def scale(data, factor):
    return [x * factor for x in data]

raw = [10, 20, 30, 40]
normalized = normalize(raw)
scaled = scale(normalized, 100)

print(scaled.data)  # [25.0, 50.0, 75.0, 100.0]

Extracting Lineage

from scilineage import extract_lineage, get_upstream_lineage

@lineage_fcn
def step1(x):
    return x + 1

@lineage_fcn
def step2(x):
    return x * 2

result = step2(step1(5))

lineage = extract_lineage(result)
print(lineage.function_name)   # 'step2'
print(lineage.function_hash)   # SHA-256 of function bytecode

chain = get_upstream_lineage(result)
for record in chain:
    print(f"{record['function_name']}: inputs={record['inputs']}")

Manual Interventions

from scilineage import manual

# Step outside the pipeline for a manual correction
edited_data = [1, 2, 3]

# Re-enter the pipeline — the intervention is documented in lineage
corrected = manual(
    edited_data,
    label="outlier_removal",
    reason="amplitude < 0.1 in trial 3 is sensor artifact",
)

API Reference

@lineage_fcn(unpack_output=False, unwrap=True, generates_file=False)

Decorator to convert a function into a LineageFcn.

  • unpack_output: Whether to unpack a tuple return into separate LineageFcnResults
  • unwrap: If True, automatically unwrap LineageFcnResult inputs to their raw data
  • generates_file: If True, marks the function as producing files as side effects

LineageFcnResult

Wrapper around computed values that carries lineage.

  • .data: The actual computed value
  • .invoked: The LineageFcnInvocation that produced this
  • .hash: Unique hash based on computation lineage
  • .output_num: Index for multi-output functions

LineageFcnInvocation

Represents a specific function invocation with captured inputs.

  • .fcn: The parent LineageFcn (function wrapper)
  • .inputs: Dict of captured input values
  • .outputs: Tuple of LineageFcnResult results
  • .compute_lineage_hash(): Generate lineage hash for cache key computation

LineageFcn

The decorated function wrapper.

  • .fcn: The original wrapped function
  • .hash: SHA-256 hash of function bytecode
  • .invocations: All LineageFcnInvocations created from this

License

MIT License - see LICENSE for details.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

scilineage-0.1.17.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

scilineage-0.1.17-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file scilineage-0.1.17.tar.gz.

File metadata

  • Download URL: scilineage-0.1.17.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for scilineage-0.1.17.tar.gz
Algorithm Hash digest
SHA256 8caacf74a9a16d4388f439d6e10c9dd918f99849329fbf5d5581798f7067859a
MD5 f55c4c9e2cd08b80038d173f8ae5d066
BLAKE2b-256 4e61e536fd5405ec92cd1afc7a99fea82269ae7c6a16cf26292423c690784e2e

See more details on using hashes here.

Provenance

The following attestation bundles were made for scilineage-0.1.17.tar.gz:

Publisher: publish.yml on mtillman14/scistack

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file scilineage-0.1.17-py3-none-any.whl.

File metadata

  • Download URL: scilineage-0.1.17-py3-none-any.whl
  • Upload date:
  • Size: 6.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for scilineage-0.1.17-py3-none-any.whl
Algorithm Hash digest
SHA256 2878a2b5d4b59dba3c1745901435563f7f0ce13b95c4d3a3236de5a40a382bc2
MD5 90acf235869804845172c0b4c23ec7a3
BLAKE2b-256 e9783266142da81c0ca01971e8ddf2982bceb5d9daf88f3bf733f78cd2ffee47

See more details on using hashes here.

Provenance

The following attestation bundles were made for scilineage-0.1.17-py3-none-any.whl:

Publisher: publish.yml on mtillman14/scistack

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.1.29

2 files

0.1.28

2 files

0.1.26

2 files

0.1.21

2 files

0.1.20

2 files

0.1.19

2 files

0.1.18

2 files

This release

0.1.17 This release

2 files

0.1.16

2 files

0.1.14

2 files

0.1.13

2 files

0.1.11

2 files

0.1.10

2 files

0.1.0

2 files

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