def processArguments(self, superpipeline, args, gkno): # Get the name of the top level pipeline. pipeline = superpipeline.pipeline # Get the names of all the contained pipelines. containedPipelines = superpipeline.tiersByPipeline.keys() # Get a list of all the allowable long and short form arguments. In this first pass, any arguments # being pulled from a contained pipeline are stored. containedPipelineArguments = [] longFormArguments = {} shortFormArguments = {} for argument in args.arguments.keys(): # Check if the argument name is prefixed with the name of a task, following by a '.'. If so, this # argument is pulled in from a contained pipeline. if '.' in argument: prefix = argument.split('.')[0] if prefix in containedPipelines: containedPipelineArguments.append(argument) # Handle defined arguments in the configuration file. else: longFormArguments[argument] = argument shortFormArguments[args.arguments[argument].shortFormArgument] = argument # Loop over the contained pipeline arguments. for argument in containedPipelineArguments: longFormArgument = args.arguments[argument].longFormArgument shortFormArgument = args.arguments[argument].shortFormArgument if longFormArgument not in longFormArguments and shortFormArgument not in shortFormArguments: longFormArguments[argument.split('.')[1]] = argument shortFormArguments[args.arguments[argument].shortFormArgument] = argument # Loop over all of the supplied command line arguments, ensure that they are in their long form # versions and consolidate. Check that all of the arguments are valid for the pipeline being run # or are gkno specific arguments. for argument in self.arguments: values = self.arguments[argument] pipelineShortFormArguments = superpipeline.pipelineConfigurationData[pipeline].shortFormArguments # First check if the argument is the name of a task in the superpipeline. if argument.strip('-') in superpipeline.tasks: if argument.strip('-') in self.tasksAsArguments: for value in values: self.tasksAsArguments[argument.strip('-')].append(value) else: self.tasksAsArguments[argument.strip('-')] = values # If this is a long form argument, check to see if it is a gkno specific argument or a valid pipeline # argument. elif argument in gkno.arguments: shortFormArgument = gkno.arguments[argument].shortFormArgument dataType = gkno.arguments[argument].dataType if argument not in self.gknoArguments: self.gknoArguments[argument] = [] for value in values: if not dataConsistency.isCorrectDataType(value, dataType): self.errors.invalidValue(argument, shortFormArgument, value, dataType, True) self.gknoArguments[argument].append(value) # Check if this is a valid gkno short form argument. elif argument in gkno.shortForms: longFormArgument = gkno.shortForms[argument] dataType = gkno.arguments[longFormArgument].dataType if longFormArgument not in self.gknoArguments: self.gknoArguments[longFormArgument] = [] for value in values: if not dataConsistency.isCorrectDataType(value, dataType): self.errors.invalidValue(longFormArgument, argument, value, dataType, True) self.gknoArguments[longFormArgument].append(value) # Check if this argument is valid for the pipeline. elif argument in longFormArguments: argumentName = longFormArguments[argument] shortFormArgument = args.arguments[argumentName].shortFormArgument dataType = args.arguments[argumentName].dataType if argumentName not in self.pipelineArguments: self.pipelineArguments[argumentName] = [] # If the data type is flag, there are no values, so include 'set' as the value. if dataType == 'flag': self.pipelineArguments[argumentName] = ['set'] # Handle non-flags. else: for value in values: if not dataConsistency.isCorrectDataType(value, dataType): self.errors.invalidValue(argumentName, shortFormArgument, value, dataType, False) self.pipelineArguments[argumentName].append(value) # Check if this is a valid short form pipeline argument. elif argument in shortFormArguments: longFormArgument = shortFormArguments[argument] dataType = args.arguments[longFormArgument].dataType if longFormArgument not in self.pipelineArguments: self.pipelineArguments[longFormArgument] = [] if dataType == 'flag': self.pipelineArguments[longFormArgument] = ['set'] else: for value in values: if not dataConsistency.isCorrectDataType(value, dataType): self.errors.invalidValue(longFormArgument, argument, value, dataType, False) self.pipelineArguments[longFormArgument].append(value) # If the argument is invalid. else: self.errors.invalidArgument(argument)
def processArguments(self, superpipeline, args, gkno): # Get the name of the top level pipeline. pipeline = superpipeline.pipeline # Get a list of all the allowable long and short form arguments. longFormArguments = [] shortFormArguments = {} for argument in args.arguments.keys(): longFormArguments.append(argument) shortFormArguments[args.arguments[argument].shortFormArgument] = argument # Loop over all of the supplied command line arguments, ensure that they are in their long form # versions and consolidate. Check that all of the arguments are valid for the pipeline being run # or are gkno specific arguments. for argument in self.arguments: values = self.arguments[argument] pipelineShortFormArguments = superpipeline.pipelineConfigurationData[pipeline].shortFormArguments # First check if the argument is the name of a task in the superpipeline. if argument.strip('-') in superpipeline.tasks: if argument.strip('-') in self.tasksAsArguments: for value in values: self.tasksAsArguments[argument.strip('-')].append(value) else: self.tasksAsArguments[argument.strip('-')] = values # If this is a long form argument, check to see if it is a gkno specific argument or a valid pipeline # argument. elif argument in gkno.arguments: shortFormArgument = gkno.arguments[argument].shortFormArgument dataType = gkno.arguments[argument].dataType if argument not in self.gknoArguments: self.gknoArguments[argument] = [] for value in values: if not dataConsistency.isCorrectDataType(value, dataType): self.errors.invalidValue(argument, shortFormArgument, value, dataType, True) self.gknoArguments[argument].append(value) # Check if this is a valid gkno short form argument. elif argument in gkno.shortForms: longFormArgument = gkno.shortForms[argument] dataType = gkno.arguments[longFormArgument].dataType if longFormArgument not in self.gknoArguments: self.gknoArguments[longFormArgument] = [] for value in values: if not dataConsistency.isCorrectDataType(value, dataType): self.errors.invalidValue(longFormArgument, argument, value, dataType, True) self.gknoArguments[longFormArgument].append(value) # Check if this argument is valid for the pipeline. elif argument in longFormArguments: shortFormArgument = args.arguments[argument].shortFormArgument dataType = args.arguments[argument].dataType if argument not in self.pipelineArguments: self.pipelineArguments[argument] = [] # If the data type is flag, there are no values, so include 'set' as the value. if dataType == 'flag': self.pipelineArguments[argument] = ['set'] # Handle non-flags. else: for value in values: if not dataConsistency.isCorrectDataType(value, dataType): self.errors.invalidValue(argument, shortFormArgument, value, dataType, False) self.pipelineArguments[argument].append(value) # Check if this is a valid short form pipeline argument. elif argument in shortFormArguments: longFormArgument = shortFormArguments[argument] dataType = args.arguments[longFormArgument].dataType if longFormArgument not in self.pipelineArguments: self.pipelineArguments[longFormArgument] = [] if dataType == 'flag': self.pipelineArguments[longFormArgument] = ['set'] else: for value in values: if not dataConsistency.isCorrectDataType(value, dataType): self.errors.invalidValue(longFormArgument, argument, value, dataType, False) self.pipelineArguments[longFormArgument].append(value) # If the argument is invalid. else: self.errors.invalidArgument(argument)