nemo_rl.utils.venvs#

Module Contents#

Functions#

create_local_venv

Create a virtual environment using uv and execute a command within it.

_env_builder

create_local_venv_on_each_node

Create a virtual environment on each Ray node.

Data#

API#

nemo_rl.utils.venvs.dir_path#

‘dirname(…)’

nemo_rl.utils.venvs.git_root#

‘abspath(…)’

nemo_rl.utils.venvs.DEFAULT_VENV_DIR#

‘join(…)’

nemo_rl.utils.venvs.logger#

‘getLogger(…)’

nemo_rl.utils.venvs.create_local_venv(
py_executable: str,
venv_name: str,
force_rebuild: bool = False,
) str[source]#

Create a virtual environment using uv and execute a command within it.

The output can be used as a py_executable for a Ray worker assuming the worker nodes also have access to the same file system as the head node.

This function is cached to avoid multiple calls to uv to create the same venv, which avoids duplicate logging.

Parameters:
  • py_executable (str) – Command to run with the virtual environment (e.g., “uv.sh run –locked”)

  • venv_name (str) – Name of the virtual environment (e.g., “foobar.Worker”)

  • force_rebuild (bool) – If True, force rebuild the venv even if it already exists

Returns:

Path to the python executable in the created virtual environment

Return type:

str

nemo_rl.utils.venvs._env_builder(
py_executable: str,
venv_name: str,
node_idx: int,
force_rebuild: bool = False,
)#
nemo_rl.utils.venvs.create_local_venv_on_each_node(py_executable: str, venv_name: str)[source]#

Create a virtual environment on each Ray node.

Parameters:
  • py_executable (str) – Command to run with the virtual environment

  • venv_name (str) – Name of the virtual environment

Returns:

Path to the python executable in the created virtual environment

Return type:

str