How to use the spython.main function in spython

To help you get started, we’ve selected a few spython examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github systemslab / popper / src / popper / runner_host.py View on Github external
def __init__(self, init_spython_client=True, **kw):
        super(SingularityRunner, self).__init__(**kw)

        self._spawned_containers = set()
        self._s = None

        if self._config.reuse:
            log.fail("Reuse not supported for SingularityRunner.")

        if not init_spython_client:
            return

        self._s = spython.main.Client
        self._s.quiet = True
github ReproNim / neurodocker / neurodocker / utils.py View on Github external
def get_singularity_client():
    try:
        import spython.main
    except ImportError:
        raise ImportError(
            "the singularity python (spython) package is required for this")
    return spython.main.Client
github edraizen / molmimic / molmimic / parsers / singularity.py View on Github external
#     job.defer(singularityStop, containerName)
    #
    # if deferParam == FORGO:
    #     remove = False
    # elif deferParam == RM:
    #     remove = True
    #     job.defer(singularityKill, containerName)
    # elif remove is True:
    #     job.defer(singularityKill, containerName)

    # if runscript is None:
    #     client_command = client.run
    # else:
    #     client_command = client.execute

    client = spython.main.get_client()

    try:
        if runscript is None:
            out = client.run(image=image,
                       args=parameters,
                       stream=stream,
                       bind=bind,
                       **kwargs)
        else:
            out = client.execute(image=image,
                                 command=command,
                                 stream=stream,
                                 bind=bind,
                                 **kwargs)
    except Exception as e:
        logger.error("Singularity had non-zero exit. Error: {} \n " +
github edraizen / molmimic / molmimic / parsers / singularity.py View on Github external
def pullSingularityImage(image, pull_folder=None):
    if pull_folder is None:
        pull_folder = os.environ.get("HOME", "")

    base_image = os.path.basename(image)+".simg"

    for dir in (pull_folder, os.getcwd(), os.environ.get("HOME")):
        path = os.path.join(dir, base_image)
        if os.path.isfile(path):
            return path

    client = spython.main.get_client()
    client.pull(image, name=base_image, pull_folder=pull_folder)

    return os.path.join(pull_folder, base_image)
github systemslab / popper / cli / popper / gha.py View on Github external
from subprocess import CalledProcessError, PIPE, Popen, STDOUT

import yaml
import docker
import spython
from spython.main.parse.parsers import DockerParser
from spython.main.parse.writers import SingularityWriter

import popper.cli
from popper.cli import log
from popper import scm, utils as pu
from popper.parser import Workflow


yaml.Dumper.ignore_aliases = lambda *args: True
s_client = spython.main.Client


class WorkflowRunner(object):
    """A GHA workflow runner."""

    def __init__(self, workflow):
        self.wf = workflow
        self.wf.parse()
        self.wid = pu.get_id(os.getuid(), self.wf.wfile)
        log.debug('workflow:\n{}'.format(
            yaml.dump(self.wf, default_flow_style=False, default_style='')))

    @staticmethod
    def check_secrets(wf, dry_run, skip_secrets_prompt):
        """Checks whether the secrets defined for a step block is set in the
        execution environment or not.