Ejemplo n.º 1
0
def test_processjobs_include(m_validator, m_proccommandline):

    """Test that if user has provided upload-includes that they don't get
    overriden.
    """

    jobs = {
        "jobone": {
            "executableargs": ["-i", "input", "-c", "coords", "-p", "topol"],
            "localworkdir": os.path.join(os.getcwd(),
                                         "tests/standards/jobs/single"),
            "executable": "pmemd.MPI",
            "upload-include": "test.file",
            "upload-exclude": ""
        }
    }

    m_proccommandline.side_effect = _proccommandline

    m_validator.return_value = None

    processjobs(jobs)

    assert jobs["jobone"]["upload-include"] == \
        "test.file, input, coords, topol"
Ejemplo n.º 2
0
def test_processjobs_singlejob2(m_validator, m_proccommandline):

    """Test for single job, make sure parameters are all set correctly."""

    jobs = {
        "jobone": {
            "executableargs": ["-i", "input", "-c", "coords", "-p", "topol"],
            "localworkdir": os.path.join(os.getcwd(),
                                         "tests/standards/jobs/single"),
            "executable": "pmemd.MPI",
            "upload-include": "",
            "upload-exclude": ""
        }
    }

    m_proccommandline.side_effect = _proccommandline

    m_validator.return_value = None

    processjobs(jobs)

    assert jobs["jobone"]["upload-exclude"] == "*"
    assert jobs["jobone"]["localworkdir"] == os.path.join(
        os.getcwd(), "tests/standards/jobs/single")
    assert jobs["jobone"]["executableargs"] == \
        "pmemd.MPI -i input -c coords -p topol"
    assert jobs["jobone"]["upload-include"] == "input, coords, topol"
Ejemplo n.º 3
0
def test_processjobs_abspath():

    """Test exception is thrown when using absolute paths on command-line."""

    jobs = {
        "jobone": {
            "executableargs": ["-flag", "/path/to/file"],
            "executable": "pmemd.MPI"
        }
    }

    with pytest.raises(exceptions.RequiredinputError):

        processjobs(jobs)
Ejemplo n.º 4
0
def test_processjobs_pardir():

    """
    Test exception is thrown when using paths above workdir on command-line.
    """

    jobs = {
        "jobone": {
            "executableargs": ["-flag", "../../file"],
            "executable": "pmemd.MPI"
        }
    }

    with pytest.raises(exceptions.RequiredinputError):

        processjobs(jobs)
Ejemplo n.º 5
0
def test_processjobs_direxcept():

    """Test exception is thrown when job directory is missing."""

    jobs = {
        "jobone": {
            "executableargs": ["-i", "input", "-c", "coords", "-p", "topol"],
            "localworkdir": os.path.join(os.getcwd(),
                                         "tests/standards/jobs/error"),
            "executable": "pmemd.MPI",
            "upload-include": "",
            "upload-exclude": ""
        }
    }

    with pytest.raises(exceptions.DirectorynotfoundError):

        processjobs(jobs)
Ejemplo n.º 6
0
def test_processjobs_genericexec1():

    """
    Test that the generic executable case works with hard path
    """

    jobs = {
        "jobone": {
            "executableargs": ["-f", "input", "-c", "file", "-p", "test"],
            "localworkdir": os.getcwd(),
            "executable": "/opt/somesoftware/exec",
            "upload-include": "",
            "upload-exclude": ""
        }
    }

    processjobs(jobs)

    assert jobs["jobone"]["executableargs"] == \
        "/opt/somesoftware/exec -f input -c file -p test"
    assert jobs["jobone"]["upload-include"] == ""
    assert jobs["jobone"]["upload-exclude"] == "*.log"
Ejemplo n.º 7
0
def test_processjobs_genericexec2():

    """
    Test that the generic executable case works with module and exec only.
    """

    jobs = {
        "jobone": {
            "executableargs": ["-f", "input", "-c", "file", "-p", "test"],
            "localworkdir": os.getcwd(),
            "executable": "testexec",
            "upload-include": "",
            "upload-exclude": "",
            "modules": "testsoftware"
        }
    }

    processjobs(jobs)

    assert jobs["jobone"]["executableargs"] == \
        "testexec -f input -c file -p test"
    assert jobs["jobone"]["upload-include"] == ""
    assert jobs["jobone"]["upload-exclude"] == "*.log"
Ejemplo n.º 8
0
def longbow(jobs, parameters):
    """Entry point at the top level of the Longbow library.

    Being the top level method that makes calls on the Longbow library.
    This is a good place to link against Longbow if a developer does not want
    to link against the executable, or if low level linking is not needed or is
    over-kill.

    Required inputs are:
    parameters (dictionary): A dictionary containing the parameters and
                             overrides from the command-line.

    """
    # A failure at this level will result in jobs being killed off before
    # escalating the exception to trigger graceful exit.

    # Load configurations and initialise Longbow data structures.
    jobparams = configuration.processconfigs(parameters)

    # Copy to jobs so when exceptions are raised the structure is available.
    for param in jobparams:

        jobs[param] = jobparams[param]

    # Test all connection/s specified in the job configurations
    shellwrappers.checkconnections(jobs)

    # Test the hosts listed in the jobs configuration file have their
    # scheduler environments listed, if not then test and save them.
    scheduling.checkenv(jobs, parameters["hosts"])

    # Test that for the applications listed in the job configuration
    # file are available and that the executable is present.
    if parameters["nochecks"] is False:

        applications.checkapp(jobs)

    # Process the jobs command line arguments and find files for
    # staging.
    applications.processjobs(jobs)

    # Create jobfile and add it to the list of files that needs
    # uploading.
    scheduling.prepare(jobs)

    # Stage all of the job files along with the scheduling script.
    staging.stage_upstream(jobs)

    # Submit all jobs.
    scheduling.submit(jobs)

    # Process the disconnect function.
    if parameters["disconnect"] is True:

        raise exceptions.DisconnectException

    # Monitor all jobs.
    scheduling.monitor(jobs)

    # Clean up all jobs
    staging.cleanup(jobs)