From c2791e6e1121e4cc7906e13cbf3a8970775560f3 Mon Sep 17 00:00:00 2001 From: Guido Petretto Date: Wed, 28 Jun 2023 13:55:04 +0200 Subject: [PATCH 1/2] update shell io --- src/qtoolkit/io/__init__.py | 2 +- src/qtoolkit/io/shell.py | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/qtoolkit/io/__init__.py b/src/qtoolkit/io/__init__.py index a4d31ea..cc9080d 100644 --- a/src/qtoolkit/io/__init__.py +++ b/src/qtoolkit/io/__init__.py @@ -3,4 +3,4 @@ from qtoolkit.io.shell import ShellIO, ShellState from qtoolkit.io.slurm import SlurmIO, SlurmState -scheduler_mapping = {"slurm": SlurmIO, "pbs": PBSIO} +scheduler_mapping = {"slurm": SlurmIO, "pbs": PBSIO, "shell": ShellIO} diff --git a/src/qtoolkit/io/shell.py b/src/qtoolkit/io/shell.py index d3fc6cd..727bc39 100644 --- a/src/qtoolkit/io/shell.py +++ b/src/qtoolkit/io/shell.py @@ -59,6 +59,10 @@ def qstate(self) -> QState: class ShellIO(BaseSchedulerIO): header_template: str = """ +exec > $${qout_path} +exec 2> $${qerr_path} + +echo $${job_name} $${qverbatim} """ @@ -178,8 +182,10 @@ def parse_jobs_list_output(self, exit_code, stdout, stderr) -> list[QJob]: if isinstance(stderr, bytes): stderr = stderr.decode() - if exit_code != 0: - msg = f"command ps failed: {stderr}" + # if asking only for pid that are not running the exit code is != 0, + # so check also on stderr for failing + if exit_code != 0 and stderr.strip(): + msg = f"command ps failed: stdout: {stdout}. stderr: {stderr}" raise CommandFailedError(msg) jobs_list = [] From f0a9e77e952fa6c15e228bad466e28157c942901 Mon Sep 17 00:00:00 2001 From: Guido Petretto Date: Wed, 28 Jun 2023 17:24:41 +0200 Subject: [PATCH 2/2] fix remote host --- src/qtoolkit/host/remote.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/qtoolkit/host/remote.py b/src/qtoolkit/host/remote.py index 362e043..9fc6080 100644 --- a/src/qtoolkit/host/remote.py +++ b/src/qtoolkit/host/remote.py @@ -161,6 +161,10 @@ def execute(self, command: str | list[str], workdir: str | Path | None = None): exit_code : int Exit code of the command. """ + + if isinstance(command, (list, tuple)): + command = " ".join(command) + # TODO: check here if we use the context manager. What happens if we provide the # connection from outside (not through a config) and we want to keep it alive ?