Skip to content

Commit

Permalink
Adjusted a bunch of Boutiques modules
Browse files Browse the repository at this point in the history
The adjustements here are meant to make sure
each of the modules do nothing if they happen to be
including in a task class, but the associated
ToolConfig's boutiques descriptor doesn't contain
any configuration for them. See github issue aces#1462
  • Loading branch information
prioux committed Jan 20, 2025
1 parent 057739d commit 4a1ceea
Show file tree
Hide file tree
Showing 17 changed files with 62 additions and 31 deletions.
2 changes: 1 addition & 1 deletion BrainPortal/lib/boutiques_allowed_exit_codes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def exit_status_means_failure?(status)

# Get the acceptable status codes.
descriptor = self.descriptor_for_save_results
ok_codes = descriptor.custom_module_info('BoutiquesAllowedExitCodes')
ok_codes = descriptor.custom_module_info('BoutiquesAllowedExitCodes') || [ 0 ]

addlog("BoutiquesAllowedExitCodes rev. #{Revision_info.short_commit}, status=#{status}, allowed=#{ok_codes}")

Expand Down
5 changes: 4 additions & 1 deletion BrainPortal/lib/boutiques_collection_basenames_list_maker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ module BoutiquesCollectionBasenamesListMaker
def descriptor_for_form #:nodoc:
descriptor = super.dup()
input_id, type, regex_string, = descriptor.custom_module_info('BoutiquesCollectionBasenamesListMaker')
return descriptor if input_id.nil? # no config at all

# Get the userfile_ids from the params
# Return immediately if there is no exactly one file.
Expand Down Expand Up @@ -81,6 +82,7 @@ def descriptor_for_form #:nodoc:
def final_task_list #:nodoc:
descriptor = self.descriptor_for_final_task_list
input_id, _, _ = descriptor.custom_module_info('BoutiquesCollectionBasenamesListMaker')
return super if input_id.nil? # no config at all

params_values = self.invoke_params[input_id]
return super if params_values.blank? || params_values.size == 1
Expand All @@ -95,4 +97,5 @@ def final_task_list #:nodoc:
end

end
end

end
2 changes: 1 addition & 1 deletion BrainPortal/lib/boutiques_ext3_capturer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def ext3capture_basenames

# Get values in descriptor, as a hash
descriptor = self.descriptor_for_cluster_commands
ext3_specs = descriptor.custom_module_info('BoutiquesExt3Capturer')
ext3_specs = descriptor.custom_module_info('BoutiquesExt3Capturer') || {}

# Append our own entries; note that duplications of basenames
# will mean only the first entry is used!
Expand Down
2 changes: 1 addition & 1 deletion BrainPortal/lib/boutiques_file_name_matcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ module BoutiquesFileNameMatcher

def after_form #:nodoc:
descriptor = self.descriptor_for_after_form
verifs = descriptor.custom_module_info('BoutiquesFileNameMatcher')
verifs = descriptor.custom_module_info('BoutiquesFileNameMatcher') || []

verifs.each do |inputid,regexstring| # 'myinput' => "^sub-[a-zA-Z0-9]*$"
input = descriptor.input_by_id(inputid)
Expand Down
2 changes: 1 addition & 1 deletion BrainPortal/lib/boutiques_file_type_verifier.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ module BoutiquesFileTypeVerifier

def after_form #:nodoc:
descriptor = self.descriptor_for_after_form
verifs = descriptor.custom_module_info('BoutiquesFileTypeVerifier')
verifs = descriptor.custom_module_info('BoutiquesFileTypeVerifier') || {}

verifs.each do |inputid,typenames| # 'myinput' => [ 'TextFile', 'MincFile' ]
input = descriptor.input_by_id(inputid)
Expand Down
24 changes: 23 additions & 1 deletion BrainPortal/lib/boutiques_forced_output_browse_path.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,28 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#

# This module will attempt to force an output file
# created by the boutiques integrator to be stored
# with a "browse_path" under the target destination
# DataProvider, if possible. e.g.
#
# "custom": {
# "cbrain:integrator_modules": {
# "BoutiquesForcedOutputBrowsePath" : {
# "supertool_output_dir": "derivatives/supertool",
# "supertool_html_report": "reports/[VERSION]/supertool",
# },
# }
# }
#
# The keys are IDs of the output-files section of the descriptor,
# and the values are relative paths on the target result DP.
# The relative paths can contain templated values that will be
# substituted when the results are saved.
#
# If the target DP doesn't have browse_path capabilities, the
# browse path will be set to nil and a warning will be added
# to the task's log.
module BoutiquesForcedOutputBrowsePath

