PyJVLink
JRA-VAN Data Lab JV-Link を Python から利用するための非同期クライアントライブラリ。
Windows では JVLinkServer.exe の自動起動に対応し、Linux/macOS ではリモート接続モードで利用できます。
オンラインドキュメント | PyPI | Releases
特徴
async/awaitベースの API- NDJSON ストリーミング対応
- typed query / raw query の両系統
RecordEnvelopeで一貫した戻り値Sequence[JVDataSpec | str]を受け取る柔軟な DataSpec 指定- realtime race key helper (
RaceKeyParts,build_race_key*) - SSE イベント監視 (
watch_events,stream_events)
前提条件
- Python 3.10 以上
- 接続先の JVLinkServer
- Windows: ローカル自動起動
- Linux/macOS: Windows 上の JVLinkServer へ接続
インストール
標準版と拡張版のレコード解析
0.8.5から、UM、BR、HN、SK、BT、CK、HSは標準版の旧レイアウトと拡張版の両方に対応しています。
C++サーバーはレコード種別とCR/LF込みの生バイト長で形式を識別し、各形式の位置と幅で解析します。
不正な長さ、末尾CR/LFの欠損、範囲外の読み取りはJVServerError(-32001)で取得を中断します。
| 取得する種別 | 標準版 / 拡張版 |
|---|---|
| UM、BR | DIFF / DIFN、TCOV / TCVN、RCOV / RCVN |
| HN、SK、BT | BLOD / BLDN |
| CK | SNAP / SNPN |
| HS | HOSE / HOSN |
拡張版は2023年8月8日以降に提供しているデータが対象です。 それ以前のデータを取得する場合は標準版を使用してください。 繁殖登録番号と生産者コードは元の桁数を保持し、新番号への変換は行いません。 0.8.4は拡張版のみ対応し、0.8.3以前は旧レイアウトを誤読する場合がありました。 誤読したJSONから元の値は復元できないため、対象期間に対応するdataspecから再取得してください。 リモート接続ではC++サーバーも更新する必要があります。 取得途中のエラーは、クエリ全体の完了として扱わないでください。 幅の変更は公式JV-Data仕様書の変更履歴で確認できます。
pip install git+https://github.com/nyoki-mtl/JVLinkServer.git#subdirectory=python
クイックスタート
import asyncio
from pyjvlink import Client
async def main() -> None:
async with Client() as client:
result = await client.query_stored(
dataspec=["RACE", "TOKU"],
from_datetime="20240101",
option=1,
record_types=["RA", "TK"],
)
print(result.meta)
async for envelope in result.records:
print(envelope.type)
if __name__ == "__main__":
asyncio.run(main())
主要API
Client.query_stored(...) -> StoredResult[DomainRecord]Client.query_realtime(...) -> RealtimeResult[DomainRecord]Client.query_stored_raw(...) -> StoredResult[WireRecord]Client.query_realtime_raw(...) -> RealtimeResult[WireRecord]Client.watch_events() -> AsyncContextManager[AsyncIterator[JVLinkEvent]]Client.stream_events() -> AsyncIterator[JVLinkEvent]Client.delete_file(filename) -> dictClient.get_uniform(pattern) -> bytesClient.save_uniform(pattern, filepath) -> dictClient.get_course(key) -> tuple[bytes, str]Client.get_course_file(key) -> dictClient.save_course(key, filepath) -> dict
StoredResult / RealtimeResult は次の構造です。
meta: サーバーからのメタ情報records:RecordEnvelopeの非同期イテレータ
realtime 系では key に文字列だけでなく date / datetime / RaceKeyParts も渡せます。
API 方針
公開クライアントは Client を使用します。
CLI
pyjvlink health
pyjvlink version
pyjvlink doctor
pyjvlink query-stored RACE 20240101 1 --max-records 10
pyjvlink query-realtime 0B12 --key 202401070511
pyjvlink health が unhealthy を返した場合は、components.jvlink.last_fault_message を確認してください。
開発
Windows ネイティブ環境を前提とします。
uv sync --all-extras
uv run ruff check src tests
uv run ty check src/pyjvlink
uv run pytest tests -v
Metadata
Release files for pyjvlink 0.8.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 |
|---|---|---|---|---|
| pyjvlink-0.8.5.tar.gz | 138.2 kB | Without provenance | Details for pyjvlink-0.8.5.tar.gz |
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pyjvlink-0.8.5-py3-none-win_amd64.whl | Python 3 | none | Windows x86-64 | Details for pyjvlink-0.8.5-py3-none-win_amd64.whl |
| pyjvlink-0.8.5-py3-none-any.whl | Python 3 | none | any | Details for pyjvlink-0.8.5-py3-none-any.whl |
Total release size: 1.1 MB
Release files / pyjvlink-0.8.5.tar.gz
| Download URL | pyjvlink-0.8.5.tar.gz |
|---|---|
| Size | 138.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
95ae00fb7bdcbceff103b342c395efce83e1e59242d72e8aefde7a2a01ed3b59
|
|
BLAKE2b-256 checksum How to use checksums |
f37581123e415839fd37ca2ea252f763a24c36af1621bce2133b04011cc1823b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / pyjvlink-0.8.5-py3-none-win_amd64.whl
| Download URL | pyjvlink-0.8.5-py3-none-win_amd64.whl |
|---|---|
| Size | 750.0 kB |
| Tags | Python 3 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
ea2dd8cddb09650c494c77afc1b6d531d942571bb47ec1fdcb24aba8fea6df22
|
|
BLAKE2b-256 checksum How to use checksums |
ee7c342ed0c8c1b212afd84ef1351d3998ee10209029fef8353aacc231bc9af8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / pyjvlink-0.8.5-py3-none-any.whl
| Download URL | pyjvlink-0.8.5-py3-none-any.whl |
|---|---|
| Size | 180.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4834b3d0b548be7cb7d4f0dfb2dd9508f7988e5c19d3868647a7f59467e4b82d
|
|
BLAKE2b-256 checksum How to use checksums |
297caa5b9eb02525f58281ea5b821ce748bbfae43a1790e4eed23d43d49a621c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Security for pyjvlink 0.8.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.
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.