Sync sansei branch #1
@ -9,8 +9,7 @@ RUN apt update
|
|||||||
|
|
||||||
COPY requirements.txt ./requirements.txt
|
COPY requirements.txt ./requirements.txt
|
||||||
|
|
||||||
RUN pip3 install --upgrade pip && \
|
RUN pip3 install --no-cache-dir -r requirements.txt
|
||||||
pip3 install -r requirements.txt
|
|
||||||
|
|
||||||
# This is *really* bad, but I'd rather get this working rather than forking packages and re-publishing them.
|
# This is *really* bad, but I'd rather get this working rather than forking packages and re-publishing them.
|
||||||
# It'll probably break some day.
|
# It'll probably break some day.
|
||||||
@ -24,5 +23,7 @@ COPY ./src/ ./src/
|
|||||||
|
|
||||||
ENV GUNICORN_CMD_ARGS="--bind=0.0.0.0:5000 --workers=16"
|
ENV GUNICORN_CMD_ARGS="--bind=0.0.0.0:5000 --workers=16"
|
||||||
|
|
||||||
|
WORKDIR /app/src
|
||||||
|
|
||||||
# Run gunicorn with the application
|
# Run gunicorn with the application
|
||||||
CMD ["gunicorn", "--chdir", "src", "main:app"]
|
CMD ["sanic", "main", "--port=5000"]
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
ossapi==3.4.3
|
ossapi==3.4.3
|
||||||
circleguard==5.4.1
|
circleguard==5.4.1
|
||||||
flask==3.0.2
|
|
||||||
brparser==1.0.4
|
brparser==1.0.4
|
||||||
gunicorn==21.2.0
|
sanic==24.6.0
|
||||||
|
|||||||
@ -5,21 +5,21 @@ from dataclasses import dataclass, asdict
|
|||||||
from typing import List, Iterable
|
from typing import List, Iterable
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
from sanic import Request, Sanic, exceptions, json
|
||||||
import scipy
|
import scipy
|
||||||
from brparser import Replay, BeatmapOsu, Mod
|
from brparser import Replay, BeatmapOsu, Mod
|
||||||
from circleguard import Circleguard, ReplayString, Hit
|
from circleguard import Circleguard, ReplayString, Hit
|
||||||
from flask import Flask, request, jsonify, abort
|
|
||||||
from itertools import combinations
|
from itertools import combinations
|
||||||
from math import isnan
|
from math import isnan
|
||||||
from slider import Beatmap, Circle, Slider, Spinner
|
from slider import Beatmap, Circle, Slider, Spinner
|
||||||
|
|
||||||
from src.WriteStreamWrapper import WriteStreamWrapper
|
from WriteStreamWrapper import WriteStreamWrapper
|
||||||
from src.keypresses import get_kp_sliders
|
from keypresses import get_kp_sliders
|
||||||
|
|
||||||
# Circleguard
|
# Circleguard
|
||||||
cg = Circleguard(os.getenv("OSU_API_KEY"), db_path="./dbs/db.db", slider_dir="./dbs/")
|
cg = Circleguard(os.getenv("OSU_API_KEY"), db_path="./dbs/db.db", slider_dir="./dbs/")
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Sanic(__name__)
|
||||||
|
|
||||||
def my_filter_outliers(arr, bias=1.5):
|
def my_filter_outliers(arr, bias=1.5):
|
||||||
"""
|
"""
|
||||||
@ -123,11 +123,11 @@ class ScoreJudgement:
|
|||||||
|
|
||||||
|
|
||||||
@app.post("/replay")
|
@app.post("/replay")
|
||||||
def process_replay():
|
async def process_replay(request: Request):
|
||||||
try:
|
try:
|
||||||
request_data = request.get_json()
|
request_data = request.json
|
||||||
if not request_data:
|
if not request_data:
|
||||||
abort(400, description="Bad Request: No JSON data provided.")
|
raise exceptions.BadRequest("Bad Request: No JSON data provided.")
|
||||||
|
|
||||||
replay_request = ReplayRequest.from_dict(request_data)
|
replay_request = ReplayRequest.from_dict(request_data)
|
||||||
|
|
||||||
@ -219,10 +219,10 @@ def process_replay():
|
|||||||
|
|
||||||
judgements=judgements
|
judgements=judgements
|
||||||
)
|
)
|
||||||
return jsonify(ur_response.to_dict())
|
return json(ur_response.to_dict())
|
||||||
|
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
abort(400, description=str(e))
|
raise exceptions.BadRequest(str(e))
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
@ -242,11 +242,11 @@ class ReplayDto:
|
|||||||
|
|
||||||
|
|
||||||
@app.post("/similarity")
|
@app.post("/similarity")
|
||||||
def process_similarity():
|
async def process_similarity(request: Request):
|
||||||
try:
|
try:
|
||||||
request_data = request.get_json()
|
request_data = request.json
|
||||||
if not request_data:
|
if not request_data:
|
||||||
abort(400, description="Bad Request: No JSON data provided.")
|
raise exceptions.BadRequest("Bad Request: No JSON data provided.")
|
||||||
|
|
||||||
replays: List[ReplayDto] = request_data['replays']
|
replays: List[ReplayDto] = request_data['replays']
|
||||||
replay_cache = {}
|
replay_cache = {}
|
||||||
@ -287,11 +287,7 @@ def process_similarity():
|
|||||||
)
|
)
|
||||||
response.append(new_score_similarity)
|
response.append(new_score_similarity)
|
||||||
|
|
||||||
return jsonify({'result': response})
|
return json({'result': response})
|
||||||
|
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
abort(400, description=str(e))
|
raise exceptions.BadRequest(str(e))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
app.run(host='0.0.0.0', debug=False)
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user