Skip to content

Commit

Permalink
Merge pull request #12 from sickboyyy/master
Browse files Browse the repository at this point in the history
Starting a number of code quality improvements
  • Loading branch information
alocate authored Feb 10, 2021
2 parents 04c7299 + c1b2593 commit e8ab0fc
Show file tree
Hide file tree
Showing 8 changed files with 464 additions and 309 deletions.
144 changes: 143 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,144 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# IDE
.idea
__pycache__

# Virtualenv
.venv
2 changes: 1 addition & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ glicko2 = "*"
scipy = "*"
uvicorn = "*"
fastapi = "*"
requests = "*"
requests = "*"
155 changes: 49 additions & 106 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions common/constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Constant to go from Mu/Standard deviation representation of Logistic distr.
# to Mu/Scale representation.
# https://en.wikipedia.org/wiki/Logistic_distribution
C_SD = 0.551328895

# TODO: Should be hardcoded to the same value as in the python mmr service
BETA = 215
5 changes: 3 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
from fastapi import FastAPI

from mmr.bayesian_rating_w3c import UpdateMmrRequestBody, update_after_game, UpdateMmrResponseBody
from teambalance.balance import BalanceTeamResponseBody, BalanceTeamRequestBody, find_best_game
from teambalance.balance import BalanceTeamResponseBody, BalanceTeamRequestBody, Balance

app = FastAPI()

balance = Balance()

@app.post("/mmr/update")
async def update_mmr(body: UpdateMmrRequestBody) -> UpdateMmrResponseBody:
Expand All @@ -31,7 +32,7 @@ async def update_mmr(body: BalanceTeamRequestBody) -> BalanceTeamResponseBody:
if rating < 0:
body.ratings_list[i] = 0

return find_best_game(np.array(body.ratings_list), np.array(body.rds_list), body.gamemode)
return balance.find_best_game(np.array(body.ratings_list), np.array(body.rds_list), body.gamemode)


if __name__ == "__main__":
Expand Down
Loading

0 comments on commit e8ab0fc

Please sign in to comment.