Skip to main content

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) -> dict
  • Client.get_uniform(pattern) -> bytes
  • Client.save_uniform(pattern, filepath) -> dict
  • Client.get_course(key) -> tuple[bytes, str]
  • Client.get_course_file(key) -> dict
  • Client.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)

Source distribution for pyjvlink 0.8.4
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)

Table of built distributions (wheels) for pyjvlink 0.8.4
File Interpreter ABI Platform Actions
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

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.

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