Skip to content

Commit

Permalink
Merge branch 'projectmesa:main' into patch-15
Browse files Browse the repository at this point in the history
  • Loading branch information
EwoutH authored Oct 28, 2023
2 parents cd83306 + 3b580a3 commit 699d824
Show file tree
Hide file tree
Showing 216 changed files with 2,720 additions and 14,544 deletions.
8 changes: 0 additions & 8 deletions .flake8

This file was deleted.

31 changes: 18 additions & 13 deletions .github/workflows/build_lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,12 @@ jobs:
fail-fast: False
matrix:
os: [windows, ubuntu, macos]
python-version: ["3.10"]
python-version: ["3.12"]
include:
- os: ubuntu
python-version: "3.11"
- os: ubuntu
python-version: "3.10"
- os: ubuntu
python-version: "3.9"
- os: ubuntu
Expand All @@ -41,7 +45,7 @@ jobs:
# python-version: 'pypy-3.8'

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
Expand All @@ -58,27 +62,28 @@ jobs:
name: Codecov
uses: codecov/codecov-action@v3

lint-flake:
lint-ruff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
- uses: actions/checkout@v4
- name: Set up Python 3.12
uses: actions/setup-python@v4
with:
python-version: "3.10"
- run: pip install flake8
- name: Lint with flake8
# Use settings from mesas .flake8 file
run: flake8 . --count --show-source --statistics
python-version: "3.12"
- run: pip install ruff~=0.1.1 # Update periodically
- name: Lint with ruff
# Include `--format=github` to enable automatic inline annotations.
# Use settings from pyproject.toml.
run: ruff . --output-format=github --extend-exclude 'mesa/cookiecutter-mesa/*'

