Skip to content

Commit

Permalink
Check for sample job_conf files if the standard one doesn't exist, ot…
Browse files Browse the repository at this point in the history
…her miscellaneous fixes

Updated __main__ code and get_destination_list_from_job_config  to
check for the sample job config files if the default one doesn't
exist, and if in verbose mode, notify the user to which one will
be used.

Also changed the version number to 1.1

Also removed references to waffles in the test files
  • Loading branch information
Matthew Spelchak committed Feb 20, 2018
1 parent c77bb86 commit de8c0a1
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 32 deletions.
63 changes: 44 additions & 19 deletions lib/galaxy/jobs/dynamic_tool_destination.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from yaml import load

__version__ = '1.0.0'
__version__ = '1.1.0'

# log to galaxy's logger
log = logging.getLogger(__name__)
Expand Down Expand Up @@ -1591,14 +1591,17 @@ def map_tool_to_destination(
return destination


def get_destination_list_from_job_config(job_config_location='/config/job_conf.xml'):
def get_destination_list_from_job_config(job_config_location):
"""
returns A list of all destination IDs declared in the job configuration
@type job_config_location: str
@param job_config_location: The location of the job config file relative
to the galaxy root directory. Defaults to
galaxy/config/job_conf.xml
to the galaxy root directory. If NoneType, defaults to
galaxy/config/job_conf.xml,
galaxy/config/job_conf.xml.sample_advanced, or
galaxy/config/job_conf.xml.sample_basic
(first one that exists)
@rtype: list
@return: A list of all of the destination IDs declared in the job
Expand All @@ -1609,10 +1612,36 @@ def get_destination_list_from_job_config(job_config_location='/config/job_conf.x
# os.path.realpath gets the path of DynamicToolDestination.py
# and then os.path.join is used to go back four directories

if job_config_location == "/config/job_conf.xml":
config_location = os.path.join(
os.path.dirname(os.path.realpath(__file__)), '../../..')
job_config_location = config_location + job_config_location
config_location = os.path.join(
os.path.dirname(os.path.realpath(__file__)), '../../..')

if job_config_location:
local_path = re.compile('^/config/.+$')
if local_path.match(job_config_location):
job_config_location = config_location + job_config_location
else: # Pick one of the default ones
message = "* No job config specified, "
if os.path.isfile(config_location + "/config/job_conf.xml"):
job_config_location = config_location + "/config/job_conf.xml"
message += "using 'config/job_conf.xml'. *"

elif os.path.isfile(config_location +
"/config/job_conf.xml.sample_advanced"):
job_config_location = (config_location
+ "/config/job_conf.xml.sample_advanced")
message += "using 'config/job_conf.xml.sample_advanced'. *"

elif os.path.isfile(config_location +
"/config/job_conf.xml.sample_basic"):
job_config_location = (config_location
+ "/config/job_conf.xml.sample_basic")
message += "using 'config/job_conf.xml.sample_basic'. *"
else:
message += "and no default job configs in 'config/'. Failing... *"

if verbose:
log.debug(message)


job_conf = ET.parse(job_config_location)

Expand Down Expand Up @@ -1765,21 +1794,17 @@ def get_typo_correction(typo_str, word_set, max_dist):
parser.print_help()
sys.exit(1)

if args.check_config and args.job_config:
valid_config = parse_yaml(path=args.check_config,
job_conf_path=args.job_config, return_bool=True)
if args.job_config:
job_conf = args.job_config
else:
job_conf = None

elif args.check_config:
if args.check_config:
valid_config = parse_yaml(path=args.check_config,
job_conf_path="/config/job_conf.xml", return_bool=True)

elif args.job_config:
valid_config = parse_yaml(path="/config/tool_destinations.yml",
job_conf_path=args.job_config, return_bool=True)

job_conf_path=job_conf, return_bool=True)
else:
valid_config = parse_yaml(path="/config/tool_destinations.yml",
job_conf_path="/config/job_conf.xml", return_bool=True)
job_conf_path=job_conf, return_bool=True)

if valid_config:
print("Configuration is valid!")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ tools:

default_destination:
priority:
low: waffles_default_low
med: waffles_default_med
high: waffles_default_high
low: cluster_default_low
med: cluster_default_med
high: cluster_default_high
users:
user@email.com:
priority: high
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ tools:
lower_bound: 1 KB
upper_bound: Infinity
destination: Destination1
default_destination: waffles_default
default_destination: waffles_default
default_destination: cluster_default
default_destination: cluster_default
verbose: False
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
tools:
spades:
default_destination: waffles_default
default_destination: cluster_default
smalt:
rules:
- rule_type: num_input_datasets
Expand All @@ -13,5 +13,5 @@ tools:
lower_bound: 200
upper_bound: Infinity
destination: cluster_high_32
default_destination: waffles_low
default_destination: cluster_low
verbose: True
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ tools:
lower_bound: 5
upper_bound: Infinity
destination: Destination3
default_destination: waffles_default
default_destination: cluster_default

test_overlap:
rules:
Expand All @@ -46,7 +46,7 @@ tools:
lower_bound: 5
upper_bound: Infinity
destination: Destination5
default_destination: waffles_default
default_destination: cluster_default

test_db:
rules:
Expand All @@ -61,7 +61,7 @@ tools:
lower_bound: 0
upper_bound: 1 KB
destination: Destination4
default_destination: waffles_default
default_destination: cluster_default

test_db_high:
rules:
Expand All @@ -70,7 +70,7 @@ tools:
lower_bound: 0
upper_bound: Infinity
destination: Destination5
default_destination: waffles_default
default_destination: cluster_default

test_arguments:
rules:
Expand All @@ -79,7 +79,7 @@ tools:
arguments:
careful: true
destination: Destination6
default_destination: waffles_default
default_destination: cluster_default

default_destination: waffles_default
default_destination: cluster_default
verbose: True

0 comments on commit de8c0a1

Please sign in to comment.