# Note: to access the revision info of the module,
Expand Down Expand Up @@ -72,7 +94,7 @@ def name_and_type_for_output_file(output, pathname)
end
name, type = super # the standard names and types; the name will be replaced
descriptor = descriptor_for_save_results
config = descriptor.custom_module_info('BoutiquesForcedOutputBrowsePath')
config = descriptor.custom_module_info('BoutiquesForcedOutputBrowsePath') || {}
browse_path = config[output.id] # "a/b/c"
return [ name, type ] if browse_path.blank? # no configured browse_path for this output
browse_path = apply_value_keys(browse_path) # replaces [XYZ] strings with values from params
Expand Down
2 changes: 1 addition & 1 deletion BrainPortal/lib/boutiques_input_cache_cleaner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def save_results #:nodoc:
# module's config.
def to_clean_userfile_ids #:nodoc:
descriptor = self.descriptor_for_save_results
input_ids = descriptor.custom_module_info('BoutiquesInputCacheCleaner')
input_ids = descriptor.custom_module_info('BoutiquesInputCacheCleaner') || []
input_ids # 'my_input1', 'my_input2'
.map { |inputid| invoke_params[inputid] } # the userfile ID(s) in the params; scalar or array
.flatten # flatten them all
Expand Down
2 changes: 1 addition & 1 deletion BrainPortal/lib/boutiques_input_copier.rb
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def finalize_bosh_invoke_struct(invoke_struct) #:nodoc:
override_invoke_params = super.dup

descriptor = self.descriptor_for_cluster_commands
module_config = descriptor.custom_module_info('BoutiquesInputCopier')
module_config = descriptor.custom_module_info('BoutiquesInputCopier') || {}

# For each input in BoutiquesInputCopier override the input with the copy
# if the checkbox is selected
Expand Down
2 changes: 1 addition & 1 deletion BrainPortal/lib/boutiques_input_regex_checker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def after_form

# Find the configured info
descriptor = self.boutiques_descriptor
checkers = descriptor.custom_module_info('BoutiquesInputRegexChecker') || {} # the raw struct in the decriptor
checkers = descriptor.custom_module_info('BoutiquesInputRegexChecker') || {} # the raw struct in the descriptor

# Run the checks
checkers.each do |input_id,regex_message|
Expand Down
11 changes: 6 additions & 5 deletions BrainPortal/lib/boutiques_input_subdir_maker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ module BoutiquesInputSubdirMaker
# the fake parent directory information
def descriptor_for_form #:nodoc:
descriptor = super.dup
parent_dirname_by_inputid = descriptor.custom_module_info('BoutiquesInputSubdirMaker')
parent_dirname_by_inputid = descriptor.custom_module_info('BoutiquesInputSubdirMaker') || {}

parent_dirname_by_inputid.each do |inputid,subdir_config|
# Adjust the description
Expand All @@ -126,6 +126,10 @@ def descriptor_for_form #:nodoc:
# create a fake parent directory that will contains a symlink
# to the orginal selected Userfile.
def setup #:nodoc:
descriptor = self.descriptor_for_setup
parent_dirname_by_inputid = descriptor.custom_module_info('BoutiquesInputSubdirMaker') || {}
return super if parent_dirname_by_inputid.blank? # no config means nothing to do

original_userfile_ids = {}

# Log revision information
Expand All @@ -134,10 +138,7 @@ def setup #:nodoc:
self.addlog("Creating parent directories in BoutiquesInputSubdirMaker.")
self.addlog("#{basename} rev. #{commit}")

descriptor = self.descriptor_for_setup

# Remove IDs from invoke_params
parent_dirname_by_inputid = descriptor.custom_module_info('BoutiquesInputSubdirMaker')
parent_dirname_by_inputid.each_key do |inputid|
original_userfile_ids[inputid] = invoke_params[inputid]
invoke_params[inputid] = nil
Expand Down Expand Up @@ -187,7 +188,7 @@ def finalize_bosh_invoke_struct(invoke_struct) #:nodoc:
override_invoke_params = super.dup

