Exemple #1
0
    def convertJobObj(self, key, courselab, jobObj):
        """ convertJobObj - Converts a dictionary into a TangoJob object
        """

        name = jobObj['jobName']
        limitingKey = jobObj['limitingKey']
        dirPath = self.getDirPath(key, courselab)
        outputFile = self.getOutFilePath(key, courselab, jobObj['output_file'])

        timeout = jobObj['timeout']
        notifyURL = None
        maxOutputFileSize = Config.MAX_OUTPUT_FILE_SIZE
        if 'callback_url' in jobObj:
            notifyURL = jobObj['callback_url']

        # List of input files
        input = []
        for file in jobObj['files']:
            inFile = file['localFile']
            vmFile = file['destFile']
            handinfile = InputFile(
                localFile="%s/%s" % (dirPath, inFile),
                destFile=vmFile)
            input.append(handinfile)

        # VM object
        if "vm" in jobObj:
            vm = self.createTangoMachine(jobObj["image"], vmObj=jobObj["vm"])
        else:
            vm = self.createTangoMachine(jobObj["image"])

        # for backward compatibility
        accessKeyId = None
        accessKey = None
        if "accessKey" in jobObj and len(jobObj["accessKey"]) > 0:
            accessKeyId = jobObj["accessKeyId"]
            accessKey = jobObj["accessKey"]

        job = TangoJob(
            name=name,
            limitingKey=limitingKey,
            vm=vm,
            outputFile=outputFile,
            input=input,
            timeout=timeout,
            notifyURL=notifyURL,
            maxOutputFileSize=maxOutputFileSize,
            accessKey=accessKey,
            accessKeyId=accessKeyId
        )

        self.log.debug("inputFiles: %s" % [file.localFile for file in input])
        self.log.debug("outputFile: %s" % outputFile)
        return job
Exemple #2
0
    def convertJobObj(self, dirName, jobObj):
        """convertJobObj - Converts a dictionary into a TangoJob object"""

        name = jobObj["jobName"]
        outputFile = "%s/%s/%s/%s" % (
            self.COURSELABS,
            dirName,
            self.OUTPUT_FOLDER,
            jobObj["output_file"],
        )
        timeout = jobObj["timeout"]
        notifyURL = None
        maxOutputFileSize = Config.MAX_OUTPUT_FILE_SIZE
        if "callback_url" in jobObj:
            notifyURL = jobObj["callback_url"]

        # List of input files
        input = []
        for file in jobObj["files"]:
            inFile = file["localFile"]
            vmFile = file["destFile"]
            handinfile = InputFile(
                localFile="%s/%s/%s" % (self.COURSELABS, dirName, inFile),
                destFile=vmFile,
            )
            input.append(handinfile)

        # VM object
        vm = self.createTangoMachine(jobObj["image"])

        # for backward compatibility
        accessKeyId = None
        accessKey = None
        if "accessKey" in jobObj and len(jobObj["accessKey"]) > 0:
            accessKeyId = jobObj["accessKeyId"]
            accessKey = jobObj["accessKey"]

        job = TangoJob(
            name=name,
            vm=vm,
            outputFile=outputFile,
            input=input,
            timeout=timeout,
            notifyURL=notifyURL,
            maxOutputFileSize=maxOutputFileSize,
            accessKey=accessKey,
            accessKeyId=accessKeyId,
        )

        self.log.debug("inputFiles: %s" % [file.localFile for file in input])
        self.log.debug("outputFile: %s" % outputFile)
        return job
Exemple #3
0
    def convertJobObj(self, dirName, jobObj):
        """ convertJobObj - Converts a dictionary into a TangoJob object
        """

        name = jobObj['jobName']
        outputFile = "%s/%s/%s/%s" % (self.COURSELABS, dirName,
                                      self.OUTPUT_FOLDER,
                                      jobObj['output_file'])
        timeout = jobObj['timeout']
        notifyURL = None
        maxOutputFileSize = Config.MAX_OUTPUT_FILE_SIZE
        if 'callback_url' in jobObj:
            notifyURL = jobObj['callback_url']

        # List of input files
        input = []
        for file in jobObj['files']:
            inFile = file['localFile']
            vmFile = file['destFile']
            handinfile = InputFile(localFile="%s/%s/%s" %
                                   (self.COURSELABS, dirName, inFile),
                                   destFile=vmFile)
            input.append(handinfile)

        # VM object
        vm = self.createTangoMachine(jobObj["image"])

        # for backward compatibility
        accessKeyId = None
        accessKey = None
        if "accessKey" in jobObj and len(jobObj["accessKey"]) > 0:
            accessKeyId = jobObj["accessKeyId"]
            accessKey = jobObj["accessKey"]

        # argument of job from rest request
        arg = jobObj.get('arg', None)

        job = TangoJob(name=name,
                       vm=vm,
                       outputFile=outputFile,
                       input=input,
                       timeout=timeout,
                       notifyURL=notifyURL,
                       maxOutputFileSize=maxOutputFileSize,
                       accessKey=accessKey,
                       accessKeyId=accessKeyId,
                       arg=arg)

        self.log.debug("inputFiles: %s" % [file.localFile for file in input])
        self.log.debug("outputFile: %s" % outputFile)
        return job
Exemple #4
0
    def convertJobObj(self, dirName, jobObj):
        """ convertJobObj - Converts a dictionary into a TangoJob object
        """

        name = jobObj['jobName']
        outputFile = "%s/%s/%s/%s" % (self.COURSELABS,
                                      dirName,
                                      self.OUTPUT_FOLDER,
                                      jobObj['output_file'])
        timeout = jobObj['timeout']
        notifyURL = None
        maxOutputFileSize = Config.MAX_OUTPUT_FILE_SIZE
        if 'callback_url' in jobObj:
            notifyURL = jobObj['callback_url']

        # List of input files
        input = []
        for file in jobObj['files']:
            inFile = file['localFile']
            vmFile = file['destFile']
            handinfile = InputFile(
                localFile="%s/%s/%s" % (self.COURSELABS, dirName, inFile),
                destFile=vmFile)
            input.append(handinfile)

        # VM object
        vm = self.createTangoMachine(jobObj["image"])

        job = TangoJob(
            name=name,
            vm=vm,
            outputFile=outputFile,
            input=input,
            timeout=timeout,
            notifyURL=notifyURL,
            maxOutputFileSize=maxOutputFileSize)

        self.log.debug("inputFiles: %s" % [file.localFile for file in input])
        self.log.debug("outputFile: %s" % outputFile)
        return job