Skip to content

Commit

Permalink
Rename conda_yaml with conda_config (#1581)
Browse files Browse the repository at this point in the history
  • Loading branch information
carolineechen authored Dec 11, 2024
1 parent 0cbe466 commit 23ca976
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions runhouse/resources/hardware/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ def _sync_image_to_cluster(self):
if setup_step.step_type == ImageSetupStepType.SETUP_CONDA_ENV:
self.create_conda_env(
conda_env_name=setup_step.kwargs.get("conda_env_name"),
conda_yaml=setup_step.kwargs.get("conda_yaml"),
conda_config=setup_step.kwargs.get("conda_config"),
)
elif setup_step.step_type == ImageSetupStepType.PACKAGES:
self.install_packages(
Expand Down Expand Up @@ -1952,11 +1952,11 @@ def run_python(

return return_codes

def create_conda_env(self, conda_env_name: str, conda_yaml: Dict):
def create_conda_env(self, conda_env_name: str, conda_config: Dict):
install_conda(cluster=self)
create_conda_env_on_cluster(
conda_env_name=conda_env_name,
conda_yaml=conda_yaml,
conda_config=conda_config,
cluster=self,
)

Expand Down
8 changes: 4 additions & 4 deletions runhouse/resources/images/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def __init__(self, name: str, image_id: str = None):
>>> rh.Image(name="base_image")
>>> .setup_conda_env(
>>> conda_env_name="base_env",
>>> conda_yaml={"dependencies": ["python=3.11"], "name": "base_env"},
>>> conda_config={"dependencies": ["python=3.11"], "name": "base_env"},
>>> )
>>> .install_packages(["numpy", "pandas"])
>>> .set_env_vars({"OMP_NUM_THREADS": 1})
Expand Down Expand Up @@ -160,18 +160,18 @@ def run_bash(self, command: str, conda_env_name: Optional[str] = None):
)
return self

def setup_conda_env(self, conda_env_name: str, conda_yaml: Union[str, Dict]):
def setup_conda_env(self, conda_env_name: str, conda_config: Union[str, Dict]):
"""Setup Conda env
Args:
conda_env_name (str): Name of conda env to create.
conda_yaml (str or Dict): Path or Dict referring to the conda yaml config to use to create the conda env.
conda_config (str or Dict): Path or Dict referring to the conda yaml config to use to create the conda env.
"""
self.setup_steps.append(
ImageSetupStep(
step_type=ImageSetupStepType.SETUP_CONDA_ENV,
conda_env_name=conda_env_name,
conda_yaml=conda_yaml,
conda_config=conda_config,
)
)
self.conda_env_name = conda_env_name
Expand Down
6 changes: 3 additions & 3 deletions runhouse/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def install_conda(cluster: "Cluster" = None, node: Optional[str] = None):

def create_conda_env_on_cluster(
conda_env_name: str,
conda_yaml: Dict,
conda_config: Dict,
force: bool = False,
cluster: "Cluster" = None,
node: Optional[str] = None,
Expand All @@ -114,12 +114,12 @@ def create_conda_env_on_cluster(
"import yaml",
"from pathlib import Path",
f"path = Path('{ENVS_DIR}').expanduser()",
f"yaml.dump({conda_yaml}, open(path / '{conda_env_name}.yml', 'w'))",
f"yaml.dump({conda_config}, open(path / '{conda_env_name}.yml', 'w'))",
]
)
subprocess.run(f'python -c "{python_commands}"', shell=True)
else:
contents = yaml.dump(conda_yaml)
contents = yaml.dump(conda_config)
run_setup_command(
f"echo $'{contents}' > {yaml_path}", cluster=cluster, node=node
)
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/docker_cluster_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ def docker_cluster_pk_http_exposed(request, test_rns_folder):
Image(name="default_image")
.setup_conda_env(
conda_env_name="base_env",
conda_yaml={"dependencies": ["python=3.11"], "name": "base_env"},
conda_config={"dependencies": ["python=3.11"], "name": "base_env"},
)
.install_packages(
[
Expand Down
4 changes: 2 additions & 2 deletions tests/fixtures/on_demand_cluster_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def ondemand_gcp_cluster(request):
Image(name="default_image")
.setup_conda_env(
conda_env_name="base_env",
conda_yaml={"dependencies": ["python=3.11"], "name": "base_env"},
conda_config={"dependencies": ["python=3.11"], "name": "base_env"},
)
.install_packages(TEST_REQS + ["ray==2.30.0"], conda_env_name="base_env")
.set_env_vars(env_vars=TEST_ENV_VARS)
Expand Down Expand Up @@ -201,7 +201,7 @@ def multinode_cpu_docker_conda_cluster(request):
.from_docker("rayproject/ray:latest-py311-cpu")
.setup_conda_env(
conda_env_name="base_env",
conda_yaml={"dependencies": ["python=3.11"], "name": "base_env"},
conda_config={"dependencies": ["python=3.11"], "name": "base_env"},
)
.install_packages(TEST_REQS + ["ray==2.30.0"], conda_env_name="base_env")
)
Expand Down

0 comments on commit 23ca976

Please sign in to comment.