Skip to content

Commit

Permalink
Shift to using pyproject.toml rather than setup.cfg and setup.py
Browse files Browse the repository at this point in the history
  • Loading branch information
pseudo-rnd-thoughts committed Aug 9, 2024
1 parent 0d26a5c commit 7f9f4f6
Show file tree
Hide file tree
Showing 14 changed files with 336 additions and 379 deletions.
9 changes: 2 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
pip install gymnasium>=1.0.0a2
pip install .[deploy]
run: pip install .[testing]
- name: Test with pytest
run: |
pip install pytest
pip install pytest-cov
pytest --cov=./ --cov-report=xml
run: pytest --cov=./ --cov-report=xml
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ jobs:
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.pypi_password }}
password: ${{ secrets.pypi_password }}
1 change: 0 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ repos:
hooks:
- id: isort
args: ["--profile", "black"]
exclude: "__init__.py"
- repo: https://github.com/python/black
rev: 23.3.0
hooks:
Expand Down
8 changes: 0 additions & 8 deletions codecov.yml

This file was deleted.

3 changes: 1 addition & 2 deletions highway_env/envs/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from highway_env.envs.exit_env import ExitEnv
from highway_env.envs.highway_env import HighwayEnv, HighwayEnvFast
from highway_env.envs.intersection_env import (
IntersectionEnv,
ContinuousIntersectionEnv,
IntersectionEnv,
MultiAgentIntersectionEnv,
)
from highway_env.envs.lane_keeping_env import LaneKeepingEnv
Expand All @@ -17,7 +17,6 @@
from highway_env.envs.two_way_env import TwoWayEnv
from highway_env.envs.u_turn_env import UTurnEnv


__all__ = [
"ExitEnv",
"HighwayEnv",
Expand Down
6 changes: 3 additions & 3 deletions highway_env/envs/common/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def __init__(
lateral: bool = True,
dynamical: bool = False,
clip: bool = True,
**kwargs
**kwargs,
) -> None:
"""
Create a continuous action space.
Expand Down Expand Up @@ -172,7 +172,7 @@ def __init__(
dynamical: bool = False,
clip: bool = True,
actions_per_axis: int = 3,
**kwargs
**kwargs,
) -> None:
super().__init__(
env,
Expand Down Expand Up @@ -216,7 +216,7 @@ def __init__(
longitudinal: bool = True,
lateral: bool = True,
target_speeds: Optional[Vector] = None,
**kwargs
**kwargs,
) -> None:
"""
Create a discrete action space of meta-actions.
Expand Down
8 changes: 4 additions & 4 deletions highway_env/envs/common/observation.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def __init__(
weights: List[float],
scaling: Optional[float] = None,
centering_position: Optional[List[float]] = None,
**kwargs
**kwargs,
) -> None:
super().__init__(env)
self.observation_shape = observation_shape
Expand Down Expand Up @@ -168,7 +168,7 @@ def __init__(
see_behind: bool = False,
observe_intentions: bool = False,
include_obstacles: bool = True,
**kwargs: dict
**kwargs: dict,
) -> None:
"""
:param env: The environment to observe
Expand Down Expand Up @@ -293,7 +293,7 @@ def __init__(
align_to_vehicle_axes: bool = False,
clip: bool = True,
as_image: bool = False,
**kwargs: dict
**kwargs: dict,
) -> None:
"""
:param env: The environment to observe
Expand Down Expand Up @@ -687,7 +687,7 @@ def __init__(
cells: int = 16,
maximum_range: float = 60,
normalize: bool = True,
**kwargs
**kwargs,
):
super().__init__(env, **kwargs)
self.cells = cells
Expand Down
2 changes: 1 addition & 1 deletion highway_env/road/road.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ def straight_road_network(
*nodes_str,
StraightLane(
origin, end, line_types=line_types, speed_limit=speed_limit
)
),
)
return net

Expand Down
54 changes: 49 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,50 @@
[build-system]
requires = [
"setuptools>=42",
"wheel"
[project]
name = "highway-env"
description = "An environment for simulated highway driving tasks."
readme = "README.md"
requires-python = ">= 3.8"
authors = [{ name = "Edouard Leurent", email = "eleurent@gmail.com" }]
license = { text = "MIT License" }
keywords = ["Reinforcement Learning", "car simulation", "RL", "AI"]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"License :: OSI Approved :: MIT License",
'Intended Audience :: Science/Research',
'Topic :: Scientific/Engineering :: Artificial Intelligence',
]
build-backend = "setuptools.build_meta"
dependencies = [
"gymnasium >=0.28.0",
"farama-notifications >=0.0.1",
"numpy >=1.21.0",
"pygame >=2.0.2",
"matplotlib",
"pandas",
"scipy"
]
dynamic = ["version"]

[project.optional-dependencies]
testing = [
"pytest",
"pytest-cov"
]

[project.urls]
Homepage = "https://farama.org"
Repository = "https://github.com/eleurent/highway-env"
Documentation = "https://highway-env.farama.org/"
"Bug Report" = "https://github.com/eleurent/highway-env/issues"

[tool.setuptools]
include-package-data = true

[tool.setuptools.packages.find]
include = ["highway_env", "highway_env.*"]

