Skip to content

Commit

Permalink
Finish implementing typo correction suggestions
Browse files Browse the repository at this point in the history
Code has been added in all locations in the code that check values
against the list of valid values, and checks if there are similar
valid values in the list if the value in the config is invalid.

If there is a similar value (edit distance 3 or closer, currently,)
output will be printed pointing out the similar, valid value.
  • Loading branch information
Matthew Spelchak committed Feb 15, 2018
1 parent 5158b13 commit 5c9196a
Showing 1 changed file with 40 additions and 5 deletions.
45 changes: 40 additions & 5 deletions lib/galaxy/jobs/dynamic_tool_destination.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,10 @@ def __validate_destination(cls, valid_rule, return_bool, rule, tool, counter):
error += str(counter) + ": '"
error += str(rule["destination"])
error += "' does not exist in job configuration."
suggestion = get_typo_correction(rule['destination'],
destination_list, max_edit_dist)
if suggestion is not None:
error += " Did you mean '" + str(suggestion) + "'?"
if not return_bool:
error += " Ignoring..."
if verbose:
Expand All @@ -437,13 +441,12 @@ def __validate_destination(cls, valid_rule, return_bool, rule, tool, counter):
error = "Invalid priority '"
error += str(priority) + "' for rule "
error += str(counter) + " in '" + str(tool) + "'."
suggestion = get_typo_correction(priority,
priority_list, max_edit_dist)
if suggestion is not None:
error += " Did you mean '" + str(suggestion) + "'?"
if not return_bool:
error += " Ignoring..."
else:
suggestion = get_typo_correction(priority,
priority_list, max_edit_dist)
if suggestion is not None:
error += " Did you mean '" + str(suggestion) + "'?"
if verbose:
log.debug(error)
valid_rule = False
Expand All @@ -464,6 +467,10 @@ def __validate_destination(cls, valid_rule, return_bool, rule, tool, counter):
error += str(counter) + ": '"
error += str(rule["destination"]["priority"][priority])
error += "' does not exist in job configuration."
suggestion = get_typo_correction(rule["destination"]["priority"][priority],
destination_list, max_edit_dist)
if suggestion is not None:
error += " Did you mean '" + str(suggestion) + "'?"
if not return_bool:
error += " Ignoring..."
if verbose:
Expand Down Expand Up @@ -818,6 +825,10 @@ def infinite_defaultdict():
error = ("Default destination '"
+ obj['default_destination']
+ "' does not appear in the job configuration.")
suggestion = get_typo_correction(obj['default_destination'],
destination_list, max_edit_dist)
if suggestion is not None:
error += " Did you mean '" + str(suggestion) + "'?"
if verbose:
log.debug(error)
valid_config = False
Expand All @@ -837,6 +848,10 @@ def infinite_defaultdict():
error = ("Default destination '"
+ obj['default_destination']['priority'][priority]
+ "' does not appear in the job configuration.")
suggestion = get_typo_correction(obj['default_destination']['priority'][priority],
destination_list, max_edit_dist)
if suggestion is not None:
error += " Did you mean '" + str(suggestion) + "'?"
if verbose:
log.debug(error)
valid_config = False
Expand All @@ -861,6 +876,10 @@ def infinite_defaultdict():
else:
error = ("Default priority '" + str(obj['default_priority'])
+ "' is not a valid priority.")
suggestion = get_typo_correction(obj['default_priority'],
priority_list, max_edit_dist)
if suggestion is not None:
error += " Did you mean '" + str(suggestion) + "'?"
if verbose:
log.debug(error)
else:
Expand Down Expand Up @@ -912,6 +931,10 @@ def infinite_defaultdict():
error = ("User '" + user + "', priority '"
+ str(curr['priority']) + "' is not defined "
+ "in the global default_destination section")
suggestion = get_typo_correction(curr['priority'],
priority_list, max_edit_dist)
if suggestion is not None:
error += " Did you mean '" + str(suggestion) + "'?"
if verbose:
log.debug(error)
valid_config = False
Expand Down Expand Up @@ -954,6 +977,10 @@ def infinite_defaultdict():
+ str(tool) + "': '"
+ curr['default_destination']
+ "' does not appear in the job configuration.")
suggestion = get_typo_correction(curr['default_destination'],
destination_list, max_edit_dist)
if suggestion is not None:
error += " Did you mean '" + str(suggestion) + "'?"
if verbose:
log.debug(error)
valid_config = False
Expand All @@ -975,6 +1002,10 @@ def infinite_defaultdict():
+ str(tool) + "': '"
+ destination + "' does not appear "
+ "in the job configuration.")
suggestion = get_typo_correction(destination,
destination_list, max_edit_dist)
if suggestion is not None:
error += " Did you mean '" + str(suggestion) + "'?"
if verbose:
log.debug(error)
valid_config = False
Expand All @@ -990,6 +1021,10 @@ def infinite_defaultdict():
error = ("Invalid default destination priority '"
+ str(priority) + "' for '" + str(tool)
+ "'.")
suggestion = get_typo_correction(priority,
priority_list, max_edit_dist)
if suggestion is not None:
error += " Did you mean '" + str(suggestion) + "'?"
if verbose:
log.debug(error)
valid_config = False
Expand Down

0 comments on commit 5c9196a

Please sign in to comment.