An Env is a Runhouse primitive that represents an compute environment.
Builds an instance of Env
.
reqs (List[str]) – List of package names to install in this environment.
conda_env (Union[str, Dict], optional) – Dict representing conda env, Path to a conda env yaml file, or name of a local conda environment.
name (Optional[str], optional) – Name of the environment resource.
setup_cmds (Optional[List[str]]) – List of CLI commands to run for setup when the environment is being set up on a cluster.
env_vars (Dict or str) – Dictionary of environment variables, or relative path to .env file containing environment variables. (Default: {})
working_dir (str or Path) – Working directory of the environment, to be loaded onto the system. (Default: “./”)
dryrun (bool, optional) – Whether to run in dryrun mode. (Default: True
)
The resulting Env object.
Example
>>> # regular python env
>>> env = rh.env(reqs=["torch", "pip"])
>>> env = rh.env(reqs=["reqs:./"], name="myenv")
>>>
>>> # conda env, see also rh.conda_env
>>> conda_env_dict =
>>> {"name": "new-conda-env", "channels": ["defaults"], "dependencies": "pip", {"pip": "diffusers"})
>>> conda_env = rh.env(conda_env=conda_env_dict) # from a dict
>>> conda_env = rh.env(conda_env="conda_env.yaml") # from a yaml file
>>> conda_env = rh.env(conda_env="local-conda-env-name") # from a existing local conda env
>>> conda_env = rh.env(conda_env="conda_env.yaml", reqs=["pip:/accelerate"]) # with additional reqs
Builds an instance of CondaEnv
.
reqs (List[str]) – List of package names to install in this environment.
conda_env (Union[str, Dict], optional) – Dict representing conda env, Path to a conda env yaml file, or name of a local conda environment.
name (Optional[str], optional) – Name of the environment resource.
setup_cmds (Optional[List[str]]) – List of CLI commands to run for setup when the environment is being set up on a cluster.
env_vars (Dict or str) – Dictionary of environment variables, or relative path to .env file containing environment variables. (Default: {})
working_dir (str or Path) – Working directory of the environment, to be loaded onto the system. (Default: “./”)
dryrun (bool, optional) – Whether to run in dryrun mode. (Default: True
)
The resulting CondaEnv object.
Example
>>> rh.conda_env(reqs=["torch"])
>>> rh.conda_env(reqs=["torch"], name="resource_name")
>>> rh.conda_env(reqs=["torch"], name="resource_name", conda_env={"name": "conda_env"})
Create an Env object from a config dict
Locally install packages and run setup commands.
Run command locally inside the environment
Send environment to the system (Cluster or file system). This includes installing packages and running setup commands if system is a cluster.
Example
>>> env = rh.env(reqs=["numpy", "pip"])
>>> cluster_env = env.to(my_cluster)
>>> s3_env = env.to("s3", path="s3_bucket/my_env")
- __init__(conda_yaml: str | Dict, name: str | None = None, reqs: List[str | Package] = [], setup_cmds: List[str] | None = None, env_vars: Dict | None = {}, working_dir: str | Path | None = './', dryrun: bool = True, **kwargs)[source]
Runhouse CondaEnv object.
Note
To create a CondaEnv, please use the factory methods
env()
orconda_env()
.
Create an Env object from a config dict
Locally install packages and run setup commands.