lint-black:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
- uses: actions/checkout@v4
- name: Set up Python 3.12
uses: actions/setup-python@v4
with:
python-version: "3.10"
python-version: "3.12"
- run: pip install black[jupyter]
- name: Lint with black
run: black --check --exclude=mesa/cookiecutter-mesa/* .
2 changes: 1 addition & 1 deletion .github/workflows/codespell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
codespell:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: codespell-project/actions-codespell@master
with:
ignore_words_file: .codespellignore
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
name: Release
on: [push, pull_request, workflow_dispatch]

permissions:
id-token: write

jobs:
release:
name: Deploy release to PyPI
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
python-version: "3.12"
- name: Install dependencies
run: pip install -U pip build wheel setuptools
- name: Build distributions
Expand Down
31 changes: 0 additions & 31 deletions .github/workflows/update-pipfile.yml

This file was deleted.

6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ ci:

repos:
- repo: https://github.com/psf/black
rev: 22.10.0
rev: 23.9.1
hooks:
- id: black-jupyter
exclude: ^mesa/cookiecutter-mesa/
- repo: https://github.com/asottile/pyupgrade
rev: v3.1.0
rev: v3.14.0
hooks:
- id: pyupgrade
args: [--py38-plus]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0 # Use the ref you want to point at
rev: v4.4.0 # Use the ref you want to point at
hooks:
- id: trailing-whitespace
- id: check-toml
Expand Down
7 changes: 5 additions & 2 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,15 @@ sphinx:
formats:
- pdf

build:
os: "ubuntu-22.04"
tools:
python: "3.9"

# Optionally set the version of Python and requirements required to build your docs
python:
version: "3.8"
install:
- method: pip
path: .
extra_requirements:
- docs
system_packages: true
9 changes: 5 additions & 4 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@ discuss via `Matrix`_ OR via `an issue`_.
- `Clone your repository`_ from Github to your machine.
- Create a new branch in your fork: ``git checkout -b BRANCH_NAME``
- Run ``git config pull.rebase true``. This prevents messy merge commits when updating your branch on top of Mesa main branch.
- Install an editable version with developer requirements locally: ``pip install -e .[dev]``
- Install an editable version with developer requirements locally: ``pip install -e ".[dev]"``
- Edit the code. Save.
- Git add the new files and files with changes: ``git add FILE_NAME``
- Git commit your changes with a meaningful message: ``git commit -m "Fix issue X"``
- If implementing a new feature, include some documentation in docs folder.
- Make sure that your submission works with a few of the examples in the examples repository. If adding a new feature to mesa, please illustrate usage by implementing it in an example.
- Make sure that your submission passes the `GH Actions build`_. See "Testing and Standards below" to be able to run these locally.
- Make sure that your code is formatted according to `the black`_ standard (you can do it via `pre-commit`_).
- Push your changes to your fork on Github: ``git push origin NAME_OF_BRANCH``.
Expand Down Expand Up @@ -67,11 +68,11 @@ If you're changing previous Mesa features, please make sure of the following:
- Additional features or rewrites of current features are accompanied by tests.
- New features are demonstrated in a model, so folks can understand more easily.

To ensure that your submission will not break the build, you will need to install Flake8 and pytest.
To ensure that your submission will not break the build, you will need to install Ruff and pytest.

.. code-block:: bash
pip install flake8 pytest pytest-cov
pip install ruff pytest pytest-cov
We test by implementing simple models and through traditional unit tests in the tests/ folder. The following only covers unit tests coverage. Ensure that your test coverage has not gone down. If it has and you need help, we will offer advice on how to structure tests for the contribution.

Expand All @@ -90,7 +91,7 @@ You should no longer have to worry about code formatting. If still in doubt you

.. code-block:: bash
flake8 . --ignore=F403,E501,E123,E128,W504,W503 --exclude=docs,build
ruff .
.. _`PEP8` : https://www.python.org/dev/peps/pep-0008
Expand Down
40 changes: 17 additions & 23 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
FROM python:3.10-slim
# We can't use slim because we need either git/wget/curl to
# download mesa-examples, and so installing them requires
# updating the system anyway.
# We can't use alpine because NumPy doesn't support musllinux yet.
# But it's in the RC version https://github.com/numpy/numpy/issues/20089.
FROM python:bookworm
LABEL maintainer="rht <[email protected]>"

# To use this Dockerfile:
# 1. `docker build . -t mymesa_image`
# 2. `docker run --name mymesa_instance -p 8521:8521 -it mymesa_image`
# 3. In your browser, visit http://127.0.0.1:8521
# 2. `docker run --name mymesa_instance -p 8765:8765 -it mymesa_image`
# 3. In your browser, visit http://127.0.0.1:8765
#
# Currently, this Dockerfile defaults to running the Wolf-Sheep model, as an
# Currently, this Dockerfile defaults to running the Schelling model, as an
# illustration. If you want to run a different example, simply change the
# MODEL_DIR variable below to point to another model, e.g.
# examples/sugarscape_cg or path to your custom model.
# /mesa-examples/examples/sugarscape_cg or path to your custom model.
# You specify the MODEL_DIR (relative to this Git repo) by doing:
# `docker run --name mymesa_instance -p 8521:8521 -e MODEL_DIR=examples/sugarscape_cg -it mymesa_image`
# Note: the model directory MUST contain a run.py file.
# `docker run --name mymesa_instance -p 8765:8765 -e MODEL_DIR=/mesa-examples/examples/sugarscape_cg -it mymesa_image`
# Note: the model directory MUST contain an app.py file.

ENV MODEL_DIR=examples/wolf_sheep
ENV MODEL_DIR=/mesa-examples/examples/schelling_experimental

# Don't buffer output:
# https://docs.python.org/3.10/using/cmdline.html?highlight=pythonunbuffered#envvar-PYTHONUNBUFFERED
Expand All @@ -24,21 +29,10 @@ WORKDIR /opt/mesa

COPY . /opt/mesa

EXPOSE 8521/tcp

# Important: we don't install python3-dev, python3-pip and so on because doing
# so will install Python 3.9 instead of the already available Python 3.10 from
# the base image.
# The following RUN command is still provided for context.
# RUN apt-get update && apt-get upgrade -y -o Dpkg::Options::="--force-confold" \
# && apt-get install -y --no-install-recommends \
# build-essential \
# python3-dev \
# python3-pip \
# python3-setuptools \
# python3-wheel \
# && rm -rf /var/lib/apt/lists/*
RUN cd / && git clone https://github.com/projectmesa/mesa-examples.git

EXPOSE 8765/tcp

RUN pip3 install -e /opt/mesa

CMD ["sh", "-c", "cd $MODEL_DIR && python3 run.py"]
CMD ["sh", "-c", "cd $MODEL_DIR && solara run app.py --host=0.0.0.0"]
Loading

0 comments on commit 699d824

Please sign in to comment.