Skip to content
Snippets Groups Projects
Commit 9b5e05ab authored by John Chilton's avatar John Chilton
Browse files

Merge pull request #109 from mvdbeek/fix_plugin_finder

Fix for locating cli shell/job plugins
parents 083fa588 69c5e319
No related branches found
No related tags found
No related merge requests found
"""
"""
from glob import glob
from os.path import basename, join
from os import getcwd
from inspect import getsourcefile
from os import pardir
from os.path import abspath
from os.path import basename
from os.path import join
DEFAULT_SHELL_PLUGIN = 'LocalShell'
......@@ -19,12 +22,13 @@ class CliInterface(object):
def __init__(self, code_dir='lib'):
"""
"""
def __load(module_path, d):
module_pattern = join(join(getcwd(), code_dir, *module_path.split('.')), '*.py')
def __load(module_prefix, d, code_dir):
module_pattern = join(join(code_dir, module_prefix), '*.py')
for file in glob(module_pattern):
if basename(file).startswith('_'):
continue
module_name = '%s.%s' % (module_path, basename(file).rsplit('.py', 1)[0])
file = file.split(code_dir)[1]
module_name = '%s.%s' % (module_prefix.replace("/", "."), basename(file).rsplit('.py', 1)[0])
module = __import__(module_name)
for comp in module_name.split(".")[1:]:
module = getattr(module, comp)
......@@ -38,8 +42,11 @@ class CliInterface(object):
self.cli_job_interfaces = {}
module_prefix = self.__module__
__load('%s.shell' % module_prefix, self.cli_shells)
__load('%s.job' % module_prefix, self.cli_job_interfaces)
module_prefix = join(*module_prefix.split("."))
module_path = abspath(join(getsourcefile(CliInterface), pardir))
code_dir = module_path.split(module_prefix)[0]
__load('%s/shell' % module_prefix, self.cli_shells, code_dir)
__load('%s/job' % module_prefix, self.cli_job_interfaces, code_dir)
def get_plugins(self, shell_params, job_params):
"""
......
......@@ -15,6 +15,8 @@ elif [ -n "$SLURM_NTASKS" ] || [ -n "$SLURM_CPUS_PER_TASK" ]; then
GALAXY_SLOTS=`expr "${SLURM_NTASKS:-1}" \* "${SLURM_CPUS_PER_TASK:-1}"`
elif [ -n "$NSLOTS" ]; then
GALAXY_SLOTS="$NSLOTS"
elif [ -n "$NCPUS" ]; then
GALAXY_SLOTS="$NCPUS"
elif [ -n "$PBS_NCPUS" ]; then
GALAXY_SLOTS="$PBS_NCPUS"
elif [ -f "$PBS_NODEFILE" ]; then
......
#!$shell
$integrity_injection
$headers
$integrity_injection
$slots_statement
export GALAXY_SLOTS
GALAXY_LIB="$galaxy_lib"
......
......@@ -67,7 +67,7 @@ def job_script(template=DEFAULT_JOB_FILE_TEMPLATE, **kwds):
>>> 'PBS -test\\n' in script
False
>>> script = job_script(working_directory='wd', command='uptime', exit_code_path='ec', headers='#PBS -test', integrity_injection='')
>>> script.startswith('#!/bin/bash\\n\\n#PBS -test\\n')
>>> script.startswith('#!/bin/bash\\n\\n#PBS -test')
True
>>> script = job_script(working_directory='wd', command='uptime', exit_code_path='ec', slots_statement='GALAXY_SLOTS="$SLURM_JOB_NUM_NODES"')
>>> script.find('GALAXY_SLOTS="$SLURM_JOB_NUM_NODES"\\nexport GALAXY_SLOTS\\n') > 0
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment