jra-tools
For jrdb view. https://github.com/requrd/horseview
Usage
Install
$pip install jra-tools
Test
$pip install jra_tools/
$pytest jra_tools/tests
tests/viewsの結合テストはPostgresを使う。環境変数TEST_POSTGRES(例: postgresql+psycopg://test_user:test_password@127.0.0.1:5432/test_database)がなければ飛ばす。
ビューの仕組み(jra_tools.views)
分析用のPostgresのmodel・featuresのビューを、定義から作る。具体的な定義は持たず、使う側(sazanami-batchのviews/)から渡す。ビューはデータを持たないので、マイグレーションはしない。
views/
views.yaml 管理するスキーマ・関数のSQL・作る順のビューの一覧
model/races.sql ビュー1つにつき1ファイル。SELECT文だけを書く
tests/*.sql テスト。返した行があれば失敗
schemas: [model, features]
functions: [functions.sql] # ビューより先に流すSQL。省略できる
views: # 作る順に並べる
- model.races
- model.entries
from jra_tools.views import ApplyOptions, apply_views, load_view_set, run_view_tests
view_set = load_view_set("views")
apply_views(engine, view_set, ApplyOptions(readers=("sazanami_ro",), label="sha-xxxxxxx"))
failures = run_view_tests(engine, view_set) # CIで使う
apply_viewsは、定義(views.yaml・関数・ビューのSQL)のハッシュがmeta.view_versionの最後の記録と同じなら何もしない。違えば1トランザクションで、schemasのスキーマを消して作り直し、関数とビューを作り、readersに読む権限を付け、ハッシュを記録する- 定義とstagingの列が合わなければ
CREATE VIEWでPostgresがエラーにし、全体が戻る(今のビューと記録が残る) - スキーマを消すと、ほかのスキーマに置いた、これらのビューに依存するビュー(sandboxなど)も消える
- 読んでいる最中のクエリがあると、スキーマを消す排他ロックを待つ。
lock_timeout(既定10秒)で諦め、間を置いてretries回(既定5回)やり直す - 同時に流しても、advisory lockで1つずつ動く
- テストはハッシュに含めない(テストだけを変えても作り直さない)
Metadata
Release files for jra-tools 0.1.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| jra_tools-0.1.5.tar.gz | 31.5 kB | With provenance | Details for jra_tools-0.1.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| jra_tools-0.1.5-py3-none-any.whl | Python 3 | none | any | Details for jra_tools-0.1.5-py3-none-any.whl |
Total release size: 75.0 kB
Release files / jra_tools-0.1.5.tar.gz
| Download URL | jra_tools-0.1.5.tar.gz |
|---|---|
| Size | 31.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4f1832816f25c182891a3b5f9379ee20edf2210512c271c5a1f06c1002cfaf5c
|
|
BLAKE2b-256 checksum How to use checksums |
2102fe92ec45ce97ef666d4861ed80a7a9e76cfc74752f3ecb72361168145b72
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 29, 2026.
Transparency logRelease files / jra_tools-0.1.5-py3-none-any.whl
| Download URL | jra_tools-0.1.5-py3-none-any.whl |
|---|---|
| Size | 43.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
608234a889f0fdc9002060ffef17551e4e6e898f06d7ee6a7b6f4c6e701571cb
|
|
BLAKE2b-256 checksum How to use checksums |
3531fca828d1bd2bf6e5ed06c4647afc6fc6404a18052878b49c1d933a1acac8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 29, 2026.
Transparency logSecurity for jra-tools 0.1.5
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for jra_tools-0.1.5.tar.gz
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 29, 2026.
Transparency logA 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.