descriptor = self.descriptor_for_cluster_commands
parent_dirname_by_inputid = descriptor.custom_module_info('BoutiquesInputSubdirMaker')
parent_dirname_by_inputid = descriptor.custom_module_info('BoutiquesInputSubdirMaker') || {}
parent_dirname_by_inputid.each do |inputid,subdir_config|
if override_invoke_params[inputid].blank?
override_invoke_params.delete(inputid)
Expand Down
9 changes: 5 additions & 4 deletions BrainPortal/lib/boutiques_input_value_fixer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#

# This module allows one to fix some of input parameters to specific constand values
# This module allows one to fix some of input parameters to specific constant values
# The fixed input(s) would no longer be shown to the user in the form.
# The optional inputs assigned null value will be removed
# The optional inputs assigned null value will be removed
# (do not use with mandatory input parameters)
#
# In the descriptor, the spec would look like:
Expand Down Expand Up @@ -52,9 +52,9 @@ module BoutiquesInputValueFixer
Revision_info=CbrainFileRevision[__FILE__] #:nodoc:


# the hash of input parameter values to be fixed or, if value is null, to be omited
# the hash of input parameter values to be fixed or, if value is null, to be omitted
def fixed_values
self.boutiques_descriptor.custom_module_info('BoutiquesInputValueFixer')
self.boutiques_descriptor.custom_module_info('BoutiquesInputValueFixer') || {}
end

# deletes fixed inputs listed in the custom 'integrator_modules'
Expand All @@ -63,6 +63,7 @@ def descriptor_without_fixed_inputs(descriptor)
# other will be given fixed values during execution; neither should appear in web form UI

fixed_input_ids = fixed_values.keys
return descriptor if fixed_input_ids.blank? # no config means nothing to do
descriptor_dup = descriptor.dup
fully_removed = fixed_input_ids.select do |i_id| # this variables are flagged to be removed rather than assigned value
# in the spec, so they will be treated slightly different
Expand Down
6 changes: 4 additions & 2 deletions BrainPortal/lib/boutiques_output_cache_cleaner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ module BoutiquesOutputCacheCleaner
# user to disable this module's core function.
def descriptor_with_special_input(descriptor)
descriptor = descriptor.dup
output_ids = descriptor.custom_module_info('BoutiquesOutputCacheCleaner') || []
return descriptor if output_ids.blank? # no config means no changes.

