Skip to main content

Python bindings for the Rocket League replay processing library subtr-actor.

Project description

subtr-actor-py

Python bindings for subtr-actor, a Rocket League replay processing library.

Installation

pip install subtr-actor-py

Usage

import subtr_actor

replay_path = "path/to/replay.replay"

# Parse raw replay bytes into the full replay structure.
with open(replay_path, "rb") as replay_file:
    replay = subtr_actor.parse_replay(replay_file.read())

# Build a numpy ndarray plus metadata.
meta, ndarray = subtr_actor.get_ndarray_with_info_from_replay_filepath(
    replay_path,
    global_feature_adders=["BallRigidBody", "SecondsRemaining"],
    player_feature_adders=["PlayerRigidBody", "PlayerBoost", "PlayerAnyJump"],
    fps=10.0,
    dtype="float32",
)

headers = subtr_actor.get_column_headers(
    global_feature_adders=["BallRigidBody", "SecondsRemaining"],
    player_feature_adders=["PlayerRigidBody", "PlayerBoost"],
)

replay_meta = subtr_actor.get_replay_meta(replay_path)
frames_data = subtr_actor.get_replay_frames_data(replay_path)
stats_module_names = subtr_actor.get_stats_module_names()
stats = subtr_actor.get_stats(replay_path, module_names=["core", "boost", "movement"])
stats_snapshot_data = subtr_actor.get_stats_snapshot_data(
    replay_path,
    module_names=["core", "boost"],
    frame_step_seconds=1.0,
)
stats_timeline = subtr_actor.get_stats_timeline(
    replay_path,
    frame_step_seconds=1.0,
)
legacy_stats_timeline = subtr_actor.get_legacy_stats_timeline(
    replay_path,
    module_names=["core", "boost", "movement"],
    frame_step_seconds=1.0,
)

print(ndarray.shape)
print(headers["player_headers"][:5])
print(replay_meta["map_name"])
print(stats_module_names)
print(stats["modules"]["core"]["team_zero"]["score"])
print(stats_snapshot_data["frames"][-1]["modules"]["boost"]["team_zero"]["amount_collected"])
print(stats_timeline["events"]["boost_ledger"][-1])
print(legacy_stats_timeline["frames"][-1]["team_zero"]["boost"]["amount_collected"])

get_stats_timeline is the compact event-backed timeline. Its frames contain timing, gameplay state, and player identity scaffolding only; stat deltas live under events. Use get_legacy_stats_timeline only for compatibility code that still needs serialized per-frame team/player snapshots.

API Surface

parse_replay(data: bytes) -> dict

Parse raw replay bytes and return the full replay structure as Python data.

get_ndarray_with_info_from_replay_filepath(filepath, global_feature_adders=None, player_feature_adders=None, fps=None, dtype=None) -> tuple[dict, numpy.ndarray]

Process a replay file and return metadata plus a numpy.ndarray.

Parameters:

  • filepath: path to the replay file
  • global_feature_adders: list of global feature names, default ["BallRigidBody"]
  • player_feature_adders: list of player feature names, default ["PlayerRigidBody", "PlayerBoost", "PlayerAnyJump"]
  • fps: target FPS for resampling, default 10.0
  • dtype: output dtype string. Supported values are float16/f16/half, float32/f32, and float64/f64/double

get_replay_meta(filepath, global_feature_adders=None, player_feature_adders=None) -> dict

Get replay metadata and ndarray headers without materializing the full ndarray.

get_column_headers(global_feature_adders=None, player_feature_adders=None) -> dict

Get header information for the configured ndarray layout.

get_replay_frames_data(filepath) -> dict

Get structured frame-by-frame game state data with no FPS resampling.

get_stats_module_names() -> list[str]

List the builtin stats modules that can be selected in get_stats, get_stats_snapshot_data, and get_legacy_stats_timeline.

get_stats(filepath, module_names=None) -> dict

Get aggregate replay stats for the selected builtin modules.

Parameters:

  • filepath: path to the replay file
  • module_names: optional list of builtin stats module names. By default all builtin modules are included.

get_stats_snapshot_data(filepath, module_names=None, frame_step_seconds=None) -> dict

Get the raw stats snapshot payload produced by StatsCollector, including:

  • config: module configuration emitted by the selected stats modules
  • modules: aggregate module outputs
  • frames: per-sample module snapshots keyed by module name

Parameters:

  • filepath: path to the replay file
  • module_names: optional list of builtin stats module names. By default all builtin modules are included.
  • frame_step_seconds: optional positive sampling interval in seconds. By default every replay frame is captured.

get_stats_timeline(filepath, frame_step_seconds=None) -> dict

Get the compact event-backed stats timeline for each replay sample.

Frames contain timing, gameplay state, and player identity scaffolding only; stat state changes are transferred through events, and full team/player snapshots can be derived by clients that need them.

Parameters:

  • filepath: path to the replay file
  • frame_step_seconds: optional positive sampling interval in seconds. By default every replay frame is captured.