[tool.setuptools.package-data]
194 changes: 97 additions & 97 deletions scripts/highway_planning.ipynb
Original file line number Diff line number Diff line change
@@ -1,100 +1,100 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "QKWvMXWMBEJA"
},
"source": [
"# Behavioural Planning for Autonomous Highway Driving\n",
"\n",
"We plan a trajectory using the _Optimistic Planning for Deterministic systems_ ([OPD](https://hal.inria.fr/hal-00830182)) algorithm.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "s-ghXis6A_md"
},
"outputs": [],
"source": [
"#@title Imports for env, agent, and visualisation.\n",
"# Environment\n",
"!pip install highway-env\n",
"import gymnasium as gym\n",
"import highway_env\n",
"\n",
"# Agent\n",
"!pip install git+https://github.com/eleurent/rl-agents#egg=rl-agents\n",
"from rl_agents.agents.common.factory import agent_factory\n",
"\n",
"# Visualisation\n",
"import sys\n",
"from tqdm.notebook import trange\n",
"!pip install moviepy -U\n",
"!pip install imageio_ffmpeg\n",
"!pip install pyvirtualdisplay\n",
"!apt-get install -y xvfb ffmpeg\n",
"!git clone https://github.com/Farama-Foundation/HighwayEnv.git\n",
"sys.path.insert(0, './highway-env/scripts/')\n",
"from utils import record_videos, show_videos\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "bgNDDWwqCj8l"
},
"outputs": [],
"source": [
"#@title Run an episode\n",
"\n",
"# Make environment\n",
"env = gym.make(\"highway-fast-v0\", render_mode=\"rgb_array\")\n",
"env = record_videos(env)\n",
"(obs, info), done = env.reset(), False\n",
"\n",
"# Make agent\n",
"agent_config = {\n",
" \"__class__\": \"<class 'rl_agents.agents.tree_search.deterministic.DeterministicPlannerAgent'>\",\n",
" \"env_preprocessors\": [{\"method\":\"simplify\"}],\n",
" \"budget\": 50,\n",
" \"gamma\": 0.7,\n",
"}\n",
"agent = agent_factory(env, agent_config)\n",
"\n",
"# Run episode\n",
"for step in trange(env.unwrapped.config[\"duration\"], desc=\"Running...\"):\n",
" action = agent.act(obs)\n",
" obs, reward, done, truncated, info = env.step(action)\n",
" \n",
"env.close()\n",
"show_videos()"
]
}
],
"metadata": {
"colab": {
"name": "highway-planning.ipynb",
"provenance": []
},
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"pycharm": {
"stem_cell": {
"cell_type": "raw",
"metadata": {
"collapsed": false
},
"source": []
}
}
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "QKWvMXWMBEJA"
},
"source": [
"# Behavioural Planning for Autonomous Highway Driving\n",
"\n",
"We plan a trajectory using the _Optimistic Planning for Deterministic systems_ ([OPD](https://hal.inria.fr/hal-00830182)) algorithm.\n"
]
},
"nbformat": 4,
"nbformat_minor": 0
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "s-ghXis6A_md"
},
"source": [
"#@title Imports for env, agent, and visualisation.\n",
"# Environment\n",
"!pip install highway-env\n",
"import gymnasium as gym\n",
"import highway_env\n",
"\n",
"# Agent\n",
"!pip install git+https://github.com/eleurent/rl-agents#egg=rl-agents\n",
"from rl_agents.agents.common.factory import agent_factory\n",
"\n",
"# Visualisation\n",
"import sys\n",
"from tqdm.notebook import trange\n",
"!pip install moviepy -U\n",
"!pip install imageio_ffmpeg\n",
"!pip install pyvirtualdisplay\n",
"!apt-get install -y xvfb ffmpeg\n",
"!git clone https://github.com/Farama-Foundation/HighwayEnv.git\n",
"sys.path.insert(0, './highway-env/scripts/')\n",
"from utils import record_videos, show_videos\n"
],
"outputs": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "bgNDDWwqCj8l"
},
"source": [
"#@title Run an episode\n",
"\n",
"# Make environment\n",
"env = gym.make(\"highway-fast-v0\", render_mode=\"rgb_array\")\n",
"env = record_videos(env)\n",
"(obs, info), done = env.reset(), False\n",
"\n",
"# Make agent\n",
"agent_config = {\n",
" \"__class__\": \"<class 'rl_agents.agents.tree_search.deterministic.DeterministicPlannerAgent'>\",\n",
" \"env_preprocessors\": [{\"method\":\"simplify\"}],\n",
" \"budget\": 50,\n",
" \"gamma\": 0.7,\n",
"}\n",
"agent = agent_factory(env, agent_config)\n",
"\n",
"# Run episode\n",
"for step in trange(env.unwrapped.config[\"duration\"], desc=\"Running...\"):\n",
" action = agent.act(obs)\n",
" obs, reward, done, truncated, info = env.step(action)\n",
" \n",
"env.close()\n",
"show_videos()"
],
"outputs": []
}
],
"metadata": {
"colab": {
"name": "highway-planning.ipynb",
"provenance": []
},
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"pycharm": {
"stem_cell": {
"cell_type": "raw",
"metadata": {
"collapsed": false
},
"source": []
}
}
},
"nbformat": 4,
"nbformat_minor": 0
}
Loading

0 comments on commit 7f9f4f6

Please sign in to comment.