# Add new input
new_input = BoutiquesSupport::Input.new(
Expand Down Expand Up @@ -108,7 +110,7 @@ def after_form #:nodoc:
message = super
return message if params_errors.present? || errors.present?
enabled = self.invoke_params.delete :cbrain_enable_output_cache_cleaner
self.params[:cbrain_enable_output_cache_cleaner] = (enabled.to_s.match? /^(1|true)$/)
self.params[:cbrain_enable_output_cache_cleaner] = (enabled.to_s.match?(/^(1|true)$/))
message
end

Expand All @@ -126,7 +128,7 @@ def save_results #:nodoc:

# Get the list of outputs to clean from the descriptor
descriptor = self.descriptor_for_save_results
output_ids = descriptor.custom_module_info('BoutiquesOutputCacheCleaner')
output_ids = descriptor.custom_module_info('BoutiquesOutputCacheCleaner') || []

# Get the userfile IDs of all outputs.
# The Boutiques integrator create arrays of userfile
Expand Down
2 changes: 1 addition & 1 deletion BrainPortal/lib/boutiques_output_file_type_setter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def name_and_type_for_output_file(output, pathname) #:nodoc:

# Get the suggestion from the descriptor
descriptor = self.descriptor_for_save_results
out_classes = descriptor.custom_module_info('BoutiquesOutputFileTypeSetter')
out_classes = descriptor.custom_module_info('BoutiquesOutputFileTypeSetter') || {}
suggested_class_name = out_classes[output.id]
return [ name, userfile_class ] if suggested_class_name.blank?

Expand Down
9 changes: 5 additions & 4 deletions BrainPortal/lib/boutiques_output_filename_renamer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ module BoutiquesOutputFilenameRenamer
# each configured String input fields.
def descriptor_with_renaming_explanations(descriptor)
descriptor = descriptor.dup
config_map = descriptor.custom_module_info('BoutiquesOutputFilenameRenamer')
config_map = descriptor.custom_module_info('BoutiquesOutputFilenameRenamer') || {}
return descriptor if config_map.blank? # no config means nothing to do

uniq_outnames = {}

Expand Down Expand Up @@ -170,7 +171,7 @@ def descriptor_for_show_params #:nodoc:
def after_form
message = super
descriptor = descriptor_for_after_form
config_map = descriptor.custom_module_info('BoutiquesOutputFilenameRenamer')
config_map = descriptor.custom_module_info('BoutiquesOutputFilenameRenamer') || {}
config_map.each do |_, pair| # pair = [ boutiques ID of input, filename for output ]
_, outnameinputid = *pair
outname_pattern = invoke_params[outnameinputid].presence || ""
Expand All @@ -195,7 +196,7 @@ def after_form
# as the new effective value for the name.
def setup
descriptor = descriptor_for_setup
config_map = descriptor.custom_module_info('BoutiquesOutputFilenameRenamer')
config_map = descriptor.custom_module_info('BoutiquesOutputFilenameRenamer') || {}
config_map.each do |_, pair|
fileinputid, outnameinputid = *pair
input_userfile_id = invoke_params[fileinputid]
Expand All @@ -220,7 +221,7 @@ def setup
def name_and_type_for_output_file(output, pathname)
name, type = super # the standard names and types; the name will be replaced outright
descriptor = descriptor_for_save_results
config_map = descriptor.custom_module_info('BoutiquesOutputFilenameRenamer')
config_map = descriptor.custom_module_info('BoutiquesOutputFilenameRenamer') || {}
config_map.each do |outputid, pair| # boutiques ID of outfile-files entry, pair
next unless outputid == output.id
_, outnameinputid = *pair
Expand Down
3 changes: 2 additions & 1 deletion BrainPortal/lib/boutiques_post_processing_cleaner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ def save_results

# Get the cleaning paths patterns from the descriptor
descriptor = self.descriptor_for_save_results
patterns = descriptor.custom_module_info('BoutiquesPostProcessingCleaner')
patterns = descriptor.custom_module_info('BoutiquesPostProcessingCleaner') || []
return true if patterns.blank? # nothing else to do and super already worked fine

# Prepare the substitution hash
substitutions_by_token = descriptor.build_substitutions_by_tokens_hash(
Expand Down
5 changes: 4 additions & 1 deletion BrainPortal/lib/boutiques_save_std_out_std_err.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ module BoutiquesSaveStdOutStdErr
def save_results
# Get the folder where to save the log files from the descriptor
descriptor = self.descriptor_for_save_results
module_info = descriptor.custom_module_info('BoutiquesSaveStdOutStdErr')
module_info = descriptor.custom_module_info('BoutiquesSaveStdOutStdErr') || {}
return super if module_info.blank? # nothing special to do

# Get parent file to set stderr and stdout as children of first input file
main_input_id = descriptor.file_inputs.first.id
Expand Down Expand Up @@ -81,6 +82,8 @@ def save_results
# for the show page of the task.
def descriptor_for_show_params #:nodoc:
descriptor = super.dup
module_info = descriptor.custom_module_info('BoutiquesSaveStdOutStdErr') || {}
return descriptor if module_info.blank? # nothing special to do

stdout_file = BoutiquesSupport::OutputFile.new({
"id" => "cbrain_stdout",
Expand Down
5 changes: 1 addition & 4 deletions BrainPortal/lib/boutiques_task_logs_copier.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def save_results

# Get the cleaning paths patterns from the descriptor
descriptor = self.descriptor_for_save_results
destpaths = descriptor.custom_module_info('BoutiquesTaskLogsCopier')
destpaths = descriptor.custom_module_info('BoutiquesTaskLogsCopier') || {}

# Copy STDOUT and STDERR, if possible
install_std_log_file(science_stdout_basename, destpaths[:stdout], "stdout")
Expand Down Expand Up @@ -189,6 +189,3 @@ def install_std_log_file(stdlogfile, destpath, typeinfo)

end




0 comments on commit 4a1ceea

Please sign in to comment.