diff --git a/longbow/applications.py b/longbow/applications.py index 0046592..c89cd77 100644 --- a/longbow/applications.py +++ b/longbow/applications.py @@ -146,8 +146,6 @@ def processjobs(jobs): for job in [a for a in jobs if "lbowconf" not in a]: filelist = [] - appplugins = getattr(apps, "PLUGINEXECS") - app = appplugins[os.path.basename(jobs[job]["executable"])] foundflags = [] substitution = {} @@ -180,6 +178,37 @@ def processjobs(jobs): "The local job directory '{0}' cannot be found for job '{1}'" .format(jobs[job]["localworkdir"], job)) + # Here we want to support generic executable launching. To do this + # we will switch off all checking and testing and simply upload all + # files in the job directory. + try: + + appplugins = getattr(apps, "PLUGINEXECS") + app = appplugins[os.path.basename(jobs[job]["executable"])] + + except KeyError: + + LOG.info("The software you are using is unsupported by a plugin. " + "Longbow will attempt to submit, but will assume you are" + "supplying modules manually or have used a absolute path" + "to your executable. If you think this is in error, " + "please open a ticket on github.") + + jobs[job]["upload-include"] = "" + jobs[job]["upload-exclude"] = "*.log" + + # Replace the input command line with the execution command line. + jobs[job]["executableargs"] = ( + jobs[job]["executable"] + " " + + " ".join(jobs[job]["executableargs"])) + + LOG.info("For job '%s' - execution string: %s", + job, jobs[job]["executableargs"]) + + LOG.info("Processing jobs - complete.") + + return + # Hook to determine command-line parameter substitutions. try: diff --git a/tests/unit/applications/test_processjobs.py b/tests/unit/applications/test_processjobs.py index 27b4152..94264ca 100644 --- a/tests/unit/applications/test_processjobs.py +++ b/tests/unit/applications/test_processjobs.py @@ -251,3 +251,52 @@ def test_processjobs_include(m_validator, m_proccommandline): assert jobs["jobone"]["upload-include"] == \ "test.file, input, coords, topol" + + +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" + + +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"