Skip to content

Commit 37bf18a

Browse files
committed
error conditions, debug logging
1 parent 5b1e751 commit 37bf18a

File tree

3 files changed

+13
-26
lines changed

3 files changed

+13
-26
lines changed

ipyparallel/cluster/launcher.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1284,6 +1284,8 @@ def _fetch_file(self, remote, local, wait=True):
12841284
time.sleep(1)
12851285
elif check is True:
12861286
break
1287+
else:
1288+
raise ValueError(f"cmd_exists expects bool, got {check!r}")
12871289
local_dir = os.path.dirname(local)
12881290
ensure_dir_exists(local_dir, 700)
12891291
check_output(self.scp_cmd + self.scp_args + [full_remote, local])
@@ -1311,10 +1313,9 @@ def start(self, hostname=None, user=None, port=None):
13111313
# do some checks that setting are correct
13121314
shell_info = self.ssh_sender.get_shell_info()
13131315
python_ok = self.ssh_sender.has_python()
1314-
if self.log:
1315-
self.log.info(
1316-
f"ssh sender object initiated (break_away_support={self.ssh_sender.breakaway_support})"
1317-
)
1316+
self.log.debug(
1317+
f"ssh sender object initiated (break_away_support={self.ssh_sender.breakaway_support})"
1318+
)
13181319

13191320
# create remote profile dir
13201321
self.ssh_sender.check_output_python_module(
@@ -1326,11 +1327,8 @@ def start(self, hostname=None, user=None, port=None):
13261327
env=self.get_env(),
13271328
output_file=self.remote_output_file,
13281329
)
1329-
if self.log:
1330-
remote_cmd = ' '.join(self.program + self.program_args)
1331-
self.log.info(f"Running `{remote_cmd}` (pid={self.pid})")
1332-
# self.log.debug("Running script via ssh:\n%s", input_script)
1333-
pass
1330+
remote_cmd = ' '.join(self.program + self.program_args)
1331+
self.log.debug("Running `%s` (pid=%s)", remote_cmd, self.pid)
13341332
self.notify_start({'host': self.location, 'pid': self.pid})
13351333
self._start_waiting()
13361334
self.fetch_files()

ipyparallel/cluster/shellcmd.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ def _cmd_start_windows_no_breakaway(self, cmd_args, py_cmd):
195195
py_detached = _py_detached_tpl.format(input_json=input_json)
196196

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

ipyparallel/shellcmd.py

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -81,21 +81,10 @@ def main():
8181
f.write(f"\t{idx}:{arg}$\n")
8282
del args.debug
8383

84-
recevier = ShellCommandReceive()
85-
if cmd == "start":
86-
recevier.cmd_start(**vars(args))
87-
elif cmd == "running":
88-
recevier.cmd_running(**vars(args))
89-
elif cmd == "kill":
90-
recevier.cmd_kill(**vars(args))
91-
elif cmd == "mkdir":
92-
recevier.cmd_mkdir(**vars(args))
93-
elif cmd == "rmdir":
94-
recevier.cmd_rmdir(**vars(args))
95-
elif cmd == "exists":
96-
recevier.cmd_exists(**vars(args))
97-
elif cmd == "remove":
98-
recevier.cmd_remove(**vars(args))
84+
receiver = ShellCommandReceive()
85+
with receiver as r:
86+
recevier_method = getattr(r, f"cmd_{cmd}")
87+
recevier_method(**vars(args))
9988

10089

10190
if __name__ == '__main__':

0 commit comments

Comments
 (0)