Skip to content
Snippets Groups Projects
Commit 6737f66f authored by Johannes Schumann's avatar Johannes Schumann
Browse files

Fix control for local GiBUU installation

parent c72101dc
No related branches found
No related tags found
1 merge request!12Restructure
......@@ -15,6 +15,7 @@ __status__ = "Development"
from shutil import copy
import subprocess
from spython.main import Client
import os
from os.path import join, abspath, basename, isdir, isfile
from tempfile import NamedTemporaryFile, TemporaryDirectory
from thepipe.logger import get_logger
......@@ -22,15 +23,10 @@ from thepipe.logger import get_logger
from . import IMAGE_NAME
from .config import Config
from .jobcard import Jobcard, read_jobcard
from .environment import is_singularity_version_greater, MIN_SINGULARITY_VERSION
from .environment import check_singularity_version
log = get_logger(basename(__file__))
if not is_singularity_version_greater(
MIN_SINGULARITY_VERSION): # pragma: no cover
log.error("Singularity version lower than %s" % MIN_SINGULARITY_VERSION)
raise OSError("Singularity version below %s" % MIN_SINGULARITY_VERSION)
GIBUU_SHELL = """
#!/bin/bash
......@@ -84,6 +80,7 @@ def run_jobcard(jobcard, outdir, container=False):
with open(jobcard_fpath, "w") as f:
f.write(str(jobcard))
if container:
check_singularity_version()
log.info("Create temporary file for associated runscript")
script_fpath = join(input_dir.name, "run.sh")
with open(script_fpath, "w") as f:
......@@ -106,6 +103,7 @@ def run_jobcard(jobcard, outdir, container=False):
return output["return_code"]
else:
p = subprocess.Popen(
[os.environ["CONTAINER_GIBUU_EXEC"], "<", jobcard_fpath],
"%s < %s" % (os.environ["CONTAINER_GIBUU_EXEC"], jobcard_fpath),
shell=True,
cwd=outdir)
return p.wait()
......@@ -25,13 +25,17 @@ log = get_logger(basename(__file__))
MIN_SINGULARITY_VERSION = "3.3"
def check_singularity_version(): # pragma: no cover
if not is_singularity_version_greater(MIN_SINGULARITY_VERSION):
log.error("Singularity version lower than %s" %
MIN_SINGULARITY_VERSION)
raise OSError("Singularity version below %s" % MIN_SINGULARITY_VERSION)
def is_singularity_version_greater(min_version): # pragma: no cover
singularity_version = LooseVersion(get_singularity_version().split()[-1])
retval = singularity_version > LooseVersion(MIN_SINGULARITY_VERSION)
return retval
def build_image(output_dir):
if not isdir(output_dir):
raise OSError("Directory not found!")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment