rlberry.manager.with_venv

rlberry.manager.with_venv(import_libs=None, requirements=None, venv_dir_name='rlberry_venvs', python_ver=None, verbose=False)[source]

Decorator to run the script in a function using a virtual environment.

Parameters:
import_libs: list of str or None, default = None

libraries to install in the virtual environment. If import_libs and requirements are both not None, requirements is used.

requirements: str or None, default = None

requirement file containing dependencies. If not None, this takes precedence on import_libs.

venv_fir_name: str, default = “rlberry_venvs”

name of the directory containing the virtual environments and requirement files.

python_ver: str, default=None

version of python to use in a virtual environment. For example “3.11”

verbose: boolean, default=False

verbose installation.

Examples

>>> from rlberry.manager import with_venv, run_venv_xp
>>>
>>> @with_venv(import_libs=["tqdm"])
>>> def run_tqdm():
>>>     from tqdm import tqdm  # noqa
>>>     for i in tqdm(range(100)):
>>>         sleep(0.01)
>>>
>>> def test_venv():
>>>     run_venv_xp()

Examples using rlberry.manager.with_venv

Using multiple virtual environments with rlberry

Using multiple virtual environments with rlberry