def setUp(self): demo_user = m.User.objects.get(name='demo') workflow = mommy.make('Workflow', user=demo_user) self.job = mommy.make('Job', workflow=workflow, order=0) self.td = mommy.make('ToolDesc', name='my-tool') self.tool = mommy.make('Tool', desc=self.td, path='tool.sh') combined_with_equals = ParameterSwitchUse.objects.get( display_text='combined with equals') value_only = ParameterSwitchUse.objects.get(display_text='valueOnly') mommy.make('ToolParameter', tool=self.td, switch="-arg1", switch_use=combined_with_equals, rank=2) mommy.make('ToolParameter', tool=self.td, switch="-arg2", switch_use=value_only, rank=1) mommy.make('ToolParameter', tool=self.td, switch="-arg3", switch_use=value_only, file_assignment='batch') self.template = CommandTemplate() self.job_1_dict = { "jobId": 1, "toolName": "my-tool", "toolId": self.tool.id, "parameterList": { "parameter": [] } }
def __init__(self, *args, **kwargs): ret = Job.__init__(self, *args, **kwargs) if self.command_template: try: self.template = CommandTemplate() self.template.deserialise(self.command_template) except ValueError: logger.warning( "Unable to deserialise command_template on engine job id: %s" % self.id) else: self.template = None return ret
def add_job(self, job_dict): assert (job_dict) assert (job_dict["toolName"]) logger.debug(job_dict["toolName"]) template = CommandTemplate() template.setup(self, job_dict) template.parse_parameter_description() self.job_dict = job_dict if "toolId" not in job_dict: raise InvalidRequestError("Submitted job %s lacks toolId" % job_dict["toolName"]) self.tool = Tool.objects.get(id=job_dict["toolId"]) if not self.tool.enabled: raise InvalidRequestError( "Can't process workflow with disabled tool '%s'" % self.tool.name) if not self.tool.does_user_have_access_to(self.user): raise InvalidRequestError( "Can't process workflow with inaccessible tool '%s'" % self.tool.name) # lets work out the highest copy level supported by this tool and store it in job. This makes no account for the backends capabilities. # that will be resolved later when the stagein is created during the walk self.preferred_stagein_method = 'link' if self.tool.link_supported else 'lcopy' if self.tool.lcopy_supported else 'copy' self.preferred_stageout_method = 'lcopy' if self.tool.lcopy_supported else 'copy' # stageouts should never be linked. Only local copy or remote copy # cache job for later reference self.command_template = template.serialise() self.command = str(template) # text description of command self.status = const.STATUS_PENDING self.stageout = "%s%s/" % ( self.workflow.stageout, "%d - %s" % (self.order + 1, self.tool.get_display_name())) self.exec_backend = self.get_backend_uri(self.exec_credential) self.fs_backend = self.get_backend_uri(self.fs_credential) self.cpus = self.tool.cpus self.walltime = self.tool.walltime self.module = self.tool.module self.queue = self.tool.queue self.max_memory = self.tool.max_memory self.job_type = self.tool.job_type self.save()