Skip to content

Commit

Permalink
error conditions, debug logging
Browse files Browse the repository at this point in the history
  • Loading branch information
minrk committed Oct 28, 2024
1 parent 5b1e751 commit 37bf18a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 26 deletions.
16 changes: 7 additions & 9 deletions ipyparallel/cluster/launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -1284,6 +1284,8 @@ def _fetch_file(self, remote, local, wait=True):
time.sleep(1)
elif check is True:
break
else:
raise ValueError(f"cmd_exists expects bool, got {check!r}")
local_dir = os.path.dirname(local)
ensure_dir_exists(local_dir, 700)
check_output(self.scp_cmd + self.scp_args + [full_remote, local])
Expand Down Expand Up @@ -1311,10 +1313,9 @@ def start(self, hostname=None, user=None, port=None):
# do some checks that setting are correct
shell_info = self.ssh_sender.get_shell_info()
python_ok = self.ssh_sender.has_python()
if self.log:
self.log.info(
f"ssh sender object initiated (break_away_support={self.ssh_sender.breakaway_support})"
)
self.log.debug(
f"ssh sender object initiated (break_away_support={self.ssh_sender.breakaway_support})"
)

# create remote profile dir
self.ssh_sender.check_output_python_module(
Expand All @@ -1326,11 +1327,8 @@ def start(self, hostname=None, user=None, port=None):
env=self.get_env(),
output_file=self.remote_output_file,
)
if self.log:
remote_cmd = ' '.join(self.program + self.program_args)
self.log.info(f"Running `{remote_cmd}` (pid={self.pid})")
# self.log.debug("Running script via ssh:\n%s", input_script)
pass
remote_cmd = ' '.join(self.program + self.program_args)
self.log.debug("Running `%s` (pid=%s)", remote_cmd, self.pid)
self.notify_start({'host': self.location, 'pid': self.pid})
self._start_waiting()
self.fetch_files()
Expand Down
4 changes: 2 additions & 2 deletions ipyparallel/cluster/shellcmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def _cmd_start_windows_no_breakaway(self, cmd_args, py_cmd):
py_detached = _py_detached_tpl.format(input_json=input_json)

# now start proxy process detached
self.log.info("[ShellCommandSend._cmd_send] starting detached process...")
self.log.debug("[ShellCommandSend._cmd_send] starting detached process...")
self.log.debug("[ShellCommandSend._cmd_send] python command: \n%s", py_cmd)
try:
p = Popen(
Expand All @@ -206,7 +206,7 @@ def _cmd_start_windows_no_breakaway(self, cmd_args, py_cmd):
except Exception as e:
self.log.error(f"[ShellCommandSend._cmd_send] detached process failed: {e}")
raise e
self.log.info(
self.log.debug(
"[ShellCommandSend._cmd_send] detached process started successful. Waiting for redirected output (pid)..."
)

Expand Down
19 changes: 4 additions & 15 deletions ipyparallel/shellcmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,21 +81,10 @@ def main():
f.write(f"\t{idx}:{arg}$\n")
del args.debug

recevier = ShellCommandReceive()
if cmd == "start":
recevier.cmd_start(**vars(args))
elif cmd == "running":
recevier.cmd_running(**vars(args))
elif cmd == "kill":
recevier.cmd_kill(**vars(args))
elif cmd == "mkdir":
recevier.cmd_mkdir(**vars(args))
elif cmd == "rmdir":
recevier.cmd_rmdir(**vars(args))
elif cmd == "exists":
recevier.cmd_exists(**vars(args))
elif cmd == "remove":
recevier.cmd_remove(**vars(args))
receiver = ShellCommandReceive()
with receiver as r:
recevier_method = getattr(r, f"cmd_{cmd}")
recevier_method(**vars(args))


if __name__ == '__main__':
Expand Down

0 comments on commit 37bf18a

Please sign in to comment.