straw-queue 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. straw_queue-0.1.0/.github/workflows/tests.yml +69 -0
  2. straw_queue-0.1.0/.github/workflows/wheels.yml +149 -0
  3. straw_queue-0.1.0/CHANGELOG.md +30 -0
  4. straw_queue-0.1.0/CHANGELOG_zh.md +17 -0
  5. straw_queue-0.1.0/CONTRIBUTING.md +42 -0
  6. straw_queue-0.1.0/CONTRIBUTING_zh.md +27 -0
  7. straw_queue-0.1.0/Cargo.lock +523 -0
  8. straw_queue-0.1.0/Cargo.toml +34 -0
  9. straw_queue-0.1.0/LICENSE +21 -0
  10. straw_queue-0.1.0/PKG-INFO +203 -0
  11. straw_queue-0.1.0/README.md +175 -0
  12. straw_queue-0.1.0/README_zh.md +118 -0
  13. straw_queue-0.1.0/docs/APPLICATIONS.md +51 -0
  14. straw_queue-0.1.0/docs/APPLICATIONS_zh.md +28 -0
  15. straw_queue-0.1.0/docs/BENCHMARKS.md +125 -0
  16. straw_queue-0.1.0/docs/BENCHMARKS_zh.md +73 -0
  17. straw_queue-0.1.0/docs/BUILDING.md +163 -0
  18. straw_queue-0.1.0/docs/BUILDING_zh.md +104 -0
  19. straw_queue-0.1.0/docs/DESIGN.md +86 -0
  20. straw_queue-0.1.0/docs/DESIGN_zh.md +57 -0
  21. straw_queue-0.1.0/docs/FILESYSTEM.md +105 -0
  22. straw_queue-0.1.0/docs/FILESYSTEM_zh.md +63 -0
  23. straw_queue-0.1.0/docs/FORMAT.md +231 -0
  24. straw_queue-0.1.0/docs/FORMAT_zh.md +116 -0
  25. straw_queue-0.1.0/docs/PROTOCOL_AND_VERIFICATION.md +237 -0
  26. straw_queue-0.1.0/docs/PROTOCOL_AND_VERIFICATION_zh.md +122 -0
  27. straw_queue-0.1.0/docs/README.md +18 -0
  28. straw_queue-0.1.0/docs/README_zh.md +18 -0
  29. straw_queue-0.1.0/docs/USAGE.md +281 -0
  30. straw_queue-0.1.0/docs/USAGE_zh.md +167 -0
  31. straw_queue-0.1.0/docs/VERIFICATION.md +106 -0
  32. straw_queue-0.1.0/docs/VERIFICATION_zh.md +73 -0
  33. straw_queue-0.1.0/examples/multiprocess.py +101 -0
  34. straw_queue-0.1.0/examples/records.py +40 -0
  35. straw_queue-0.1.0/examples/tensors.py +45 -0
  36. straw_queue-0.1.0/examples/work_queue.py +58 -0
  37. straw_queue-0.1.0/pyproject.toml +61 -0
  38. straw_queue-0.1.0/rust/coordinator.rs +1501 -0
  39. straw_queue-0.1.0/rust/gc.rs +497 -0
  40. straw_queue-0.1.0/rust/journal.rs +185 -0
  41. straw_queue-0.1.0/rust/lib.rs +76 -0
  42. straw_queue-0.1.0/rust/python.rs +578 -0
  43. straw_queue-0.1.0/rust/store.rs +1069 -0
  44. straw_queue-0.1.0/src/straw/__init__.py +21 -0
  45. straw_queue-0.1.0/src/straw/backend.py +61 -0
  46. straw_queue-0.1.0/src/straw/benchmark.py +614 -0
  47. straw_queue-0.1.0/src/straw/coordinator.py +244 -0
  48. straw_queue-0.1.0/src/straw/errors.py +49 -0
  49. straw_queue-0.1.0/src/straw/inspect.py +128 -0
  50. straw_queue-0.1.0/src/straw/journal.py +24 -0
  51. straw_queue-0.1.0/src/straw/protocol.py +184 -0
  52. straw_queue-0.1.0/src/straw/reporting.py +22 -0
  53. straw_queue-0.1.0/src/straw/rpc.py +149 -0
  54. straw_queue-0.1.0/src/straw/store.py +301 -0
  55. straw_queue-0.1.0/src/straw/tensor.py +316 -0
  56. straw_queue-0.1.0/src/straw/tracing.py +56 -0
  57. straw_queue-0.1.0/tests/native.rs +129 -0
  58. straw_queue-0.1.0/tests/test_benchmark_profile.py +102 -0
  59. straw_queue-0.1.0/tests/test_consumer_rewind.py +188 -0
  60. straw_queue-0.1.0/tests/test_filesystem_queue.py +966 -0
  61. straw_queue-0.1.0/tests/test_gc_extent_validation.py +93 -0
  62. straw_queue-0.1.0/tests/test_online_gc.py +276 -0
  63. straw_queue-0.1.0/tests/test_packed_store.py +266 -0
  64. straw_queue-0.1.0/tests/test_read_session.py +257 -0
  65. straw_queue-0.1.0/tests/test_tensor.py +79 -0
  66. straw_queue-0.1.0/tools/check_wheel.py +138 -0
  67. straw_queue-0.1.0/verification/crash_campaign.py +408 -0
  68. straw_queue-0.1.0/verification/gc_cross_client.py +44 -0
  69. straw_queue-0.1.0/verification/gc_scale.py +125 -0
  70. straw_queue-0.1.0/verification/ownership_model.py +201 -0
