Skip to content

Commit

Permalink
Restructure project around pyproject.toml
Browse files Browse the repository at this point in the history
- Introduces `pyproject.toml` that contains all the package's configuration
- Removes `setup.py`
- Removes almost everything from `setup.cfg`. Only wheel config remains, which cannot be moved for now.
- Drops support for python 3.7. It's end of life.
- Adds tox command `dependencies` to generate requirements files with pinned dependencies based on dependencies specified in `pyproject.toml`.
- Tries to remove all version restrictions from dependencies. Some are kept because it would require code changes.
  • Loading branch information
fnberta committed Oct 24, 2023
1 parent d73b41c commit 7870bd1
Show file tree
Hide file tree
Showing 25 changed files with 1,314 additions and 333 deletions.
15 changes: 0 additions & 15 deletions .github/ISSUE_TEMPLATE.md

This file was deleted.

4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/documentation.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: Documentation
about: For missing documentation or improvements of existing documentation
about: Missing documentation or improvements of existing documentation
title: ''
labels: documentation
assignees: ''
Expand All @@ -9,7 +9,7 @@ assignees: ''

### Target
What feature(s) or functionality should be documented:
-
- [ ]

### Source code
What methods, classes etc. should be documented:
Expand Down
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/enhancement.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: Enhancement
about: For any kind of enhancement like new features or improvements to existing ones.
about: Any kind of enhancement like new features or improvements to existing ones.
title: ''
labels: enhancement
assignees: ''
Expand All @@ -9,7 +9,7 @@ assignees: ''

### Objectives
This issue aims to fulfill the following objectives:
- ...
- [ ]

### Todos
What needs to be done for the issue to be done and the objectives to be reached:
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: "3.7"
python-version: "3.8"
- name: Install tox
run: |
python -m pip install --upgrade pip
Expand All @@ -30,7 +30,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [ "3.7", "3.8", "3.9", "3.10" ]
python-version: [ "3.8", "3.9", "3.10" ]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -52,7 +52,7 @@ jobs:
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: "3.7"
python-version: "3.8"
- name: Install tox
run: |
python -m pip install --upgrade pip
Expand All @@ -67,7 +67,7 @@ jobs:
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: "3.7"
python-version: "3.8"
- name: Install tox
run: |
python -m pip install --upgrade pip
Expand Down
30 changes: 23 additions & 7 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: "3.7"
python-version: "3.8"
- name: Install tox
run: |
python -m pip install --upgrade pip
Expand All @@ -30,7 +30,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [ "3.7", "3.8", "3.9", "3.10" ]
python-version: [ "3.8", "3.9", "3.10" ]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -51,7 +51,7 @@ jobs:
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: "3.7"
python-version: "3.8"
- name: Install tox
run: |
python -m pip install --upgrade pip
Expand All @@ -72,7 +72,7 @@ jobs:
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: "3.7"
python-version: "3.8"
- name: Install tox
run: |
python -m pip install --upgrade pip
Expand All @@ -87,7 +87,7 @@ jobs:
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: "3.7"
python-version: "3.8"
- name: Install tox
run: |
python -m pip install --upgrade pip
Expand All @@ -102,7 +102,7 @@ jobs:
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: "3.7"
python-version: "3.8"
- name: Install tox
run: |
python -m pip install --upgrade pip
Expand All @@ -117,10 +117,26 @@ jobs:
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: "3.7"
python-version: "3.8"
- name: Install tox
run: |
python -m pip install --upgrade pip
pip install tox tox-gh-actions
- name: Run benchmarks
run: tox run -e benchmarks

publish:
if: ${{ false }} # disabled until decided when it should run exactly
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: "3.8"
- name: Install tox
run: |
python -m pip install --upgrade pip
pip install tox tox-gh-actions
- name: Publish new package version
run: tox run -e publish
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ __pycache__/
env/
build/
develop-eggs/
# dist/
dist/
downloads/
eggs/
.eggs/
Expand Down Expand Up @@ -124,4 +124,4 @@ playground/

*.pkl

