Skip to content

Commit b2c2553

Browse files
committed
fix: also re-enable carball in the code
1 parent d2c2201 commit b2c2553

File tree

3 files changed

+31
-5
lines changed

3 files changed

+31
-5
lines changed

microservices/replay-parse-service/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:3.13 as app_image
1+
FROM python:3.9 as app_image
22

33
WORKDIR /app
44
COPY . .

microservices/replay-parse-service/requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ certifi==2021.10.8
1919
# Utilities
2020
python-dateutil==2.8.2
2121
pytz==2021.3
22-
click==8.3.0
22+
click==8.1.8
2323
six==1.16.0
2424

2525
# sprocket-carball for local replay parsing (replaces the old carball package)
26-
sprocket-carball==0.8.7
26+
sprocket-carball>=0.8.7

microservices/replay-parse-service/src/parser.py

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import logging
22
from time import sleep
33
from typing import Callable
4+
import carball
45
import ballchasing
56
from requests import Response
67

@@ -20,17 +21,42 @@
2021
BACKOFF_FACTOR = config["ballchasing"]["backoffFactor"]
2122
DELAYS = [0, *(BACKOFF_FACTOR**(r + 1) for r in range(MAX_RETRIES))]
2223

23-
if PARSER != "ballchasing":
24-
raise Exception(f"Unknown parser {PARSER}. Only 'ballchasing' is currently supported.")
24+
if PARSER != "carball" and PARSER != "ballchasing":
25+
raise Exception(f"Unknown parser {PARSER}. Please specify either 'carball' or 'ballchasing'.")
2526

2627

2728
def parse(path: str, on_progress: Callable[[str], None] = None):
29+
if PARSER == "carball":
30+
return _parse_carball(path, on_progress)
2831
if PARSER == "ballchasing":
2932
return _parse_ballchasing(path, on_progress)
3033
raise Exception(f"Parser {PARSER} not supported")
3134

3235

3336

37+
###############################
38+
#
39+
# Carball
40+
#
41+
###############################
42+
43+
def _parse_carball(path: str, on_progress: Callable[[str], None] = None) -> dict:
44+
"""
45+
Parses a Rocket League replay located at a given local path
46+
47+
Args:
48+
path (str): The local path of the replay file to parse
49+
50+
Returns:
51+
dict: A dictionary containing all of the stats returned by carball
52+
"""
53+
logging.info(f"Parsing {path} with carball")
54+
55+
analysis_manager = carball.analyze_replay_file(path, logging_level=print)
56+
return analysis_manager.get_json_data()
57+
58+
59+
3460
###############################
3561
#
3662
# Ballchasing

0 commit comments

Comments
 (0)