Skip to content

Commit 925f3f0

Browse files
committed
Merge branch 'issues2-5-12' into development
Conflicts: Longbow/plugins/schedulers/lsf.py Longbow/plugins/schedulers/pbs.py Longbow/plugins/schedulers/sge.py Longbow/plugins/schedulers/slurm.py Longbow/plugins/schedulers/soge.py
2 parents 9d1a99e + 88bdda5 commit 925f3f0

File tree

18 files changed

+562
-405
lines changed

18 files changed

+562
-405
lines changed

Longbow/corelibs/applications.py

Lines changed: 349 additions & 299 deletions
Large diffs are not rendered by default.

Longbow/corelibs/configuration.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
import logging
6060
import re
6161
import os
62+
from random import randint
6263

6364
# Depending on how Longbow is installed/utilised the import will be slightly
6465
# different, this should handle both cases.
@@ -158,7 +159,7 @@ def processconfigs(parameters):
158159

159160
# Define a dictionary of module defaults based on the plug-in names and
160161
# executables.
161-
modules = getattr(apps, "DEFMODULES")
162+
modules = getattr(apps, "PLUGINEXECS")
162163
modules[""] = ""
163164

164165
# Try and load the host file.
@@ -329,9 +330,15 @@ def processconfigs(parameters):
329330

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

332-
# Give each job a remote base path, a random hash will be added to this
333-
# during job processing
334-
jobs[job]["destdir"] = jobs[job]["remoteworkdir"]
333+
# Give each job a unique remote base path by adding a random hash to
334+
# jobname.
335+
destdir = job + ''.join(["%s" % randint(0, 9) for _ in range(0, 5)])
336+
337+
jobs[job]["destdir"] = os.path.join(jobs[job]["remoteworkdir"],
338+
destdir)
339+
340+
LOG.debug("Job '%s' will be run in the '%s' directory on the remote "
341+
"resource.", job, jobs[job]["destdir"])
335342

336343
return jobs
337344

Longbow/longbow

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -161,23 +161,15 @@ def main():
161161
execlist = getattr(apps, "EXECLIST")
162162

163163
# Search for recognised executables on the commandline
164-
for exe in execlist:
164+
for item in commandlineargs:
165165

166-
if exe in commandlineargs:
166+
if item in execlist:
167167

168-
if commandlineargs.count(exe) == 1:
169-
170-
executable = exe
171-
position = commandlineargs.index(exe)
172-
longbowargs = commandlineargs[:position]
173-
execargs = commandlineargs[position+1:]
174-
break
175-
176-
else:
177-
178-
raise exceptions.CommandlineargsError(
179-
"More than one recognised executable has been specified on"
180-
" the Longbow command line. Please provide just one.")
168+
executable = item
169+
position = commandlineargs.index(item)
170+
longbowargs = commandlineargs[:position]
171+
execargs = commandlineargs[position+1:]
172+
break
181173

182174
# If an executable wasn't found perhaps it is specified in a configuration
183175
# file. Executable arguments might still be provided on the command line so

Longbow/plugins/__init__.py

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,6 @@
1919
# Longbow. If not, see <http://www.gnu.org/licenses/>.
2020

2121
"""
22-
This module provides the basic import framwork for Longbow plug-ins. On import,
23-
this module will import an plug-in packages that are contained within the
24-
plug-ins directory. This gives direct access to any new plug-ins that are added
25-
to the directory for use within the core library.
22+
This is the top level of the plugin framework. Longbow only natively supports
23+
plugin for applications (plugins.apps) and schedulers (plugins.schedulers).
2624
"""
27-
28-
import pkgutil
29-
import os
30-
import sys
31-
32-
PATH = os.path.dirname(__file__)
33-
PACKAGES = pkgutil.walk_packages(path=[PATH])
34-
PLUGINS = {}
35-
36-
for packageloader, packagename, ispkg in PACKAGES:
37-
try:
38-
package = __import__("Longbow.plugins." + packagename)
39-
40-
except ImportError:
41-
package = __import__("plugins." + packagename)
42-
43-
PLUGINS[packagename] = "plugins." + packagename

Longbow/plugins/apps/__init__.py