@@ -0,0 +1,69 @@
1
+ name: tests
2
+
3
+ on:
4
+ push:
5
+ pull_request:
6
+ workflow_dispatch:
7
+
8
+ permissions:
9
+ contents: read
10
+
11
+ jobs:
12
+ checks:
13
+ name: Rust tests and code checks
14
+ runs-on: ubuntu-latest
15
+ timeout-minutes: 20
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+ - uses: dtolnay/rust-toolchain@stable
19
+ with:
20
+ components: rustfmt, clippy
21
+ - uses: actions/setup-python@v5
22
+ with:
23
+ python-version: '3.12'
24
+ - name: Install formatters
25
+ run: python -m pip install 'black>=24.8' 'isort>=5.13'
26
+ - name: Check formatting
27
+ run: |
28
+ cargo fmt --check
29
+ python -m black --check src tests examples tools verification
30
+ python -m isort --check-only src tests examples tools verification
31
+ - name: Lint native core and Python bindings
32
+ run: |
33
+ cargo clippy --locked --all-targets -- -D warnings
34
+ cargo clippy --locked --all-targets --features python -- -D warnings
35
+ - name: Run Rust tests
36
+ run: cargo test --locked
37
+
38
+ python:
39
+ name: Full suite / Python ${{ matrix.python }}
40
+ runs-on: ubuntu-latest
41
+ timeout-minutes: 30
42
+ strategy:
43
+ fail-fast: false
44
+ matrix:
45
+ python: ['3.10', '3.11', '3.12', '3.13']
46
+ steps:
47
+ - uses: actions/checkout@v4
48
+ - uses: dtolnay/rust-toolchain@stable
49
+ - uses: actions/setup-python@v5
50
+ with:
51
+ python-version: ${{ matrix.python }}
52
+ - name: Install build and test dependencies
53
+ run: |
54
+ python -m pip install 'build>=1.2' 'twine>=5' 'numpy>=1.24' 'pytest>=8'
55
+ python -m pip install 'torch>=2.3' --index-url https://download.pytorch.org/whl/cpu
56
+ - name: Build the wheel
57
+ run: python -m build --wheel
58
+ - name: Check package metadata
59
+ run: python -m twine check dist/*
60
+ - name: Run all Python and protocol tests against the installed wheel
61
+ # Includes examples, multiprocess recovery, the ownership model, crash
62
+ # injection, a bounded I/O/GC benchmark and trace verification.
63
+ run: python tools/check_wheel.py dist/*.whl --tests --report wheel-check.json
64
+ - uses: actions/upload-artifact@v4
65
+ if: always()
66
+ with:
67
+ name: test-report-py${{ matrix.python }}
68
+ path: wheel-check.json
69
+ if-no-files-found: warn
@@ -0,0 +1,149 @@
1
+ name: wheels
2
+ on:
3
+ workflow_dispatch:
4
+ pull_request:
5
+ push:
6
+ tags: ['v*']
7
+ permissions:
8
+ contents: read
9
+ jobs:
10
+ build:
11
+ runs-on: ubuntu-latest
12
+ timeout-minutes: 30
13
+ strategy:
14
+ fail-fast: false
15
+ matrix:
16
+ python-tag: ['310', '311', '312', '313']
17
+ steps:
18
+ - uses: actions/checkout@v4
19
+ - uses: PyO3/maturin-action@v1
20
+ with:
21
+ target: x86_64
22
+ # The action adds --manylinux; do not also pass --compatibility in args.
23
+ manylinux: '2_28'
24
+ args: --release --locked --strip --out dist --interpreter /opt/python/cp${{ matrix.python-tag }}-cp${{ matrix.python-tag }}/bin/python
25
+ - uses: actions/upload-artifact@v4
26
+ with:
27
+ name: wheel-cp${{ matrix.python-tag }}-linux-x86_64
28
+ path: dist/*.whl
29
+ if-no-files-found: error
30
+ smoke:
31
+ name: Verify wheel / Python ${{ matrix.python }}
32
+ needs: build
33
+ runs-on: ubuntu-latest
34
+ timeout-minutes: 20
35
+ strategy:
36
+ fail-fast: false
37
+ matrix:
38
+ include:
39
+ - python: '3.10'
40
+ tag: '310'
41
+ - python: '3.11'
42
+ tag: '311'
43
+ - python: '3.12'
44
+ tag: '312'
45
+ - python: '3.13'
46
+ tag: '313'
47
+ steps:
48
+ - uses: actions/checkout@v4
49
+ - uses: actions/setup-python@v5
50
+ with:
51
+ python-version: ${{ matrix.python }}
52
+ - uses: actions/download-artifact@v4
53
+ with:
54
+ name: wheel-cp${{ matrix.tag }}-linux-x86_64
55
+ path: dist
56
+ - run: python -m pip install 'numpy>=1.24' 'pytest>=8' 'twine>=5'
57
+ - run: python -m pip install 'torch>=2.3' --index-url https://download.pytorch.org/whl/cpu
58
+ - run: python -m twine check dist/*
59
+ - run: python tools/check_wheel.py dist/*.whl --tests --report wheel-check.json
60
+ - uses: actions/upload-artifact@v4
61
+ if: always()
62
+ with:
63
+ name: wheel-check-cp${{ matrix.tag }}
64
+ path: wheel-check.json
65
+ sdist:
66
+ runs-on: ubuntu-latest
67
+ timeout-minutes: 30
68
+ steps:
69
+ - uses: actions/checkout@v4
70
+ - uses: dtolnay/rust-toolchain@stable
71
+ - uses: actions/setup-python@v5
72
+ with:
73
+ python-version: '3.12'
74
+ - run: python -m pip install 'build>=1.2' 'twine>=5' 'numpy>=1.24' 'pytest>=8'
75
+ - run: python -m pip install 'torch>=2.3' --index-url https://download.pytorch.org/whl/cpu
76
+ - run: python -m build --sdist
77
+ - run: python -m twine check dist/*
78
+ - run: python -m pip wheel --no-deps dist/*.tar.gz --wheel-dir rebuilt
79
+ - run: python -m twine check rebuilt/*
80
+ - run: python tools/check_wheel.py rebuilt/*.whl --tests --report wheel-check.json
81
+ - uses: actions/upload-artifact@v4
82
+ with:
83
+ name: source-distribution
84
+ path: dist/*.tar.gz
85
+ if-no-files-found: error
86
+ - uses: actions/upload-artifact@v4
87
+ if: always()
88
+ with:
89
+ name: source-rebuild-check
90
+ path: wheel-check.json
91
+ publish:
92
+ name: Publish to PyPI
93
+ needs: [smoke, sdist]
94
+ if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
95
+ runs-on: ubuntu-latest
96
+ timeout-minutes: 10
97
+ environment:
98
+ name: pypi
99
+ url: https://pypi.org/p/straw-queue
100
+ permissions:
101
+ contents: read
102
+ id-token: write
103
+ steps:
104
+ - uses: actions/setup-python@v5
105
+ with:
106
+ python-version: '3.12'
107
+ - name: Download tested wheels
108
+ uses: actions/download-artifact@v4
109
+ with:
110
+ pattern: wheel-cp*-linux-x86_64
111
+ merge-multiple: true
112
+ path: dist
113
+ - name: Download tested source distribution
114
+ uses: actions/download-artifact@v4
115
+ with:
116
+ name: source-distribution
117
+ path: dist
118
+ - name: Check release contents and tag
119
+ env:
120
+ RELEASE_TAG: ${{ github.ref_name }}
121
+ run: |
122
+ python - <<'PY'
123
+ import email
124
+ import os
125
+ import tarfile
126
+ import zipfile
127
+ from pathlib import Path
128
+
129
+ version = os.environ["RELEASE_TAG"].removeprefix("v")
130
+ wheels = sorted(Path("dist").glob("*.whl"))
131
+ sdists = sorted(Path("dist").glob("*.tar.gz"))
132
+ assert len(wheels) == 4 and len(sdists) == 1, "Expected four wheels and one sdist"
133
+ assert {p.name.split("-")[2] for p in wheels} == {"cp310", "cp311", "cp312", "cp313"}
134
+ for path in wheels + sdists:
135
+ if path.suffix == ".whl":
136
+ with zipfile.ZipFile(path) as archive:
137
+ data = archive.read(next(p for p in archive.namelist() if p.endswith(".dist-info/METADATA")))
138
+ else:
139
+ with tarfile.open(path) as archive:
140
+ data = archive.extractfile(f"straw_queue-{version}/PKG-INFO").read()
141
+ metadata = email.message_from_bytes(data)
142
+ assert metadata["Name"] == "straw-queue", path
143
+ assert metadata["Version"] == version, f"{path}: version does not match {version}"
144
+ print(f"Verified {path.name}")
145
+ PY
146
+ - name: Publish distributions
147
+ uses: pypa/gh-action-pypi-publish@release/v1
148
+ with:
149
+ print-hash: true
@@ -0,0 +1,30 @@
1
+ # Changelog
2
+
3
+ [中文版](CHANGELOG_zh.md)
4
+
5
+ ## 0.1.0
6
+
7
+ Initial release of straw, a filesystem-based durable queue and shared tensor
8
+ store for AI applications, distributed as `straw-queue` under the MIT license.
9
+
10
+ - Rust storage, WAL, queue and ownership protocols with Python APIs. Multiple
11
+ machines can read and write through a shared filesystem; the initial shared
12
+ storage target is JuiceFS.
13
+ - Packed immutable records and embedded manifests, batched publication and
14
+ size-based file rotation, avoiding a file per sample or tensor.
15
+ - Bytes and custom codecs, NumPy/PyTorch tensors, checked lazy row reads and
16
+ native read sessions that reuse authenticated indices.
17
+ - Shared tensor references across queues, tensor-level copy-on-write, explicit
18
+ reader/checkpoint ownership and optional online GC of unreferenced sealed packs.
19
+ - Durable task leases, continuation progress, completion receipts and consumer
20
+ state, with WAL recovery and retained-checkpoint restore.
21
+ - Local and multi-host I/O benchmarks, workload profiling and replay, an
22
+ independent protocol model, and process-crash/recovery checks.
23
+ - Linux x86_64 wheels for CPython 3.10–3.13, automated artifact tests and PyPI
24
+ Trusted Publishing, standalone examples and paired English/Chinese guides.
25
+
26
+ Each queue requires one externally fenced coordinator. Automatic failover,
27
+ live-pack compaction, journal compaction and a general distributed application
28
+ checkpoint transaction are not provided. Additional network filesystems require
29
+ deployment validation. See the [filesystem requirements](docs/FILESYSTEM.md) and
30
+ [protocol guarantees](docs/PROTOCOL_AND_VERIFICATION.md).
@@ -0,0 +1,17 @@
1
+ # 更新日志
2
+
3
+ [English](CHANGELOG.md)
4
+
5
+ ## 0.1.0
6
+
7
+ straw 首次发布:面向 AI 应用、基于文件系统的持久化队列与共享张量存储,以 `straw-queue` 包分发,采用 MIT 许可证。
8
+
9
+ - Rust 实现存储、WAL、队列及所有权协议,提供 Python API。多台机器通过共享文件系统并行读写,首个共享存储目标为 JuiceFS。
10
+ - 不可变记录与 manifest 打包存储,支持批量发布和按大小轮换文件,避免每个 sample 或张量单独创建文件。
11
+ - 支持 bytes、自定义 codec、NumPy/PyTorch 张量、带校验的惰性按行读取,以及复用已认证索引的 native 读取会话。
12
+ - 跨队列共享张量引用、张量级写时复制、显式 reader/checkpoint 所有权,以及可选在线 GC,回收无引用的封存 pack。
13
+ - 持久化任务 lease、continuation 进度、完成 receipt 和消费者状态,支持 WAL 恢复与已保留 checkpoint 的恢复。
14
+ - 本地与多机 I/O benchmark、应用负载采集与重放、独立协议模型,以及进程崩溃与恢复检查。
15
+ - CPython 3.10–3.13 的 Linux x86_64 wheel、自动化产物测试与 PyPI Trusted Publishing、独立使用示例和配套中英文指南。
16
+
17
+ 每个队列需要一个由外部机制隔离保护的协调器。尚不提供自动故障切换、存活 pack 整理、日志压缩或通用分布式应用 checkpoint 事务。其他网络文件系统需要单独验证部署语义。详见[文件系统要求](docs/FILESYSTEM_zh.md)与[协议保证](docs/PROTOCOL_AND_VERIFICATION_zh.md)。
@@ -0,0 +1,42 @@
1
+ # Contributing
2
+
3
+ [中文版](CONTRIBUTING_zh.md)
4
+
5
+ Use Rust 1.89+ and CPython 3.10+. Install the PyTorch build appropriate to your
6
+ environment, then install the development package:
7
+
8
+ ```sh
9
+ python -m pip install -e '.[test,build,dev]'
10
+ python -m black --check src tests examples tools verification
11
+ python -m isort --check-only src tests examples tools verification
12
+ cargo fmt --check
13
+ cargo clippy --all-targets --features python -- -D warnings
14
+ cargo test --locked
15
+ python -m pytest
16
+ python verification/ownership_model.py
17
+ python verification/crash_campaign.py --output /tmp/straw-crashes.json
18
+ ```
19
+
20
+ See [building](docs/BUILDING.md) for binary wheels and
21
+ [verification](docs/VERIFICATION.md) for the scope of each check.
22
+ Keep machine addresses, credentials, training scripts, payloads and raw
23
+ experiment logs outside the project. Use a private temporary root for every
24
+ filesystem test, with bounded data and cleanup after owned processes stop.
25
+
26
+ Protocol changes must explain durable ordering, retry behavior, compatibility,
27
+ reader ownership and failure handling. Add a reproducer for a real failure
28
+ boundary, not just an assertion matching the implementation. Update the format
29
+ and independent model where their abstractions change. Unknown versions must
30
+ fail explicitly. Framing constants are part of the storage format; changing
31
+ them requires an explicit format version.
32
+
33
+ Custom application codecs and scheduling belong outside the Rust core. Prefer
34
+ clear references and explicit lifetime signals to application-specific imports.
35
+ Performance changes need comparable payload sizes, publication granularity,
36
+ reader fanout, filesystem/cache conditions and actual measured byte counts.
37
+
38
+ The project uses the [MIT license](LICENSE).
39
+
40
+ User and contributor guides have matching English `.md` and Chinese `_zh.md`
41
+ versions. Update both when behavior or examples change, preserve reciprocal
42
+ language links, and keep API names, commands and protocol constants identical.
@@ -0,0 +1,27 @@
1
+ # 贡献指南
2
+
3
+ [English](CONTRIBUTING.md)
4
+
5
+ 使用 Rust 1.89+、CPython 3.10+。先安装适合当前环境的 PyTorch,再安装开发包:
6
+
7
+ ```sh
8
+ python -m pip install -e '.[test,build,dev]'
9
+ python -m black --check src tests examples tools verification
10
+ python -m isort --check-only src tests examples tools verification
11
+ cargo fmt --check
12
+ cargo clippy --all-targets --features python -- -D warnings
13
+ cargo test --locked
14
+ python -m pytest
15
+ python verification/ownership_model.py
16
+ python verification/crash_campaign.py --output /tmp/straw-crashes.json
17
+ ```
18
+
19
+ 二进制 wheel 见[构建文档](docs/BUILDING_zh.md),每类检查的边界见[验证文档](docs/VERIFICATION_zh.md)。机器地址、凭据、训练脚本、载荷和原始实验日志应保存在项目外。每次文件系统测试使用独立私有临时目录,限制数据规模,并在自有进程停止后清理。
20
+
21
+ 协议修改必须说明持久化顺序、重试行为、兼容性、reader 所有权和失败处理。对真实故障边界添加复现用例,而非仅断言实现自身的行为。格式和独立模型的抽象发生变化时,同步更新它们。未知版本必须明确报错。Framing 常量属于存储格式,修改时需要显式变更格式版本。
22
+
23
+ 应用自定义 codec 和调度逻辑应放在 Rust 核心之外。使用清晰的引用和显式生命周期信号,避免引入应用专用依赖。性能修改需要可比的载荷大小、发布粒度、reader fanout、文件系统/缓存条件,以及实际测量的字节数。
24
+
25
+ 项目使用 [MIT 许可证](LICENSE)。
26
+
27
+ 用户与贡献者文档使用配套的英文 `.md` 和中文 `_zh.md`。行为或示例发生变化时同步更新两种语言,保留双向语言切换链接,并确保 API 名称、命令和协议常量一致。