From 80fc7044b10619b8638ceaa95aa7e1ba0e191828 Mon Sep 17 00:00:00 2001 From: Nathan Baltzell Date: Tue, 23 Jul 2024 15:59:11 -0400 Subject: [PATCH] prep Auger-less SWIF class --- python/hpsmc/batch.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/python/hpsmc/batch.py b/python/hpsmc/batch.py index a4fb49821..3efccbb25 100644 --- a/python/hpsmc/batch.py +++ b/python/hpsmc/batch.py @@ -724,6 +724,38 @@ def submit(self): proc.wait() +class Swif2(Swif): + + def __init__(self): + super().__init__() + + def _create_job_json(): + # read the XML and export the relevant parts to SWIF-JSON format + pass + + def submit(self): + + logger.info("Submitting swif workflow: {}".format(self.workflow)) + + # Write request to XML file + json_filename = self._create_job_json() + + # Add job to swif2 workflow using Auger XML file + cmd = ['swif2', 'import', '-file', json_filename] + proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + out = proc.communicate()[0] + print("".join([s for s in out.decode().strip().splitlines(True) if s.strip()])) + proc.wait() + + # Run the workflow + run_cmd = ['swif2', 'run', self.workflow] + proc = subprocess.Popen(run_cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + out = proc.communicate()[0] + print("".join([s for s in out.decode().strip().splitlines(True) if s.strip()])) + proc.wait() + + + class Local(Batch): """! Run local batch jobs sequentially.