probing-environments


Nameprobing-environments JSON
Version 0.4.0 PyPI version JSON
download
home_page
SummaryProbing environments for RL/DeepRL algorithms debugging
upload_time2023-07-11 17:23:46
maintainer
docs_urlNone
authorYann Berthelot
requires_python>=3.8,<4.0
license
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # ProbingEnvironments
ProbingEnvironments is a library that provides Reinforcement Learning Environments allowing for easy debugging of DeepRL actor-critic algorithms. Tired of debugging your agent by running it on CartPole or another Gym Env and not being sure if it works or you have bugs that cancel one another? This library aims at providing testing envs to make sure that each individual part of your actor-critic algorithm works on simple cases, this allows you to narrow down your bug chase.

The goal of this library is either :
- To use the environments yourself to check your agent by hand
- To include the premade tests in your units tests, allowing to check your agent without relying on long training tests on more complex environments

Functionnalities :
- Simple environments (in the gym framework) allowing to identify the part of your actor-critic algorithm that seems to be faulty.
- Premade tests/checks that wraps the enviroments and your agent to easily use those environments by hand or in your unit tests.
- Premade adaptors to connect your agent to the tests (to adapt to the way you coded your agent without requiring refactoring) and a template to create yours.


# Installation 
```bash
pip install git+https://github.com/YannBerthelot/ProbingEnvironments
# if you need extras don't forget to install them in your virtualenv, e.g.
pip install stable-baselines3
```
OR
```bash
poetry add git+https://github.com/YannBerthelot/ProbingEnvironments
# OR, if you need extras (i.e. you are going to use your own adaptors) add @<version>[<extra_name>] e.g. for rlberry
poetry add "git+https://github.com/YannBerthelot/ProbingEnvironments@0.1.0[rlberry]"
```

Installation from PyPi is WIP.


# Extras list
- rlberry : rlberry
- sb3 : stable-baselines3

# How-to
- Install this library (with the required exgtras if the adaptators for your Agent are already provided)
- Create a unit test file in your project.
- Import pytest and the checks from ProbingEnvironments :
```python
import pytest
from probing_environments.checks import (
    check_advantage_policy,
    check_backprop_value_net,
    check_batching_process,
    check_loss_or_optimizer_value_net,
    check_reward_discounting,
)
```
- Import the adaptors for your library OR write them yourself (see template in adaptors/template.py):
```python
from probing_environments.adaptors.sb3 import (
    get_gamma,
    get_policy,
    get_value,
    init_agent,
    train_agent,
)
```
- Import your agent to be fed into the tests.
- You can then use the following tests in your unit tests (adapt the discrete parameter depending on if your agent handles Discrete or Box gym environments):
```python
def test_check_loss_or_optimizer_value_net():
    """
    Test that check_loss_or_optimizer_value_net works on failproof sb3.
    """
    check_loss_or_optimizer_value_net(
        AGENT, init_agent, train_agent, get_value, discrete=False
    )


def test_check_backprop_value_net():
    """
    Test that check_backprop_value_net works on failproof sb3.
    """
    check_backprop_value_net(AGENT, init_agent, train_agent, get_value, discrete=False)


def test_check_reward_discounting():
    """
    Test that check_reward_discounting works on failproof sb3.
    """
    check_reward_discounting(
        AGENT, init_agent, train_agent, get_value, get_gamma, discrete=False
    )


def test_check_advantage_policy():
    """
    Test that check_advantage_policy works on failproof sb3.
    """
    check_advantage_policy(AGENT, init_agent, train_agent, get_policy, discrete=False)


def test_check_actor_and_critic_coupling():
    """
    Test that test_check_actor_and_critic_coupling works on failproof sb3.
    """
    check_actor_and_critic_coupling(
        AGENT, init_agent, train_agent, get_policy, get_value, discrete=False
    )
```
- Run your tests and the (potential) error output should help you pinpoint where to start debugging !
- Keep them in your tests for non-regression testing

