Ejemplo n.º 1
0
    def validateSchema(self, schema):
        """
        _validateSchema_

        Check for required fields, and some skim facts
        """
        DataProcessing.validateSchema(self, schema)
        mainOutputModules = list(self.validateConfigCacheExists(configID=schema["ConfigCacheID"],
                                                           configCacheUrl=schema['ConfigCacheUrl'],
                                                           couchDBName=schema["CouchDBName"],
                                                           getOutputModules=True))

        # Skim facts have to be validated outside the usual master validation
        skimSchema = {k: v for (k, v) in viewitems(schema) if k.startswith("Skim")}
        skimArguments = self.getSkimArguments()
        skimIndex = 1
        skimInputs = set()
        while "SkimName%s" % skimIndex in schema:
            instanceArguments = {}
            for argument in skimArguments:
                realArg = argument.replace("#N", str(skimIndex))
                instanceArguments[realArg] = skimArguments[argument]
            try:
                validateArgumentsCreate(skimSchema, instanceArguments)
                # Validate GPU-related spec parameters
                DataProcessing.validateGPUSettings(schema)
            except Exception as ex:
                self.raiseValidationException(str(ex))

            self.validateConfigCacheExists(configID=schema["Skim%sConfigCacheID" % skimIndex],
                                           configCacheUrl=schema['ConfigCacheUrl'],
                                           couchDBName=schema["CouchDBName"],
                                           getOutputModules=False)
            if schema["SkimInput%s" % skimIndex] not in mainOutputModules:
                error = "Processing config does not have the following output module: %s." % schema[
                    "SkimInput%s" % skimIndex]
                self.raiseValidationException(msg=error)
            skimInputs.add(schema["SkimInput%s" % skimIndex])
            skimIndex += 1

        # Validate that the transient output modules are used in a skim task
        if "TransientOutputModules" in schema:
            diffSet = set(schema["TransientOutputModules"]) - skimInputs
            if diffSet:
                self.raiseValidationException(
                    msg="A transient output module was specified but no skim was defined for it")