Skip to content

Commit

Permalink
Merge pull request #68 from pomo-mondreganto/fixes
Browse files Browse the repository at this point in the history
Working version with updated requirements & Python 3.9
  • Loading branch information
pomo-mondreganto authored May 11, 2021
2 parents 58ff213 + b48f03a commit b1fc9e6
Show file tree
Hide file tree
Showing 16 changed files with 86 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[flake8]
max_line_length = 88
exclude = .git,front,docker_config,tests
exclude = .git,front,docker_config,tests,checkers
ignore = E402
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.CR_PAT }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push
id: docker_build
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
- name: Setup python
uses: actions/setup-python@v2
with:
python-version: '3.7'
python-version: '3.9'
- uses: actions/cache@v2
with:
path: ~/.cache/pip
Expand Down Expand Up @@ -80,7 +80,7 @@ jobs:
- name: Setup python
uses: actions/setup-python@v2
with:
python-version: '3.7'
python-version: '3.9'
- name: Install dependencies
run: pip install flake8
- name: Run linters
Expand Down Expand Up @@ -119,7 +119,7 @@ jobs:
- name: Setup python
uses: actions/setup-python@v2
with:
python-version: '3.7'
python-version: '3.9'
- name: Install skaffold
run: |
curl -Lo skaffold https://storage.googleapis.com/skaffold/releases/v1.19.0/skaffold-linux-amd64
Expand Down
26 changes: 26 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
.PHONY: lint
lint:
flake8 --config .flake8

.PHONY: clean
clean:
./control.py reset || :
./control.py clean

.PHONY: test
test: clean
./scripts/run_tests.sh

.PHONY: build-base
build-base:
./scripts/release_base.sh

.PHONY: release-base
release-base:
./scripts/release_base.sh --push

.PHONY: start
start: clean
./control.py setup
./control.py start --fast
./control.py rd logs -f inititializer
8 changes: 8 additions & 0 deletions backend/lib/storage/game.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,14 @@ def construct_game_state_from_db(current_round: int) -> models.GameState:
teamtasks = storage.tasks.get_teamtasks_from_db()
teamtasks = storage.tasks.filter_teamtasks_for_participants(teamtasks)

team_ids = {team.id for team in storage.teams.get_teams()}
task_ids = {task.id for task in storage.tasks.get_tasks()}

teamtasks = list(filter(
lambda tt: tt['team_id'] in team_ids and tt['task_id'] in task_ids,
teamtasks,
))

round_start = get_round_start(current_round)
state = models.GameState(
round_start=round_start,
Expand Down
40 changes: 32 additions & 8 deletions backend/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,43 @@
amqp==5.0.6
bidict==0.21.2
billiard==3.6.4.0
celery==5.0.5
eventlet==0.30.1
certifi==2020.12.5
click==7.1.2
click-didyoumean==0.0.3
click-plugins==1.1.1
click-repl==0.1.6
dnspython==1.16.0
eventlet==0.30.2
Flask==1.1.2
Flask-Cors==3.0.10
Flask-SocketIO==5.0.1
-e git://github.com/avikam/flower@9aade51671a2c1f0c1d0c1c81c7ca9bb49837f83#egg=flower
flower @ https://github.com/mher/flower/zipball/master
gevent==21.1.2
gunicorn==20.0.4
hiredis==1.1.0
librabbitmq==2.0.0
greenlet==1.1.0
gunicorn==20.1.0
hiredis==2.0.0
humanize==3.5.0
itsdangerous==1.1.0
Jinja2==2.11.3
kombu==5.0.2
librabbitmq==2.0.0
MarkupSafe==1.1.1
prometheus-client==0.8.0
pydantic==1.7.3
prompt-toolkit==3.0.18
psycopg2==2.8.6
pydantic==1.8.1
python-dateutil==2.8.1
python-socketio==5.0.4
python-engineio==4.1.0
python-socketio==5.2.1
pytz==2021.1
PyYAML==5.4.1
psycopg2==2.8.6
redis==3.5.3
six==1.16.0
tornado==6.1
typing-extensions==3.10.0.0
vine==5.0.0
wcwidth==0.2.5
Werkzeug==1.0.1
zope.event==4.5.0
zope.interface==5.4.0
4 changes: 2 additions & 2 deletions backend/services/admin/viewsets/teamtasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ class TeamTaskApi(ApiSet):
@staticmethod
def list():
try:
team_id = int(request.args['team_id'][0])
task_id = int(request.args['task_id'][0])
team_id = int(request.args['team_id'])
task_id = int(request.args['task_id'])
except (KeyError, ValueError):
return make_err_response(
'Provide team_id and task_id as get params',
Expand Down
8 changes: 1 addition & 7 deletions cli/base/reset.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@
import click

from cli import constants, utils
from cli.base.clean import clean


@click.command(help='Reset the game & clean up')
@click.pass_context
def reset(ctx: click.Context):
def reset():
utils.print_bold('Trying to wipe the database')
command = [
'docker-compose',
Expand All @@ -31,8 +29,4 @@ def reset(ctx: click.Context):
'--remove-orphans',
]
utils.run_command(command, cwd=constants.BASE_DIR)

utils.print_bold('Running clean')
ctx.invoke(clean)

utils.print_success('Done!')
5 changes: 5 additions & 0 deletions cli/base/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def setup_db(config: models.DatabaseConfig):
f'POSTGRES_DB={config.dbname}',
]

utils.print_bold(f'Writing database env to {constants.POSTGRES_ENV_PATH}')
constants.POSTGRES_ENV_PATH.write_text('\n'.join(postgres_config))


Expand All @@ -45,6 +46,7 @@ def setup_redis(config: models.RedisConfig):
f'REDIS_PASSWORD={config.password}',
]