module_names filtering is not supported for compact event timelines. Passing it raises ValueError; use get_legacy_stats_timeline if filtered full snapshot timelines are needed.

get_legacy_stats_timeline(filepath, module_names=None, frame_step_seconds=None) -> dict

Get cumulative typed stats snapshots for each replay sample.

This preserves the pre-compact timeline behavior for compatibility and for explicit parity checks, but it serializes the full team/player partial sums.

Parameters:

  • filepath: path to the replay file
  • module_names: optional list of builtin stats module names. By default all builtin modules are included.
  • frame_step_seconds: optional positive sampling interval in seconds. By default every replay frame is captured.

Feature Adders

See the subtr-actor ndarray docs for the full list of feature-adder names.

Common global features:

  • BallRigidBody
  • CurrentTime
  • SecondsRemaining

Common player features:

  • PlayerRigidBody
  • PlayerBallDistance
  • PlayerBoost
  • PlayerAnyJump
  • PlayerJump
  • PlayerDodgeRefreshed

PlayerBoost is exposed in raw replay units (0-255), not 0-100 percent.

Development

Repository-level compile check:

just build-python

For an importable local Python environment, use maturin develop from the python/ directory:

cd python
uv sync --group dev
uv run maturin develop
uv run pytest

If you are using the repo flake, nix develop now provides the pinned CPython 3.11 toolchain and Python dev dependencies via uv2nix. Create a writable virtual environment from that interpreter, then install the local extension into it:

nix develop
uv venv /tmp/subtr-actor-venv
source /tmp/subtr-actor-venv/bin/activate
cd python
maturin develop
pytest

If you are not using uv or Nix, install maturin, pytest, and numpy in a virtual environment and run maturin develop directly.

Publishing Notes

This binding depends on the workspace crate via:

[dependencies.subtr-actor]
path = ".."
version = "0.4.0"

That keeps local development wired to the workspace crate while still pinning the published dependency version. Use just bump <version> to update the workspace and binding versions together.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

subtr_actor_py-0.11.0.tar.gz (1.7 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

subtr_actor_py-0.11.0-cp314-cp314-macosx_11_0_arm64.whl (1.9 MB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

subtr_actor_py-0.11.0-cp312-cp312-win_amd64.whl (1.7 MB view details)

Uploaded CPython 3.12Windows x86-64

subtr_actor_py-0.11.0-cp312-cp312-manylinux_2_34_x86_64.whl (2.1 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

File details

Details for the file subtr_actor_py-0.11.0.tar.gz.

File metadata

  • Download URL: subtr_actor_py-0.11.0.tar.gz
  • Upload date:
  • Size: 1.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.16 {"installer":{"name":"uv","version":"0.11.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for subtr_actor_py-0.11.0.tar.gz
Algorithm Hash digest
SHA256 047a2646912e6ec0f2411135abdc6a17359c515f34480b4f7bd6b7302f2bb8cb
MD5 0672d07d5dae3e3388b8d8bd3b616803
BLAKE2b-256 6547b0599f44b76f17ef1d2f468114b67e5547ef147c9a3c4beabc34d1001df6

See more details on using hashes here.

File details

Details for the file subtr_actor_py-0.11.0-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

  • Download URL: subtr_actor_py-0.11.0-cp314-cp314-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 1.9 MB
  • Tags: CPython 3.14, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.16 {"installer":{"name":"uv","version":"0.11.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for subtr_actor_py-0.11.0-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3c7ff7d33271db3ccbcf4d0479ded57bee8b2893cf9677e009b8ad9401f006f0
MD5 c1f8159909074e540392b0dc3242b271
BLAKE2b-256 39464a4dd8622043ea577c09f1d01227e09116da046cb3d5af7a0c435f11ea7c

See more details on using hashes here.

File details

Details for the file subtr_actor_py-0.11.0-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: subtr_actor_py-0.11.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 1.7 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.16 {"installer":{"name":"uv","version":"0.11.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for subtr_actor_py-0.11.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 ae712afd98d0ca8867162a3d7c242892b9e303b1001362a9b31d01c8ba761f30
MD5 f950c8fac8224bb74a8dba826d5aee0d
BLAKE2b-256 cf059197444cee1cee684cb3995c1f9b226b1a51f7f64e26e4546e684bcc241b

See more details on using hashes here.

File details

Details for the file subtr_actor_py-0.11.0-cp312-cp312-manylinux_2_34_x86_64.whl.

File metadata

  • Download URL: subtr_actor_py-0.11.0-cp312-cp312-manylinux_2_34_x86_64.whl
  • Upload date:
  • Size: 2.1 MB
  • Tags: CPython 3.12, manylinux: glibc 2.34+ x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.16 {"installer":{"name":"uv","version":"0.11.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for subtr_actor_py-0.11.0-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 9a49c5cbf5e205b499771b9b000e5aeef070b5b0ddcfcb705a10c4541d7f0118
MD5 cd853053b6cae7fc73a88dba339e4b81
BLAKE2b-256 8e3e0d2bac942308bcfe7b1fd86cc30005e7c226474d4f57294e0d23d43f4954

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page