# Disclaimer
The idea for this library comes from this presentation from Andy L Jones : https://andyljones.com/posts/rl-debugging.html


# To-do

- [ ] Expand Readme with example of debugging
- [ ] Expand Readme with example of connector definition
- [ ] Fix the single action policy bug (sb3 policy returns an int instead of a list of float when probability is 100%)
- [ ] Further expand tests
- [ ] Fix the no-direct dependency issue when building for PyPi
- [ ] Release on Test-PyPi
- [ ] Init changelog and version automation
- [ ] Rework message codes so they are not cutoff on screen
- [ ] Rework the setup part of readme with extras for reproducibility

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "probing-environments",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8,<4.0",
    "maintainer_email": "",
    "keywords": "",
    "author": "Yann Berthelot",
    "author_email": "yannberthelot1@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/d2/34/cc946dad69d0e4c84c6ef7b4bc8cb81bcfc1b046652ba7fc82e8e5461bf8/probing_environments-0.4.0.tar.gz",
    "platform": null,
    "description": "# ProbingEnvironments\nProbingEnvironments is a library that provides Reinforcement Learning Environments allowing for easy debugging of DeepRL actor-critic algorithms. Tired of debugging your agent by running it on CartPole or another Gym Env and not being sure if it works or you have bugs that cancel one another? This library aims at providing testing envs to make sure that each individual part of your actor-critic algorithm works on simple cases, this allows you to narrow down your bug chase.\n\nThe goal of this library is either :\n- To use the environments yourself to check your agent by hand\n- To include the premade tests in your units tests, allowing to check your agent without relying on long training tests on more complex environments\n\nFunctionnalities :\n- Simple environments (in the gym framework) allowing to identify the part of your actor-critic algorithm that seems to be faulty.\n- Premade tests/checks that wraps the enviroments and your agent to easily use those environments by hand or in your unit tests.\n- Premade adaptors to connect your agent to the tests (to adapt to the way you coded your agent without requiring refactoring) and a template to create yours.\n\n\n# Installation \n```bash\npip install git+https://github.com/YannBerthelot/ProbingEnvironments\n# if you need extras don't forget to install them in your virtualenv, e.g.\npip install stable-baselines3\n```\nOR\n```bash\npoetry add git+https://github.com/YannBerthelot/ProbingEnvironments\n# OR, if you need extras (i.e. you are going to use your own adaptors) add @<version>[<extra_name>] e.g. for rlberry\npoetry add \"git+https://github.com/YannBerthelot/ProbingEnvironments@0.1.0[rlberry]\"\n```\n\nInstallation from PyPi is WIP.\n\n\n# Extras list\n- rlberry : rlberry\n- sb3 : stable-baselines3\n\n# How-to\n- Install this library (with the required exgtras if the adaptators for your Agent are already provided)\n- Create a unit test file in your project.\n- Import pytest and the checks from ProbingEnvironments :\n```python\nimport pytest\nfrom probing_environments.checks import (\n    check_advantage_policy,\n    check_backprop_value_net,\n    check_batching_process,\n    check_loss_or_optimizer_value_net,\n    check_reward_discounting,\n)\n```\n- Import the adaptors for your library OR write them yourself (see template in adaptors/template.py):\n```python\nfrom probing_environments.adaptors.sb3 import (\n    get_gamma,\n    get_policy,\n    get_value,\n    init_agent,\n    train_agent,\n)\n```\n- Import your agent to be fed into the tests.\n- You can then use the following tests in your unit tests (adapt the discrete parameter depending on if your agent handles Discrete or Box gym environments):\n```python\ndef test_check_loss_or_optimizer_value_net():\n    \"\"\"\n    Test that check_loss_or_optimizer_value_net works on failproof sb3.\n    \"\"\"\n    check_loss_or_optimizer_value_net(\n        AGENT, init_agent, train_agent, get_value, discrete=False\n    )\n\n\ndef test_check_backprop_value_net():\n    \"\"\"\n    Test that check_backprop_value_net works on failproof sb3.\n    \"\"\"\n    check_backprop_value_net(AGENT, init_agent, train_agent, get_value, discrete=False)\n\n\ndef test_check_reward_discounting():\n    \"\"\"\n    Test that check_reward_discounting works on failproof sb3.\n    \"\"\"\n    check_reward_discounting(\n        AGENT, init_agent, train_agent, get_value, get_gamma, discrete=False\n    )\n\n\ndef test_check_advantage_policy():\n    \"\"\"\n    Test that check_advantage_policy works on failproof sb3.\n    \"\"\"\n    check_advantage_policy(AGENT, init_agent, train_agent, get_policy, discrete=False)\n\n\ndef test_check_actor_and_critic_coupling():\n    \"\"\"\n    Test that test_check_actor_and_critic_coupling works on failproof sb3.\n    \"\"\"\n    check_actor_and_critic_coupling(\n        AGENT, init_agent, train_agent, get_policy, get_value, discrete=False\n    )\n```\n- Run your tests and the (potential) error output should help you pinpoint where to start debugging !\n- Keep them in your tests for non-regression testing\n\n# Disclaimer\nThe idea for this library comes from this presentation from Andy L Jones : https://andyljones.com/posts/rl-debugging.html\n\n\n# To-do\n\n- [ ] Expand Readme with example of debugging\n- [ ] Expand Readme with example of connector definition\n- [ ] Fix the single action policy bug (sb3 policy returns an int instead of a list of float when probability is 100%)\n- [ ] Further expand tests\n- [ ] Fix the no-direct dependency issue when building for PyPi\n- [ ] Release on Test-PyPi\n- [ ] Init changelog and version automation\n- [ ] Rework message codes so they are not cutoff on screen\n- [ ] Rework the setup part of readme with extras for reproducibility\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Probing environments for RL/DeepRL algorithms debugging",
    "version": "0.4.0",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c4302a27a5aa360e9f7b28d7d7d654666f8e130d715483eaa4bdaae604c411c2",
                "md5": "a89bd7587ed355557efcb75e72b342c6",
                "sha256": "540905a85cd059e80c3d8cba6e8e797c8e1b281016e875f09470085b7ef7c5a0"
            },
            "downloads": -1,
            "filename": "probing_environments-0.4.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a89bd7587ed355557efcb75e72b342c6",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8,<4.0",
            "size": 11335,
            "upload_time": "2023-07-11T17:23:45",
            "upload_time_iso_8601": "2023-07-11T17:23:45.132059Z",
            "url": "https://files.pythonhosted.org/packages/c4/30/2a27a5aa360e9f7b28d7d7d654666f8e130d715483eaa4bdaae604c411c2/probing_environments-0.4.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d234cc946dad69d0e4c84c6ef7b4bc8cb81bcfc1b046652ba7fc82e8e5461bf8",
                "md5": "5991f6c68f7cf08a23a6a7452d93da7d",
                "sha256": "ccc9f9dd0065f2fdddf67723066ee20d3478ae2552996535ab86e406bb98596a"
            },
            "downloads": -1,
            "filename": "probing_environments-0.4.0.tar.gz",
            "has_sig": false,
            "md5_digest": "5991f6c68f7cf08a23a6a7452d93da7d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8,<4.0",
            "size": 9831,
            "upload_time": "2023-07-11T17:23:46",
            "upload_time_iso_8601": "2023-07-11T17:23:46.941463Z",
            "url": "https://files.pythonhosted.org/packages/d2/34/cc946dad69d0e4c84c6ef7b4bc8cb81bcfc1b046652ba7fc82e8e5461bf8/probing_environments-0.4.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-07-11 17:23:46",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "probing-environments"
}
        
Elapsed time: 0.17385s