Lines changed: 21 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -32,60 +32,44 @@
3232
PATH = os.path.dirname(__file__)
3333
MODULES = pkgutil.iter_modules(path=[PATH])
3434

35-
# These structures make using the code lighter on the utilisation side
36-
# devs can get the data they want using getattr without having to construct
37-
# there own structures. This is at least true for basic lists and dicts.
38-
APPDATA = {}
3935
EXECLIST = []
40-
DEFMODULES = {}
41-
EXECFLAGS = {}
36+
PLUGINEXECS = {}
4237

43-
# Optional param for if the modules are named in a different way to simply
44-
# that the modules are called the same as the software (rare).
45-
MODULEOVERIDES = {}
4638
# Loop through all the modules in the plugin.
4739
for loader, modulename, ispkg in MODULES:
4840

49-
# check for double loading in the namespace.
41+
# Check for double loading in the namespace.
5042
if modulename not in sys.modules:
51-
# try to import using the pip package path.
43+
44+
# Try to import from the site-packages path.
5245
try:
53-
mod = __import__(
54-
"Longbow.plugins.apps." + modulename, fromlist=[""])
46+
47+
mod = __import__("Longbow.plugins.apps." + modulename,
48+
fromlist=[""])
5549

5650
except ImportError:
57-
# Else try to import using the non packaged path.
51+
52+
# Else try to import from a directory installed path.
5853
try:
59-
mod = __import__(
60-
"plugins.apps." + modulename, fromlist=[""])
54+
mod = __import__("plugins.apps." + modulename,
55+
fromlist=[""])
56+
6157
except ImportError:
58+
6259
# Otherwise we've had it! Raise exception.
6360
raise
6461

6562
# Now try and pull in attributes.
6663
try:
67-
APPDATA[modulename] = getattr(mod, "EXECDATA")
6864

69-
except AttributeError:
70-
raise
65+
for executable, _ in getattr(mod, "EXECDATA").items():
7166

72-
try:
73-
MODULEOVERIDES[modulename] = getattr(mod, "MODULEOVERIDE")
67+
# Compile a list of executables across all plugins.
68+
EXECLIST.append(executable)
69+
70+
# Compile a dictionary associating executable with plugins.
71+
PLUGINEXECS[executable] = modulename
7472

7573
except AttributeError:
76-
MODULEOVERIDES[modulename] = ""
77-
78-
# Construct common structures to make programmers lives easier.
79-
for plugin in APPDATA:
80-
for executable, flags in APPDATA[plugin].items():
81-
# compile a list of executables.
82-
EXECLIST.append(executable)
83-
84-
# compile dictionary of required input flags.
85-
EXECFLAGS[executable] = flags
86-
87-
# Compile a list of default modules.
88-
if MODULEOVERIDES[plugin] == "":
89-
DEFMODULES[executable] = plugin
90-
else:
91-
DEFMODULES[executable] = MODULEOVERIDES[plugin]
74+
75+
raise

Longbow/plugins/apps/amber.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,16 @@
2121
"""."""
2222

2323
EXECDATA = {
24-
"pmemd": ["-c", "-i", "-p"],
25-
"pmemd.MPI": ["-c", "-i", "-p"],
26-
"pmemd.cuda": ["-c", "-i", "-p"]
24+
"pmemd": {
25+
"subexecutables": [],
26+
"requiredfiles": ["-c", "-i", "-p"],
27+
},
28+
"pmemd.MPI": {
29+
"subexecutables": [],
30+
"requiredfiles": ["-c", "-i", "-p"],
31+
},
32+
"pmemd.cuda": {
33+
"subexecutables": [],
34+
"requiredfiles": ["-c", "-i", "-p"],
35+
}
2736
}

Longbow/plugins/apps/charmm.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,18 @@
3333

3434

3535
EXECDATA = {
36-
"charmm": ["?"]
36+
"charmm": {
37+
"subexecutables": [],
38+
"requiredfiles": ["<"],
39+
},
40+
"charmm_mpi": {
41+
"subexecutables": [],
42+
"requiredfiles": ["<"],
43+
},
44+
"charmm_cuda": {
45+
"subexecutables": [],
46+
"requiredfiles": ["<"],
47+
}
3748
}
3849