images
images
10 changes: 5 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,20 +104,20 @@ the [navigation training](https://gitlab.aicrowd.com/flatland/baselines/blob/mas

### Stochastic events

Just like in real-worl transportation systems we introduced stochastic events to disturb normal traffic flow. Currently
we implemented a malfunction process that stops agents at random time intervalls for a random time of duration.
Just like in real-world transportation systems we introduced stochastic events to disturb normal traffic flow. Currently
we implemented a malfunction process that stops agents at random time intervals for a random time of duration.
Currently the Flatland environment can be initiated with the following poisson process parameters:

```python
# Use a the malfunction generator to break agents from time to time
stochastic_data = {'prop_malfunction': 0.1, # Percentage of defective agents
'malfunction_rate': 30, # Rate of malfunction occurence
'malfunction_rate': 30, # Rate of malfunction occurrence
'min_duration': 3, # Minimal duration of malfunction
'max_duration': 20 # Max duration of malfunction
}
```

The duration of a malfunction is uniformly drawn from the intervall `[min_duration,max_duration0]` and the occurance of
The duration of a malfunction is uniformly drawn from the intervall `[min_duration,max_duration0]` and the occurrence of
malfunctions follows a point poisson process with mean rate `malfunctin_rate`.

**!!!!IMPORTANT!!!!** Once a malfunction duration has finished, the agent will **automatically** resume movement. This
Expand All @@ -138,7 +138,7 @@ Changes since Flatland 0.2
Please list all major changes since the last version:

- Refactoring of rendering code: CamelCase functions changed to snake_case
- Tree Observation Added a new Featuer: `unusable_switch` which indicates switches that are not branchingpoints for the
- Tree Observation Added a new Featuer: `unusable_switch` which indicates switches that are not branching points for the
observing agent
- Updated the shortest path predictor
- Updated conflict detection with predictor
Expand Down
65 changes: 34 additions & 31 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Contributing

Contributions are welcome, and they are greatly appreciated! Every little bit
helps, and credit will always be given.
Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given.

You can contribute in many ways:

Expand All @@ -15,19 +14,18 @@ If you are reporting a bug, please make sure to fill out the appropriate issue t

### Fix Bugs

Look through the Repository Issue Tracker for bugs. Anything tagged with "bug" and "help wanted" is open to whoever
Look through the repository issue tracker for bugs. Anything tagged with "bug" and "help wanted" is open to whoever
wants to implement it.

### Implement Features

Look through the Repository Issue Tracker for features. Anything tagged with "enhancement" and "help wanted" is open to
Look through the repository issue tracker for features. Anything tagged with "enhancement" and "help wanted" is open to
whoever wants to implement it.

### Write Documentation

flatland could always use more documentation, whether as part of the
official flatland docs, in docstrings, or even on the web in blog posts,
articles, and such. A quick reference for writing good docstrings is available
flatland could always use more documentation, whether as part of the official flatland docs, in docstrings, or even on
the web in blog posts, articles, and such. A quick reference for writing good docstrings is available
at [writing-docstrings](https://docs.python-guide.org/writing/documentation/#writing-docstrings).

### Submit Feedback
Expand All @@ -50,14 +48,14 @@ Ready to contribute? Here's how to set up `flatland` for local development.
git clone [email protected]:flatland-association/flatland-rl.git
```

2. Setup a virtual environment using your preferred method (e.g. venv) and activate it. Make sure python 3.7, 3.8 and
3.9 interpreters are available. Note that if you are using an Apple Macbook with an M1 or M2 processor, you need to
use python 3.8 or 3.9.
2. Set up a virtual environment using your preferred method (we suggest the built-in venv) and activate it. Make sure
all the supported python interpreters (3.8, 3.9, 3.10) is available. This is important because you want to run the
test with all supported versions.

3. Install the software dependencies using pip:
3. Install dependencies required for development using pip:

```shell
pip install -r requirements_dev.txt
pip install -r requirements-dev.txt
```

4. Create a branch for local development:
Expand All @@ -68,42 +66,47 @@ Ready to contribute? Here's how to set up `flatland` for local development.

Now you can make your changes locally.

5. When you're done making changes, check that your changes pass the tests. Use tox to run them as it will automatically
test on all supported python versions:
5. When you're done making changes, check that your changes pass the tests. Use `tox` to run them as it will
automatically test on all supported python versions:
```shell
tox
```
6. Commit your changes and push your branch to Github:
6. Whenever you feel like you completed an iteration of your changes, commit and push them to GitHub:
```shell
git add .
git commit -m "Addresses #<issue-number> Your detailed description of your changes."
git commit
# Your favorite editor will open, allowing you to enter a message that describes your changes. The first line is the
# subject line. Use sentence capitalisation (but don't end with a period) and limit it to 50 characters. It's good
# practice to use imperative mood, e.g. "Add new feature that does X". If you need more space to describe your
# changes (focus on the what and why, less on the how), add an empty line and then continue with the body. Try to
# keep every line at 72 characters.
git push origin name-of-your-bugfix-or-feature
```
7. Open a pull request on Github targeting the `main` branch.
7. Open a pull request on GitHub targeting the `main` branch.
## Pull Request Guidelines
Before you submit a pull request, check that it meets these guidelines:
1. The pull request should include tests.
2. The code must be formatted (using an IDE like PyCharm can do this for you).
3. If the pull request adds functionality, the docs should be updated. Put your new functionality into a function with a
docstring, and add the feature to the list in README.rst.
4. The pull request should work for Python 3.7, 3.8, 3.9. We force pipelines to be run successfully for pull requests to
be merged.
5. Pull requests must be approved by at least one member of the core team. This is to ensure that the Technical
Guidelines below are respected and that the code is well tested.
1. Include tests to verify correct behaviour.
2. Format the code according to PEP 8 (an IDE like PyCharm can do this for you).
3. Update the docs if you add new functionality. Put your new functionality into a function with a docstring, and add
the feature to the list in `README.md`.
4. Make sure your changes work with Python 3.8, 3.9 and 3.10. We force pipelines to be run successfully for pull
requests to be merged.
5. Get an approval from at least one member of the core team. This is to ensure that
the [Technical Guidelines](#technical-guidelines) are respected and that the code is well tested.
## Technical Guidelines
### Clean Code
Please adhere to the general [Clean Code](https://www.planetgeek.ch/wp-content/uploads/2014/11/Clean-Code-V2.4.pdf)
principles, for instance, we write short and concise functions and use appropriate naming to ensure readability.
principles. For instance, we write short and concise functions and use appropriate naming to ensure readability.
### Naming Conventions
Expand All @@ -125,7 +128,7 @@ We use the pylint naming conventions:
Docstrings should be formatted using [numpydoc](https://numpydoc.readthedocs.io/en/latest/format.html).
### Accessing resources
### Accessing Resources
We use [importlib-resources](https://importlib-resources.readthedocs.io/en/latest/) to read from local files.
Expand Down Expand Up @@ -155,7 +158,7 @@ renderer.gl.save_image("filename.bmp")
## Type Hints
We use Type Hints ([PEP 484](https://www.python.org/dev/peps/pep-0484/)) for better readability and better IDE support:
We use type hints ([PEP 484](https://www.python.org/dev/peps/pep-0484/)) for better readability and better IDE support:
```python
# This is how you declare the type of a variable type in Python 3.6
Expand All @@ -172,11 +175,11 @@ else:
child = False
```
To get started with Type Hints, you can have a look at
To get started with type hints, you can have a look at
the [Type Hints Cheat Sheet](https://mypy.readthedocs.io/en/latest/cheat_sheet_py3.html).
Caveat: We discourage the usage of Type Aliases for structured data since its members remain unnamed. Instead, consider
using NamedTuple:
Caveat: We discourage the usage of type aliases for structured data since its members remain unnamed. Instead, consider
using `NamedTuple`:
```python
# Discouraged: Type Alias with unnamed members
Expand Down
18 changes: 6 additions & 12 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
include AUTHORS.md
include CONTRIBUTING.rst
include changelog.md
include LICENSE
include README.md

include requirements_dev.txt
include requirements_continuous_integration.txt

include CONTRIBUTING.md
include CHANGELOG.md

include requirements.txt
include requirements-dev.txt

graft flatland/png
graft env_data


recursive-include tests *
recursive-exclude * __pycache__
recursive-exclude * *.py[co]
prune __pycache__
global-exclude *.py[cod]

recursive-include docs *.rst *.md conf.py *.jpg *.png *.gif
Loading

0 comments on commit 7870bd1

Please sign in to comment.