Skip to content

Commit e4c3ba4

Browse files
author
Jake Bailey
authored
Merge pull request #594 from SprocketBot/personal/gankoji/unbork-carball
fix: unbreak the replay-parse build
2 parents 4990ea7 + b2c2553 commit e4c3ba4

File tree

3 files changed

+55
-31
lines changed

3 files changed

+55
-31
lines changed
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
1-
FROM python:3.13 as app_image
1+
FROM python:3.9 as app_image
22

33
WORKDIR /app
44
COPY . .
55

66
# Install system dependencies, install python packages, then remove system dependencies in a single layer
77
# This is necessary to build packages like numpy and pandas from source on the Debian-based slim image
8+
# Also install Rust/Cargo for sprocket-boxcars-py dependency
89
RUN apt-get update && \
9-
apt-get install -y --no-install-recommends build-essential python3-dev
10+
apt-get install -y --no-install-recommends build-essential python3-dev curl && \
11+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && \
12+
export PATH="$HOME/.cargo/bin:$PATH" && \
13+
apt-get remove -y curl && apt-get autoremove -y
1014
RUN python3 -m pip install requests
15+
ENV PATH="/root/.cargo/bin:$PATH"
1116
RUN python3 -m pip install -r requirements.txt
1217

1318
ENTRYPOINT ["./start.sh"]
Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,26 @@
1-
amqp==5.3.1
2-
billiard==4.2.2
3-
#boxcars-py==0.1.0
4-
#carball==0.7.5
1+
# Core dependencies for Celery and message processing
52
celery==5.5.3
6-
certifi==2021.10.8
7-
charset-normalizer==2.0.12
8-
click==8.3.0
9-
click-didyoumean==0.3.0
10-
click-plugins==1.1.1
11-
click-repl==0.2.0
12-
Deprecated==1.2.13
13-
idna==3.3
143
kombu==5.5.4
15-
minio==7.1.3
16-
#numpy
17-
packaging==21.3
18-
#pandas
19-
prompt-toolkit==3.0.28
20-
protobuf==3.6.1
21-
pyparsing==3.0.7
4+
amqp==5.3.1
5+
billiard==4.2.2
6+
7+
# Ballchasing API integration
228
python-ballchasing
23-
python-dateutil==2.8.2
24-
pytz==2021.3
9+
10+
# Storage and caching
11+
minio==7.1.3
2512
redis==4.1.2
13+
14+
# HTTP and API support
2615
requests==2.27.1
27-
six==1.16.0
2816
urllib3==1.26.8
29-
vine==5.1.0
30-
wcwidth==0.2.5
31-
wrapt
32-
xlrd==1.1.0
33-
setuptools>=68.0.0
17+
certifi==2021.10.8
18+
19+
# Utilities
20+
python-dateutil==2.8.2
21+
pytz==2021.3
22+
click==8.1.8
23+
six==1.16.0
24+
25+
# sprocket-carball for local replay parsing (replaces the old carball package)
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)