3950

Longbow/plugins/apps/desmond.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Longbow is Copyright (C) of James T Gebbie-Rayet and Gareth B Shannon 2015.
2+
#
3+
# This file is part of the Longbow software which was developed as part of the
4+
# HECBioSim project (http://www.hecbiosim.ac.uk/).
5+
#
6+
# HECBioSim facilitates and supports high-end computing within the UK
7+
# biomolecular simulation community on resources such as ARCHER.
8+
#
9+
# Longbow is free software: you can redistribute it and/or modify it under the
10+
# terms of the GNU General Public License as published by the Free Software
11+
# Foundation, either version 2 of the License, or (at your option) any later
12+
# version.
13+
#
14+
# Longbow is distributed in the hope that it will be useful, but WITHOUT ANY
15+
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16+
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
17+
#
18+
# You should have received a copy of the GNU General Public License along with
19+
# Longbow. If not, see <http://www.gnu.org/licenses/>.
20+
21+
"""."""
22+
23+
EXECDATA = {
24+
"desmond": {
25+
"subexecutables": [],
26+
"requiredfiles": ["--include || --restore"],
27+
},
28+
}

Longbow/plugins/apps/gromacs.py

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,34 @@
2323
import os
2424

2525
EXECDATA = {
26-
"mdrun": ["-s || -deffnm"],
27-
"mdrun_d": ["-s || -deffnm"],
28-
"mdrun_mpi": ["-s || -deffnm"],
29-
"mdrun_mpi_d": ["-s || -deffnm"]
26+
"gmx": {
27+
"subexecutables": ["mdrun", "mdrun_mpi"],
28+
"requiredfiles": ["-s || -deffnm"],
29+
},
30+
"gmx_d": {
31+
"subexecutables": ["mdrun", "mdrun_mpi"],
32+
"requiredfiles": ["-s || -deffnm"],
33+
},
34+
"mdrun": {
35+
"subexecutables": [],
36+
"requiredfiles": ["-s || -deffnm"],
37+
},
38+
"mdrun_d": {
39+
"subexecutables": [],
40+
"requiredfiles": ["-s || -deffnm"],
41+
},
42+
"mdrun_mpi": {
43+
"subexecutables": [],
44+
"requiredfiles": ["-s || -deffnm"],
45+
},
46+
"mdrun_mpi_d": {
47+
"subexecutables": [],
48+
"requiredfiles": ["-s || -deffnm"],
49+
}
3050
}
3151

3252

33-
def defaultfilename(path, item):
53+
def defaultfilename(path, item, initargs):
3454

3555
"""Method for dealing with input files that are provided by the -deffnm
3656
flag. The reason this needs a special message is due to the fact that
@@ -44,4 +64,13 @@ def defaultfilename(path, item):
4464

4565
filename = item + ".tpr"
4666

47-
return filename
67+
if initargs != "":
68+
69+
if "-s" not in initargs and "-deffnm" in initargs:
70+
71+
index = initargs.index("-deffnm")
72+
73+
initargs.insert(index, os.path.join("../", filename))
74+
initargs.insert(index, "-s")
75+
76+
return filename, initargs

Longbow/plugins/apps/lammps.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,30 @@
3333

3434

3535
EXECDATA = {
36-
"lmp_xc30": ["-i"]
36+
"lmp_xc30": {
37+
"subexecutables": [],
38+
"requiredfiles": ["-i"],
39+
},
40+
"lmp_linux": {
41+
"subexecutables": [],
42+
"requiredfiles": ["-i"],
43+
},
44+
"lmp_gpu": {
45+
"subexecutables": [],
46+
"requiredfiles": ["-i"],
47+
},
48+
"lmp_mpi": {
49+
"subexecutables": [],
50+
"requiredfiles": ["-i"],
51+
},
52+
"lmp_cuda": {
53+
"subexecutables": [],
54+
"requiredfiles": ["-i"],
55+
},
56+
"lmp": {
57+
"subexecutables": [],
58+
"requiredfiles": ["-i"],
59+
}
3760
}
3861

3962

0 commit comments

Comments
 (0)