utils.print_bold(f'Writing redis env to {constants.REDIS_ENV_PATH}')
constants.REDIS_ENV_PATH.write_text('\n'.join(redis_config))


Expand All @@ -58,6 +60,7 @@ def setup_rabbitmq(config: models.RabbitMQConfig):
f'RABBITMQ_DEFAULT_VHOST={config.vhost}',
]

utils.print_bold(f'Writing broker env to {constants.RABBITMQ_ENV_PATH}')
constants.RABBITMQ_ENV_PATH.write_text('\n'.join(rabbitmq_config))


Expand All @@ -68,6 +71,7 @@ def setup_admin_api(config: models.AdminConfig):
f'ADMIN_PASSWORD={config.password}',
]

utils.print_bold(f'Writing admin env to {constants.ADMIN_ENV_PATH}')
constants.ADMIN_ENV_PATH.write_text('\n'.join(admin_config))


Expand All @@ -85,5 +89,6 @@ def prepare_compose(redis: str = None, database: str = None, rabbitmq: str = Non
del base_conf['services']['rabbitmq']

res_path = constants.BASE_DIR / constants.BASE_COMPOSE_FILE
utils.print_bold(f'Writing generated compose base to {res_path}')
with res_path.open(mode='w') as f:
yaml.dump(base_conf, f)
2 changes: 1 addition & 1 deletion cli/kube/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def cli():
pass


cli: click.Group
cli: click.Group # noqa
cli.add_command(build)
cli.add_command(clean)
cli.add_command(create)
Expand Down
2 changes: 1 addition & 1 deletion docker_config/base_images/backend.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.7
FROM python:3.9

ENV PYTHONUNBUFFERED=1
ENV PYTHONPATH=${PYTHONPATH}:/app
Expand Down
2 changes: 1 addition & 1 deletion docker_config/celery/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.7
FROM python:3.9

ENV PYTHONUNBUFFERED=1
ENV PYTHONPATH=${PYTHONPATH}:/app
Expand Down
2 changes: 1 addition & 1 deletion docker_config/initializer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.7
FROM python:3.9

ENV PYTHONUNBUFFERED=1
ENV PYTHONPATH=${PYTHONPATH}:/app
Expand Down
2 changes: 1 addition & 1 deletion docker_config/services/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.7
FROM python:3.9

ENV PYTHONUNBUFFERED=1
ENV PYTHONPATH=${PYTHONPATH}:/app
Expand Down
1 change: 1 addition & 0 deletions scripts/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export TEST=1

python tests/setup_forcad.py
./control.py setup
# shellcheck disable=SC2038,SC2046
export $(find ./docker_config -name "*.env" -exec egrep -v '^#' {} \; | xargs)
./control.py reset
./control.py build
Expand Down
2 changes: 1 addition & 1 deletion tests/service/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.7
FROM python:3.9

ENV PYTHONUNBUFFERED=1

Expand Down

0 comments on commit b1fc9e6

Please sign in to comment.