Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/lint_build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ jobs:
- name: Build release distributions
run: |
# NOTE: put your own distribution build steps here.
python -m pip install build
python -m build
python -m pip install uv
python -m uv build
17 changes: 13 additions & 4 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,39 @@ The goal of this repository is to learn a little more about reinforcement learni

## Getting Started

### Install

Please [install uv](https://docs.astral.sh/uv/getting-started/installation/#standalone-installer)

Then install the project
```
uv sync
```

### Training

Example: To train the Reinforce algorithm, use the following command:
```
python scripts/launch.py --train --config configs/reinforce.yaml
uv run rl-runner --train --config configs/reinforce.yaml
```
You can customize the training parameters, such as the number of episodes. For example, to set the maximum number of training episodes to 500:

```
python scripts/launch.py --train --config configs/reinforce.yaml trainer.max_episodes=500
uv run rl-runner --train --config configs/reinforce.yaml trainer.max_episodes=500
```

### Evaluation

To evaluate your models, use the same launch.py script but with the --test flag. You'll also need to specify the configuration file and the checkpoint from the outputs folder. Here’s an example:

```
python scripts/launch.py --test --config outputs/reinforce-discrete/../parsed.yaml --resume=outputs/reinforce-discrete/.../checkpoint.ckpt
uv run rl-runner --test --config outputs/reinforce-discrete/../parsed.yaml --resume=outputs/reinforce-discrete/.../checkpoint.ckpt
```

By default, this command will print the cumulative reward for each episode. If you'd like to render the environment and save a video, add the following options:

```
python scripts/launch.py --test --config outputs/reinforce-discrete/../parsed.yaml --resume=outputs/reinforce-discrete/.../checkpoint.ckpt system.environment.render=True --save-video
uv run rl-runner --test --config outputs/reinforce-discrete/../parsed.yaml --resume=outputs/reinforce-discrete/.../checkpoint.ckpt system.environment.render=True --save-video
```

## Contributions
Expand Down
96 changes: 96 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.uv]
index-url = "https://pypi.org/simple"
[tool.uv.sources]
torch = { index = "pytorch" }
torchvision = { index = "pytorch" }

[[tool.uv.index]]
name = "pytorch"
url = "https://download.pytorch.org/whl/cu124"
explicit = true

[project]
name = "rl-baselines"
version = "0.0.1"
description = "Implementations of Reinforcement Learning algorithms as baselines in Pytorch"
readme = "Readme.md"
authors = [
{ name = "Erick T", email = "erickdeivy01@gmail.com" },
]
classifiers = [
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.12",
]
requires-python = ">=3.12"
dependencies = [
"omegaconf==2.3.0",
"torch==2.6.0",
"torchvision==0.21.0",
"torchaudio==2.6.0",
"lightning==2.6.0",
"tensordict==0.10.0",
"gymnasium[classic-control]==1.2.2",
"torchrl==0.10.1",
"opencv-python==4.12.0.88",
"tensorboardX==2.6.4",
"tensorboard==2.20.0",
"ale-py==0.11.2"
]

[project.optional-dependencies]
runtime = [

]
dev = [
"ruff>=0.1.6",
"mypy>=1.7.0",
"types-PyYAML>=6.0.0",
"pre-commit>=3.6.0",
"ipython>=8.17.0",
"ipdb>=0.13.13",
]
docs = [
"mkdocs>=1.5.0",
"mkdocs-material>=9.4.0",
"mkdocstrings[python]>=0.24.0",
]

[project.urls]
Homepage = "https://github.com/erickTornero/rl-baselines"
Documentation = "https://github.com/erickTornero/rl-baselines"
Repository = "https://github.com/erickTornero/rl-baselines"
Issues = "https://github.com/erickTornero/rl-baselines/issues"

[project.scripts]
rl-runner = "rl_baselines.cli.launch:app"

# Hatchling configuration
[tool.hatch.build.targets.sdist]
include = [
"/src",
"/Readme.md",
]

[tool.hatch.build.targets.wheel]
packages = ["src/rl_baselines"]

[dependency-groups]
dev = [
"mypy>=1.17.1",
"pandas-stubs>=2.3.2.250926",
"pytest-asyncio>=1.1.0",
"pytest-cov>=6.2.1",
"pytest-mock>=3.14.1",
"ruff>=0.1.6",
"types-pymysql>=1.1.0.20250916",
"types-pyyaml>=6.0.0",
]
docs = [
"mkdocs>=1.6.1",
"mkdocs-material>=9.6.17",
"mkdocstrings[python]>=0.30.0",
]
18 changes: 0 additions & 18 deletions setup.py

This file was deleted.

File renamed without changes.
Empty file.
7 changes: 6 additions & 1 deletion scripts/launch.py → src/rl_baselines/cli/launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@

import rl_baselines

if __name__ == "__main__":

def app():
import argparse

parser = argparse.ArgumentParser()
Expand Down Expand Up @@ -80,3 +81,7 @@
model.test_rollout(save_video=args.save_video)
else:
raise NotImplementedError("")


if __name__ == "__main__":
app()
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@ def make_custom_envs(
env_class = getattr(cenvs, name)
return env_class(*args, **kwargs)
except Exception:
import ale_py
import gymnasium as gym
from torchrl import envs

gym.register_envs(ale_py)

if "render" in kwargs:
render = kwargs.pop("render")
if render:
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading