def RunWorkflowJob(self, job, stages, files): stage_levels = {} executed_stages = {} #create job stages for i, s in enumerate(stages): stage = Stages.GetStage(self.user, s["StageID"]) if not stage_levels.get(stage.StageLevel): stage_levels[stage.StageLevel] = [] stage_obj = { "stage": stage, "parameters": s["Parameters"] } stage_levels[stage.StageLevel].append(stage_obj) for stages in sorted(stage_levels): for s in stage_levels[stages]: stage = s["stage"] parameters = s["parameters"] jobstage = self.RunToolJob(job, parameters, files.get("stage_%d" % stage.StageID, []), stage, i) executed_stages[stage.StageID] = jobstage.JobStageID for dep in jobstage.Stage.StageDependencies.all(): JobStageDependency.objects.create( JobStageOI=jobstage, DependantOn_id=executed_stages[dep.DependantOn.StageID], Condition_id=dep.Condition.ConditionID, ExitCodeValue=dep.ExitCodeValue )
def DeleteStageDependency(self, dependency_id): with transaction.atomic(): dep = StageDependencies.GetStageDependency(self.user, dependency_id) StageDependencies.DeleteStageDependency(self.user, dep) Stages.UpdateStageLevel(dep.StageOI) return self.GetStages(dep.StageOI.WorkflowVersion.Workflow.WorkflowID, "dev")
def AddStage(self, workflow_id, stage): workflow = self.GetWorkflow(workflow_id) version = self.GetWorkflowVersion(workflow, "dev") tool = self.GetTool(stage["ID"]) tool_version = self.GetToolVersion(tool, stage["VersionNum"]) return Stages.AddStage(self.user, version, tool_version, None, False, stage["Left"], stage["Top"])
def AddStageDependency(self, stage_id, dependency): with transaction.atomic(): stage = self.GetStage(stage_id) stage_dependency = StageDependencies.AddStageDependency(self.user, stage, dependency['DependantOn'], dependency['Condition'], dependency['ExitCodeValue']) Stages.UpdateStageLevel(stage) return stage_dependency
def UpdateStage(self, stage_id, stage_details): with transaction.atomic(): stage = self.GetStage(stage_id) tool = stage.ToolVersion.Tool version = self.GetToolVersion(tool, stage_details["VersionNum"]) stage = Stages.UpdateStage(self.user, stage, version, None, stage_details["Checkpoint"]) StageParameters.UpdateStageParameters(self.user, stage, stage_details["StageParameters"]) return stage
def DeleteStage(self, stage_id): stage = self.GetStage(stage_id) Stages.DeleteStage(self.user, stage)
def MoveStage(self, stage_id, stage_pos): stage = self.GetStage(stage_id) return Stages.MoveStage(self.user, stage, stage_pos['Left'], stage_pos['Top'])
def GetStage(self, stage_id): return Stages.GetStage(self.user, stage_id)
def GetStages(self, workflow_id, version_num): workflow = self.GetWorkflow(workflow_id) version = self.GetWorkflowVersion(workflow, version_num) return Stages.GetStages(version)