Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #63 #69

Merged
merged 1 commit into from
Aug 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions longbow/corelibs/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,10 +438,18 @@ def _processconfigsfinalinit(jobs):

jobs[job]["executableargs"] = jobs[job]["executableargs"].split()

# If modules hasn't been set then try and use a default.
# If modules hasn't been set then try and use a default. If the
# executable is given as an absolute path than we will assume the user
# knows they need to provide any modules to load etc.
if jobs[job]["modules"] is "":

jobs[job]["modules"] = modules[jobs[job]["executable"]]
try:

jobs[job]["modules"] = modules[jobs[job]["executable"]]

except KeyError:

pass

# Give each job a unique base path by adding a random hash to jobname.
destdir = job + ''.join(["%s" % randint(0, 9) for _ in range(0, 5)])
Expand Down
27 changes: 27 additions & 0 deletions tests/unit/corelibs_configuration/test_processconfigsfinalinit.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
def test_processconfigsfinalinit1():

"""
Tests for basic functionality of the final initialisation checking method.
"""

jobs = {
Expand Down Expand Up @@ -75,3 +76,29 @@ def test_processconfigsfinalinit1():
assert jobs["jobtwo"]["destdir"] != ""
assert jobs["jobtwo"]["remoteworkdir"] == "/work/dir"
assert jobs["jobtwo"]["modules"] == "gromacs"


def test_processconfigsfinalinit2():

"""
Test with an absolute path for the executable.
"""

jobs = {
"test": {
"modules": "",
"localworkdir": "/somepath/to/dir",
"executableargs": "arg1 arg2 arg3",
"executable": "/some/path/to/mdrun_mpi_d",
"remoteworkdir": "/work/dir"
}
}

_processconfigsfinalinit(jobs)

assert jobs["test"]["localworkdir"] == "/somepath/to/dir"
assert jobs["test"]["executableargs"] == ["arg1", "arg2", "arg3"]
assert jobs["test"]["executable"] == "/some/path/to/mdrun_mpi_d"
assert jobs["test"]["destdir"] != ""
assert jobs["test"]["remoteworkdir"] == "/work/dir"
assert jobs["test"]["modules"] == ""