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.4以降のレコードレイアウト制約
UM、BR、HN、SK、BT、CK、HSは拡張版のレイアウトのみ対応しています。
標準版の旧レイアウトはJVServerError(-32001)で取得を中断します。
対応する拡張版を使用してください。
| 取得する種別 | 標準版 → 対応する拡張版 |
|---|---|
| UM、BR | DIFF → DIFN、TCOV → TCVN、RCOV → RCVN |
| HN、SK、BT | BLOD → BLDN |
| CK | SNAP → SNPN |
| HS | HOSE → HOSN |
配置が共通のKS、CH、BN、RC、RA、SEは引き続き解析できます。 0.8.3以前で保存した対象データは、拡張版から再取得してください。 リモート接続では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.4
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.4.tar.gz | 137.6 kB | Without provenance | Details for pyjvlink-0.8.4.tar.gz |
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pyjvlink-0.8.4-py3-none-win_amd64.whl | Python 3 | none | Windows x86-64 | Details for pyjvlink-0.8.4-py3-none-win_amd64.whl |
| pyjvlink-0.8.4-py3-none-any.whl | Python 3 | none | any | Details for pyjvlink-0.8.4-py3-none-any.whl |
Total release size: 1.1 MB
Release files / pyjvlink-0.8.4.tar.gz
| Download URL | pyjvlink-0.8.4.tar.gz |
|---|---|
| Size | 137.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b40854f3ebad3dc4f9bab05e2d8e015f28705ee23756ec8a64c5e6f434012fc0
|
|
BLAKE2b-256 checksum How to use checksums |
d38bc995034f0138be1a26eb1b6e36bf24e803137d5e43469a2082f30759f145
|
| 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.4-py3-none-win_amd64.whl
| Download URL | pyjvlink-0.8.4-py3-none-win_amd64.whl |
|---|---|
| Size | 747.0 kB |
| Tags | Python 3 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
6019da9bc15e77dc26ebe6fc217633b93b2d59492b64cb41e94653eccebbee64
|
|
BLAKE2b-256 checksum How to use checksums |
16beb894f9bb5c98b7755a3ab55c0cdd4b8da293727c79630169313ad3c50472
|
| 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.4-py3-none-any.whl
| Download URL | pyjvlink-0.8.4-py3-none-any.whl |
|---|---|
| Size | 180.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d43ec6e0ef0620ea027fde6e4a8e01e205719871d1a9f54d3672447931c6111a
|
|
BLAKE2b-256 checksum How to use checksums |
275bf07942a79605b6c040f80b1e440b789a222a4fd4be63df83b94cf63019d1
|
| 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.4
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.