Skip to content

Commit

Permalink
Reorg EdgeRef and NodeRef and CI Fixes (#262)
Browse files Browse the repository at this point in the history
* Move EdgeRef and NodeRef to enums.py

* test no pip

* Try using Python 3.11

* TEST COMMIT

* Use v4 for CI Python

* Upgrade PIP

* Cache pip

* Upgrade setuptools

* Upgrade setuptools and rename flow

* Update .readthedocs.yml

* Remove deps in docsrequirements.txt

* Fix README.md

* Upgrade Perf to v4 checkout, 3.11 python, and comment
  • Loading branch information
bcollazo committed Dec 1, 2023
1 parent 2ae972f commit d24e1e2
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 48 deletions.
25 changes: 14 additions & 11 deletions .github/workflows/python-app.yml → .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Build the UI Docker image
run: docker build ui/ -t bcollazo/catanatron-react-ui:latest
- name: Build the Server Docker image
Expand All @@ -26,14 +26,15 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
- uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: 3.8
python-version: 3.11
cache: "pip" # caching pip dependencies
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install --upgrade pip setuptools wheel
pip install -r all-requirements.txt
- name: Lint with black
run: |
Expand All @@ -57,13 +58,15 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
- uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: 3.8
python-version: 3.11
cache: "pip" # caching pip dependencies
- name: Install dependencies
run: |
pip install --upgrade pip setuptools wheel
pip install -e catanatron_core
pip install -e catanatron_gym
- name: Inline test
Expand All @@ -74,7 +77,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: 16
Expand Down
20 changes: 12 additions & 8 deletions .github/workflows/perf-regression.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,21 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
- uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: 3.8
python-version: 3.11
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade pip setuptools
pip install -r all-requirements.txt
- name: Checkout PR and Master Branch
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
path: pr
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
ref: master
path: master
Expand All @@ -41,7 +41,11 @@ jobs:
tool: "pytest"
pr-benchmark-file-path: pr/benchmark.json
base-benchmark-file-path: master/benchmark.json
# A comment will be left on the latest PR commit if `alert-threshold` is exceeded
comment-on-alert: true
alert-threshold: "130%"
# Workflow will fail if `fail-threshold` is exceeded
fail-on-alert: true
fail-on-alert: false
fail-threshold: "150%"
# A token is needed to leave commit comments
github-token: ${{ secrets.GITHUB_TOKEN }}
21 changes: 19 additions & 2 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
# Explicitly set the version of Python and its requirements
# .readthedocs.yaml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Set the version of Python and other tools you might need
build:
os: ubuntu-22.04
tools:
python: "3.11"

# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: docs/source/conf.py

# We recommend specifying your dependencies to enable reproducible builds:
# https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
python:
version: 3.8
install:
- requirements: docs/requirements.txt
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ make upload-production PACKAGE=catanatron_gym

```
sphinx-quickstart docs
sphinx-apidoc -o docs/source catanatron
sphinx-apidoc -o docs/source catanatron_core
sphinx-build -b html docs/source/ docs/build/html
```

Expand Down
20 changes: 20 additions & 0 deletions catanatron_core/catanatron/models/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,26 @@
ROAD: Final = "ROAD"


# Given a tile, the reference to the node.
class NodeRef(Enum):
NORTH = "NORTH"
NORTHEAST = "NORTHEAST"
SOUTHEAST = "SOUTHEAST"
SOUTH = "SOUTH"
SOUTHWEST = "SOUTHWEST"
NORTHWEST = "NORTHWEST"


# References an edge from a tile.
class EdgeRef(Enum):
EAST = "EAST"
SOUTHEAST = "SOUTHEAST"
SOUTHWEST = "SOUTHWEST"
WEST = "WEST"
NORTHWEST = "NORTHWEST"
NORTHEAST = "NORTHEAST"


class ActionPrompt(Enum):
BUILD_INITIAL_SETTLEMENT = "BUILD_INITIAL_SETTLEMENT"
BUILD_INITIAL_ROAD = "BUILD_INITIAL_ROAD"
Expand Down
23 changes: 2 additions & 21 deletions catanatron_core/catanatron/models/map.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import typing
from dataclasses import dataclass
import random
from enum import Enum
from collections import Counter, defaultdict
from typing import Dict, FrozenSet, List, Literal, Mapping, Set, Tuple, Type, Union

Expand All @@ -13,33 +12,15 @@
SHEEP,
WHEAT,
ORE,
EdgeRef,
NodeRef,
)

NUM_NODES = 54
NUM_EDGES = 72
NUM_TILES = 19


# Given a tile, the reference to the node.
class NodeRef(Enum):
NORTH = "NORTH"
NORTHEAST = "NORTHEAST"
SOUTHEAST = "SOUTHEAST"
SOUTH = "SOUTH"
SOUTHWEST = "SOUTHWEST"
NORTHWEST = "NORTHWEST"


# References an edge from a tile.
class EdgeRef(Enum):
EAST = "EAST"
SOUTHEAST = "SOUTHEAST"
SOUTHWEST = "SOUTHWEST"
WEST = "WEST"
NORTHWEST = "NORTHWEST"
NORTHEAST = "NORTHEAST"


EdgeId = Tuple[int, int]
NodeId = int
Coordinate = Tuple[int, int, int]
Expand Down
3 changes: 0 additions & 3 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,13 @@ cloudpickle==2.1.0
colorama==0.4.4
decorator==4.4.2
docutils==0.16
gym==0.21.0
idna==2.10
imagesize==1.2.0
importlib-metadata==4.12.0
Jinja2==3.0.1
m2r2==0.3.2
MarkupSafe==2.0.1
mistune==0.8.4
networkx==2.5.1
numpy==1.23.1
packaging==20.9
pydata-sphinx-theme==0.9.0
Pygments==2.9.0
Expand Down
3 changes: 1 addition & 2 deletions tests/test_machine_learning.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@

from tests.utils import advance_to_play_turn, build_initial_placements
from catanatron.state import player_deck_replenish
from catanatron.models.enums import ORE, Action, ActionType, WHEAT
from catanatron.models.enums import ORE, Action, ActionType, WHEAT, NodeRef
from catanatron.models.board import Board, get_edges
from catanatron.models.map import (
BASE_MAP_TEMPLATE,
MINI_MAP_TEMPLATE,
NUM_EDGES,
NUM_NODES,
CatanMap,
NodeRef,
)
from catanatron.game import Game
from catanatron.models.map import number_probability
Expand Down

0 comments on commit d24e1e2

Please sign in to comment.