Skip to main content

autostorage

License: MIT Pixi Badge Code style: ruff Typing: ty Copier

A SQLModel/SQLAlchemy persistence layer for computational chemistry workflow data, built on top of autogeom. It stores molecular geometries, chemical identities, trajectories, stationary points, calculation results (energies, gradients, Hessians), and the calculations/reaction steps that connect them, as a graph of related rows in a SQLite database.

GeometryRow extends autogeom.Geometry directly rather than wrapping it, so a Geometry can be persisted with no conversion step, and autogeom's functions accept the rows directly. Chemical identities (InChI, SMILES, Hill formula) are generated automatically for stationary points by the algorithms in IdentityAlgorithmRegistry, to which you can add your own.

Installation

autostorage requires Python 3.13 or later. With Pixi, add it from the avcopan/automech channel on prefix.dev, which also has autogeom:

pixi workspace channel add https://repo.prefix.dev/avcopan/automech
pixi add autostorage

Or install it from PyPI:

pip install autostorage  # or: uv add autostorage

Usage

import numpy as np
from sqlmodel import select

from autostorage import (
    CalculationGeometryLink,
    CalculationRow,
    Database,
    GeometryRow,
    ModelRow,
    PropertyValueRow,
    Role,
    StationaryPointRow,
    energy_property_kind,
    query,
    rdkit_inchi,
)

# Open (or create) a SQLite database; ":memory:" also works for scratch use.
with Database("workflow.db") as db, db.session() as session:
    # Create a model specifying the program, method, and basis.
    model = ModelRow(program="orca", method="b3lyp", basis="def2-svp")

    # Create a calculation using this model.
    calc = CalculationRow(model=model, calc_type="energy")

    # Create a geometry (validated by autogeom: known elements, consistent spin).
    geo = GeometryRow(
        symbols=["H", "O", "H"],
        coordinates=np.array([[0, 0, 0.96], [0, 0, 0], [0.93, 0, -0.24]]),
        charge=0,
        spin=0,
    )

    # Link the geometry to the calculation as an input.
    link = CalculationGeometryLink(calculation=calc, geometry=geo, role=Role.INPUT)

    # Add all objects to the session and commit.
    session.add_all([model, calc, geo, link])
    session.commit()

    # Attach an energy to the geometry/calculation pair. Values are validated
    # against their property kind ("energy", "gradient", "hessian") on flush.
    energy = PropertyValueRow(
        geometry=geo,
        calculation=calc,
        property_kind_name=energy_property_kind.name,
        value=-76.02,
    )
    session.add(energy)
    session.commit()

    # Query the energy back by geometry and property kind.
    found = session.exec(
        select(PropertyValueRow).where(
            PropertyValueRow.geometry_id == geo.id,
            PropertyValueRow.property_kind_name == "energy",
        )
    ).one()
    print(float(found.value))

    # Stationary points are automatically given identities (InChI, SMILES,
    # Hill formula), which can be used to look them up.
    session.add(StationaryPointRow(geometry=geo, calculation=calc))
    session.commit()
    stmt = query.stationary_point_by_identity(rdkit_inchi, "InChI=1S/H2O/h1H2")
    print(session.exec(stmt).all())

Database.session() returns an AutostorageSession (a sqlmodel.Session, so session.exec(...) is available) that supports the context manager protocol. Validation and automatic identities are only applied by these sessions. Sessions don't commit automatically: call session.commit() explicitly to persist changes.

For a full worked example covering geometries, trajectories, results, stationary points, stages, and steps, see examples/stationary.py.

See the documentation for the user guide and API reference.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. See Contributing for the workflow and design rules.

License

This project is licensed under the MIT License.

Credits

This package was created with copier and the avcopan/copier-pixi-python project template.

Metadata

Release files for autostorage 0.0.22

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

Source distribution (sdist)

Source distribution for autostorage 0.0.22
File Size Uploaded Provenance Actions
autostorage-0.0.22.tar.gz 24.7 kB Without provenance Details for autostorage-0.0.22.tar.gz

Built distribution (wheel)

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

Total release size: 52.0 kB

Release files / autostorage-0.0.22.tar.gz

Download URL autostorage-0.0.22.tar.gz
Size 24.7 kB
Tags Source
SHA-256 checksum
How to use checksums
b6b6e1828ce6d7782b09b52bd85e56dd7e1dcc448a88bb5828e7814bdc11af3e
BLAKE2b-256 checksum
How to use checksums
c345ad13b6c0b94441fde8cb2fb0811d3b73cc8f7ddd57cd1e1617c7852843ce
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / autostorage-0.0.22-py3-none-any.whl

Download URL autostorage-0.0.22-py3-none-any.whl
Size 27.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
41b1e608dfc54060e5ec7f31b10e0be143d48ae7e53a2c9afe4ceddfde99fb5c
BLAKE2b-256 checksum
How to use checksums
75a58999c3badc5d72837f4eeb1b92bed1b2d6f4b5a6eaf3daff356d19ece1ad
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for autostorage 0.0.22

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