Skip to main content

AsterStore

AsterStore 为普通文件提供数据集级别的原子发布、一次回退和维护清理。适合定期生成数据、日常读取最新结果、保留上一份成功结果的工作流。

每个数据集有两个版本槽位:current 用于日常读取,rollback 保存上一次成功发布的 current。文件和描述它们的元数据可以一起发布。核心不解释文件内容,没有第三方运行依赖。

安装

要求 Python 3.11+,以及支持 POSIX 文件锁、硬链接和原子替换的文件系统。从当前仓库安装:

pip install 'git+https://github.com/Aequiludium/asterstore.git@main'
# 需要可选的 Parquet 扫描适配器时:
pip install 'asterstore[polars] @ git+https://github.com/Aequiludium/asterstore.git@main'

需要固定部署内容时,将 main 换成经过验证的提交 SHA。

快速开始

下面的示例使用临时目录,可以直接运行:

from pathlib import Path
from tempfile import TemporaryDirectory

from asterstore import Repository

with TemporaryDirectory() as temporary:
    repo = Repository(Path(temporary) / "store")
    repo.initialize()

    with repo.prepare("prices", expected_revision=0) as draft:
        draft.allocate("data").write_bytes(b"first result")
        candidate = draft.seal()
        assert candidate.files(keys=["data"])[0].read_bytes() == b"first result"
        head = draft.commit()

    with repo.prepare("prices", expected_revision=head.revision) as draft:
        draft.reuse_current()
        draft.allocate("data").write_bytes(b"second result")
        draft.seal()
        head = draft.commit()

    assert repo.open("prices").files()[0].read_bytes() == b"second result"
    repo.rollback("prices", expected_revision=head.revision)
    assert repo.open("prices").files()[0].read_bytes() == b"first result"

    # 此例没有并行读写;实际应用须先停止新任务并等待已有读取完成。
    repo.clean("prices", quiescent=True)

文件路径

已有数据可以原位接管,不复制、不移动、不建立硬链接:

with repo.prepare("prices") as draft:
    draft.adopt("data", "/data/prices/existing.parquet")
    draft.seal()
    draft.commit()

新文件使用 draft.allocate("data", path="/data/prices/new.parquet") 指定完整路径。它独占创建并返回该路径,已有文件不会被覆盖。省略 path 时使用仓库默认布局。

相对路径以仓库根为基准,绝对路径可以位于仓库外、不同文件系统。seal 记录归属后,文件必须保持不可变,并允许 clean 在不再被保留版本引用时删除它。未封存的自定义路径文件仍由调用方处理。

完整示例见 managed_paths.py,边界见文件路径与归属。

工作方式

  • 发布:准备文件,封存完整成员清单,完成业务检查,显式提交。current 与 rollback 一起原子切换。
  • 读取:一次 open 固定一个版本;后续发布不会自动改变这个 Binding。
  • 复用:继承 current 的成员,只写变化的文件。复用限于同一数据集。
  • 回退:将 rollback 提升为 current,清空 rollback;下次成功发布重新保留两个版本。
  • 清理:在调用方协调的维护窗口内,删除两个保留版本之外的文件和清单。

已封存文件必须保持不可变。发布可以与读取并行,清理必须等待全部相关读取结束,包括延迟计算最后一次文件访问。quiescent=True 是调用方的声明,不会自动暂停读者。

默认启用持久化同步。提交报错可能发生在原子切换之后,需要读取 head 核实结果。两个版本用于操作回退,不代替备份。

文档

可运行示例:双版本、Parquet。规模检查见 benchmarks。

Metadata

Release files for asterstore 0.4.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 asterstore 0.4.1
File Size Uploaded
asterstore-0.4.1.tar.gz 46.3 kB Details

Built distribution (wheel)

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

Total release size: 69.0 kB

Release files / asterstore-0.4.1.tar.gz

Download URL asterstore-0.4.1.tar.gz
Size 46.3 kB
Tags Source
SHA-256 checksum
How to use checksums
faf04e99b3ed3d00a2fb50104aeaea7e87d60feda7586202099e573acf8c0ad8
BLAKE2b-256 checksum
How to use checksums
a3a8a9a8a4270626e42d3a4c3520e9c4086d1206dc90681171e82cd178fb04ea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 14, 2026.

Transparency log

Release files / asterstore-0.4.1-py3-none-any.whl

Download URL asterstore-0.4.1-py3-none-any.whl
Size 22.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
efbe9be14dd3020b9f8a7e5ebe05c4af95033f06c6f93f7ee26b0ca462b5bf2a
BLAKE2b-256 checksum
How to use checksums
719fa5f8b501955f3ab92edac4d06c743004499bfa9d64e63a4b06cbc150be35
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 14, 2026.

Transparency log

Release history Release notifications | RSS feed

0.5.1

2 release files

0.5.0

2 release files

This release

0.4.1 This release

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release 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