Skip to content

Commit

Permalink
Small Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
pmariglia committed Dec 21, 2024
1 parent 375ae49 commit ce3fdc0
Show file tree
Hide file tree
Showing 113 changed files with 58,161 additions and 133,243 deletions.
15 changes: 8 additions & 7 deletions .github/workflows/pythonapp.yml → .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Python application
name: CI

on:
push:
Expand All @@ -14,14 +14,15 @@ jobs:
steps:
- uses: actions/checkout@v1
- name: Set up Python
uses: actions/setup-python@v1
- uses: actions/setup-python@v5
with:
python-version: 3.8
python-version: '3.13'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements-docker.txt
- name: Test with unittests
pip install -r requirements-dev.txt
- name: fmt, lint, & test
run: |
python -m unittest discover -s tests -t .
ruff check
ruff format --check --diff
pytests tests
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
logs/
venv/
dist/
.idea/
**/actual_states/*
**/__pycache__/*
Expand All @@ -8,3 +9,4 @@ creds
*.txt
suspect_decisions.py
teams/teams
data/smogon_stats_cache
38 changes: 24 additions & 14 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,23 +1,33 @@
FROM pmariglia/gambit-docker as debian-with-gambit
FROM rust:1.81-slim as build

FROM python:3.8-slim
RUN apt update && apt install -y python3.11 make build-essential python3.11-venv

COPY --from=debian-with-gambit /usr/local/bin/gambit-enummixed /usr/local/bin
COPY requirements.txt requirements.txt

WORKDIR /showdown
# Replace the poke-engine version in requirements.txt
# Matches and replaces `poke-engine/` followed by any non-space characters
ARG GEN
RUN if [ -n "$GEN" ]; then sed -i "s/poke-engine\/[^ ]*/poke-engine\/${GEN}/" requirements.txt; fi

COPY requirements.txt /showdown/requirements.txt
COPY requirements-docker.txt /showdown/requirements-docker.txt
RUN mkdir ./packages && \
python3 -m venv venv && \
. venv/bin/activate && \
# pip24 is required for --config-settings
pip install --upgrade pip==24.2 && \
pip install -v --target ./packages -r requirements.txt

RUN pip3 install -r requirements.txt
RUN pip3 install -r requirements-docker.txt
FROM python:3.11-slim

COPY config.py /showdown/config.py
COPY constants.py /showdown/constants.py
COPY data /showdown/data
COPY run.py /showdown/run.py
COPY showdown /showdown/showdown
COPY teams /showdown/teams
WORKDIR /foul-play

COPY config.py /foul-play/config.py
COPY constants.py /foul-play/constants.py
COPY data /foul-play/data
COPY run.py /foul-play/run.py
COPY fp /foul-play/fp
COPY teams /foul-play/teams

COPY --from=build /packages/ /usr/local/lib/python3.11/site-packages/

ENV PYTHONIOENCODING=utf-8

Expand Down
226 changes: 0 additions & 226 deletions ENGINE.md

This file was deleted.

43 changes: 43 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
docker:
docker build . -t foul-play:latest --build-arg GEN=$(GEN)

clean_logs:
rm logs/*

test:
pytest tests

fmt:
ruff format

lint:
ruff check --fix

# Used to install poke-engine for specific generations
# This assumes that the poke-engine project is in the same directory as foul-play
gen1:
pip uninstall -y poke-engine && pip install -v --force-reinstall --no-cache-dir ../poke-engine/poke-engine-py --config-settings="build-args=--features poke-engine/gen1 --no-default-features"

gen2:
pip uninstall -y poke-engine && pip install -v --force-reinstall --no-cache-dir ../poke-engine/poke-engine-py --config-settings="build-args=--features poke-engine/gen2 --no-default-features"

gen3:
pip uninstall -y poke-engine && pip install -v --force-reinstall --no-cache-dir ../poke-engine/poke-engine-py --config-settings="build-args=--features poke-engine/gen3 --no-default-features"

gen4:
pip uninstall -y poke-engine && pip install -v --force-reinstall --no-cache-dir ../poke-engine/poke-engine-py --config-settings="build-args=--features poke-engine/gen4 --no-default-features"

gen5:
pip uninstall -y poke-engine && pip install -v --force-reinstall --no-cache-dir ../poke-engine/poke-engine-py --config-settings="build-args=--features poke-engine/gen5 --no-default-features"

gen6:
pip uninstall -y poke-engine && pip install -v --force-reinstall --no-cache-dir ../poke-engine/poke-engine-py --config-settings="build-args=--features poke-engine/gen6 --no-default-features"

gen7:
pip uninstall -y poke-engine && pip install -v --force-reinstall --no-cache-dir ../poke-engine/poke-engine-py --config-settings="build-args=--features poke-engine/gen7 --no-default-features"

gen8:
pip uninstall -y poke-engine && pip install -v --force-reinstall --no-cache-dir ../poke-engine/poke-engine-py --config-settings="build-args=--features poke-engine/gen8 --no-default-features"

gen9:
pip uninstall -y poke-engine && pip install -v --force-reinstall --no-cache-dir ../poke-engine/poke-engine-py --config-settings="build-args=--features poke-engine/terastallization --no-default-features"
Loading

0 comments on commit ce3fdc0

Please sign in to comment.