Skip to content

Commit

Permalink
No longer save the "run" of anything run via ssh.
Browse files Browse the repository at this point in the history
  • Loading branch information
rohinb2 committed Jun 30, 2024
1 parent 77fb4fb commit b870708
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 32 deletions.
39 changes: 9 additions & 30 deletions runhouse/resources/hardware/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -1227,7 +1227,6 @@ def run(
port_forward: Union[None, int, Tuple[int, int]] = None,
require_outputs: bool = True,
node: Optional[str] = None,
run_name: Optional[str] = None,
_ssh_mode: str = "interactive", # Note, this only applies for non-password SSH
) -> List:
"""Run a list of shell commands on the cluster. If `run_name` is provided, the commands will be
Expand All @@ -1236,7 +1235,7 @@ def run(
Example:
>>> cpu.run(["pip install numpy"])
>>> cpu.run(["pip install numpy"], env="my_conda_env"])
>>> cpu.run(["python script.py"], run_name="my_exp")
>>> cpu.run(["python script.py"])
>>> cpu.run(["python script.py"], node="3.89.174.234")
"""
from runhouse.resources.envs import Env
Expand All @@ -1258,7 +1257,6 @@ def run(
port_forward=port_forward,
require_outputs=require_outputs,
node=node,
run_name=run_name,
_ssh_mode=_ssh_mode,
)
res_list.append(res)
Expand Down Expand Up @@ -1301,34 +1299,17 @@ def run(
return return_codes

full_commands = [env._full_command(cmd) for cmd in commands]
if not run_name:
# If not creating a Run then just run the commands via SSH and return
return self._run_commands_with_ssh(
full_commands,
cmd_prefix="",
stream_logs=stream_logs,
node=node,
port_forward=port_forward,
require_outputs=require_outputs,
_ssh_mode=_ssh_mode,
)

# Create and save the Run locally
from runhouse.resources.provenance import run

with run(name=run_name, cmds=commands, overwrite=True) as r:
return_codes = self._run_commands_with_ssh(
full_commands,
cmd_prefix="",
stream_logs=stream_logs,
node=node,
port_forward=port_forward,
require_outputs=require_outputs,
)
return_codes = self._run_commands_with_ssh(
full_commands,
cmd_prefix="",
stream_logs=stream_logs,
node=node,
port_forward=port_forward,
require_outputs=require_outputs,
)

# Register the completed Run
r._register_cmd_run_completion(return_codes)
logger.debug(f"Saved Run to path: {r.folder.path}")
return return_codes

def _run_commands_with_ssh(
Expand Down Expand Up @@ -1441,7 +1422,6 @@ def run_python(
stream_logs: bool = True,
node: str = None,
port_forward: Optional[int] = None,
run_name: Optional[str] = None,
):
"""Run a list of python commands on the cluster, or a specific cluster node if its IP is provided.
Expand Down Expand Up @@ -1470,7 +1450,6 @@ def run_python(
stream_logs=stream_logs,
node=node,
port_forward=port_forward,
run_name=run_name,
)

return return_codes
Expand Down
5 changes: 3 additions & 2 deletions tests/test_resources/test_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ def test_delete_fn_run_from_rns(submitted_run):
# ------------------------- CLI RUN ------------ ----------------------


@pytest.mark.skip("Run stuff is deprecated.")
def test_create_cli_python_command_run(ondemand_aws_cluster):
# Run python commands on the specified system. Save the run results to the .rh/logs/<run_name> folder of the system.
return_codes = ondemand_aws_cluster.run_python(
Expand All @@ -268,7 +269,6 @@ def test_create_cli_python_command_run(ondemand_aws_cluster):
"logging.info(f'File path: {local_blob.path}')",
"local_blob.rm()",
],
run_name=CLI_RUN_NAME,
stream_logs=True,
)
pprint(return_codes)
Expand All @@ -277,10 +277,11 @@ def test_create_cli_python_command_run(ondemand_aws_cluster):
assert "File path" in return_codes[0][1].strip()


@pytest.mark.skip("Run stuff is deprecated.")
def test_create_cli_command_run(ondemand_aws_cluster):
"""Run CLI command on the specified system.
Saves the Run locally to the rh/<run_name> folder of the local file system."""
return_codes = ondemand_aws_cluster.run(["python --version"], run_name=CLI_RUN_NAME)
return_codes = ondemand_aws_cluster.run(["python --version"])

assert return_codes[0][0] == 0, "Failed to run CLI command"
assert return_codes[0][1].strip() == "Python 3.10.6"
Expand Down

0 comments on commit b870708

Please sign in to comment.