Skip to main content

A composable app infrastructure for scientific computing

Project description

Coverage Status Codacy Badge Ruff CI

scinexus

A composable app infrastructure for scientific computing. What dataclasses are for structured data, scinexus apps are for structured algorithms.

Many scientific problems require repeating calculations across many files or database records. Such tasks suit data-level parallelism, but writing robust, maintainable code for them is often tedious and quickly becomes complex.

As the Unix philosophy articulates, writing algorithms that do one thing well and can be composed together through piping data of known type is a Very Good Thing™.

scinexus encourages this design pattern. We leverage the Python type annotation system to govern the compatibility (composability) of different applications. This enables in-process composition of your applications with validation of the consistency of the pipeline and the consistency of the data being run through it.

scinexus is designed for scientific reproducibility. Scientific computations should record all conditions needed to reproduce an analysis. scinexus reduces the effort by intercepting all arguments (including defaults) used in app construction and logging the resulting app state.

Examples

Developers can choose inheriting from a base class or use the scinexus.define_app decorator to make composable apps. The following examples show simple composition

Loading files so missing data does not cause a crash
from scinexus import define_app


@define_app(app_type="loader")
def read_json(path: str) -> dict:
    import json

    with open(path) as f:
        return json.load(f)


@define_app
def validate(data: dict, required_field: str) -> dict:
    if required_field not in data:
        # this becomes a NotCompleted sentinel object
        # your run doesn't crash!
        raise ValueError(f"missing {required_field!r} field")
    return data


app = read_json() + validate(required_field="name")

You can apply app to a single file path as app(filepath), or operate in parallel (and show a progress bar) on a sequence of file paths as

results = list(app.as_completed(["some_file_path.json", "some_other_file_path.json"], parallel=True, show_progress=True)
A contrived numerical example
from scinexus import define_app


@define_app
def normalise(values: list[float]) -> list[float]:
    lo, hi = min(values), max(values)
    return [(v - lo) / (hi - lo) for v in values]


@define_app
def threshold(values: list[float]) -> list[bool]:
    return [v > 0.5 for v in values]


app = normalise() + threshold()
app([1.0, 5.0, 3.0, 9.0])
A configurable app
from scinexus import define_app


@define_app(app_type="loader")
def load_csv(path: str) -> list[dict]:
    import csv

    with open(path) as f:
        return list(csv.DictReader(f))


@define_app
class summarise:
    def __init__(self, column: str) -> None:
        """column contains the values to produce summary stats for"""
        self.column = column

    def main(self, rows: list[dict]) -> dict[str, float]:
        vals = [float(r[self.column]) for r in rows]
        return {"mean": sum(vals) / len(vals), "min": min(vals), "max": max(vals)}


app = load_csv() + summarise(column="price")

Features

  • Type checking at composition time
  • Durable computing -- failures recorded as NotCompleted records, not exceptions
  • Data-level parallel execution via loky or MPI
  • Progress bars (tqdm or rich)
  • Automated logging and citation tracking
  • Checkpointing via data stores (directory, SQLite)

Installation

pip install scinexus

History

The app framework and utility functions in scinexus incubated inside cogent3 from March 2019, accumulating over five years of development, testing, and real-world use in computational genomics before being extracted into a standalone package. The design is mature and has underpinned analyses in published studies.

The extraction into scinexus makes the infrastructure available to any scientific Python project, free of the cogent3 dependency.

We acknowledge here that many members of the cogent3 community contributed to the code that now lives here, including @rmcar17, @Nick-Foto, @KatherineCaley, @fredjaya, and @khiron.

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

scinexus-2026.4.17a1.tar.gz (249.7 kB view details)

Uploaded Source

Built Distribution

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

scinexus-2026.4.17a1-py3-none-any.whl (50.8 kB view details)

Uploaded Python 3

File details

Details for the file scinexus-2026.4.17a1.tar.gz.

File metadata

  • Download URL: scinexus-2026.4.17a1.tar.gz
  • Upload date:
  • Size: 249.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for scinexus-2026.4.17a1.tar.gz
Algorithm Hash digest
SHA256 7a782e776e2328850eb65efe75fc3f2ee12f6f90702eba45479e30e6cd4917ab
MD5 a24e7f67e28339173e0907c42c073fad
BLAKE2b-256 3ea9fa572a2e8bdfe0b2d4bc0fe2196a4fb865188478b3a4c28a92f4045a809f

See more details on using hashes here.

Provenance

The following attestation bundles were made for scinexus-2026.4.17a1.tar.gz:

Publisher: release.yml on cogent3/scinexus

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

File details

Details for the file scinexus-2026.4.17a1-py3-none-any.whl.

File metadata

  • Download URL: scinexus-2026.4.17a1-py3-none-any.whl
  • Upload date:
  • Size: 50.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for scinexus-2026.4.17a1-py3-none-any.whl
Algorithm Hash digest
SHA256 f401be1e90600210c51e582e34b492abd0d0519f9359009ace89a919a2c4f5d1
MD5 a5828a39767985b90e25391e10304f7c
BLAKE2b-256 7480ce485db3bfeaed8fbdfd6f617e3129abff5aca5731b7d1566afc5a605841

See more details on using hashes here.

Provenance

The following attestation bundles were made for scinexus-2026.4.17a1-py3-none-any.whl:

Publisher: release.yml on cogent3/scinexus

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

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page