def checkParameterSets(self, data, allowTermination, name, isTool): success = True # Define the allowed attributes. allowedAttributes = {} allowedAttributes['id'] = (str, True, True, 'id') allowedAttributes['description'] = (str, True, True, 'description') allowedAttributes['data'] = (list, True, False, None) # Define the allowed attributes in the data section of the parameter set. allowedDataAttributes = {} allowedDataAttributes['id'] = (str, True, True, 'id') allowedDataAttributes['values'] = (list, True, True, 'values') # The parameter set definitions differ slightly between tools and pipelines. For tools, the argument is # provided as the means of identifying the node for which the supplied values apply. For pipelines, it is # the node within the pipeline that is supplied. if isTool: allowedDataAttributes['argument'] = (str, True, True, 'argument') else: allowedDataAttributes['node'] = (str, True, True, 'nodeId') # Loop over all of the defined parameter sets. for parameterSet in data: # Check that the supplied structure is a dictionary. if not methods.checkIsDictionary(parameterSet, allowTermination): return False # Check that the node has a valid ID. This is required for help messages. id = methods.checkForId(parameterSet, name, 'parameter sets', allowTermination, isTool) if not id: return False # Define a set of information to be used in help messages. helpInfo = (name, 'parameter sets', id) # Define a structure to hold the data. attributes = parameterSetData() # Check the attributes. success, attributes = methods.checkAttributes(parameterSet, allowedAttributes, attributes, allowTermination, helpInfo) # Loop over all of the data supplied with the parameter set and check the validity. for dataSet in parameterSet['data']: # Check that the supplied structure is a dictionary. if not methods.checkIsDictionary(dataSet, allowTermination): return False # Define a structure to hold the information for each argument. dataAttributes = parameterSetArguments() # Check the attributes. success, dataAttributes = methods.checkAttributes(dataSet, allowedDataAttributes, dataAttributes, allowTermination, helpInfo) # Append this argument to the main parameter set attributes. attributes.data.append(dataAttributes) # Store the parameter set data. #TODO RROR if attributes.id in self.sets: print('parameterSets.checkParameterSets - REPEAT', attributes.id); exit(0) self.sets[attributes.id] = attributes return success
def checkUniqueNodes(self, data): # If there is not information on unique graph nodes, return. if 'unique graph nodes' not in data: return # Define the allowed nodes attributes. allowedAttributes = {} allowedAttributes['delete files'] = (bool, False, True, 'isDelete') allowedAttributes['evaluate command'] = (dict, False, True, 'evaluateCommand') allowedAttributes['id'] = (str, True, True, 'id') allowedAttributes['omit from reduced plot'] = (bool, False, True, 'omitFromReducedPlot') allowedAttributes['node id'] = (str, False, True, 'nodeId') allowedAttributes['task'] = (str, True, True, 'task') allowedAttributes['task argument'] = (str, False, True, 'taskArgument') # Loop over all of the defined nodes. for uniqueNode in data['unique graph nodes']: # Check that the supplied structure is a dictionary. if not methods.checkIsDictionary(uniqueNode, self.allowTermination): return # Check that the node has a valid ID. This is required for help messages. id = methods.checkForId(uniqueNode, self.name, 'unique graph nodes', self.allowTermination, isTool = False) if not id: return # Define a set of information to be used in help messages. helpInfo = (self.name, 'unique graph nodes', id) # Define the attributes object. attributes = uniqueGraphNodes() # Check the attributes conform to expectations. self.success, attributes = methods.checkAttributes(uniqueNode, allowedAttributes, attributes, self.allowTermination, helpInfo) # If the nodeId already exists in the attributes, a node of this name has already been seen. All #nodes must have a unique name. if attributes.id in self.uniqueNodeAttributes: self.errors.repeatedNodeId(helpInfo) # Also check that the node id is not the name of a task. if attributes.id in self.allTasks: self.errors.nodeIdIsTaskId('unique', helpInfo) # Store the attributes. self.uniqueNodeAttributes[attributes.id] = attributes