Beispiel #1
0
 def RevertToolVersion(self, tool_id, version_num):
     tool = self.GetTool(tool_id)
         
     with transaction.atomic():
         dev = ToolVersions.GetDevelopmentVersion(tool)
         ver = ToolVersions.GetToolVersion(tool, version_num)
         
         #set development version details to old details
         dev.ShortDescription = ver.ShortDescription
         dev.LongDescription = ver.LongDescription
         dev.save()
         
         #delete development parameters and replace with old parameters
         Parameters.DeleteParameters(self.user, dev)
         Parameters.CopyParameters(self.user, ver, dev)
         
         #delete development outputs and replace with old outputs
         ExpectedOutputs.DeleteOutputs(self.user, dev)
         ExpectedOutputs.CopyOutputs(self.user, ver, dev)
         
         #delete development outputs and replace with old outputs
         Resources.DeleteResources(self.user, dev)
         Resources.CopyResources(self.user, ver, dev)
         
         #delete development scripts and files and replace with old
         dev_dir = os.path.join(self.base_dir, "tools/%s/dev" % str(tool_id))
         ver_dir = os.path.join(self.base_dir, "tools/%s/%s" % (str(tool_id),
             ver.ToolVersionNum))
         
         shutil.rmtree(dev_dir)
         Directory.copy_directory(ver_dir, dev_dir, 0755)
     
     return dev
Beispiel #2
0
 def PublishTool(self, tool_id, version_nums):
     tool = self.GetTool(tool_id)
     
     version_num = "%s.%s.%s" % (version_nums['Major'],version_nums['Minor'],
         version_nums['Patch'])
         
     with transaction.atomic():
         #copy the development tool version
         dev = ToolVersions.GetDevelopmentVersion(tool)
         new = ToolVersions.PublishToolVersion(self.user, dev, version_num)
         
         #copy dev scripts and files to new version
         dev_dir = os.path.join(self.base_dir, "tools/%s/dev" % str(tool_id))
         new_dir = os.path.join(self.base_dir, "tools/%s/%s" % (str(tool_id),
             new.ToolVersionNum))
         Directory.copy_directory(dev_dir, new_dir, 0755)
         
         #copy parameters
         Parameters.CopyParameters(self.user, dev, new)
         
         #copy outputs
         ExpectedOutputs.CopyOutputs(self.user, dev, new)
         
         #copy default resources
         Resources.CopyResources(self.user, dev, new)
     
     return new
Beispiel #3
0
 def UpdateTool(self, tool_id, version):
     tool = self.GetTool(tool_id)
     with transaction.atomic():
         #update tool details
         tool_details = version["Tool"]
         tool = Tools.UpdateTool(self.user, tool, 
             ToolName=tool_details["ToolName"], 
             CategoryID=tool_details["CategoryID"],
             ToolDescription=version["ShortDescription"]
         )
         
         #update version details
         tool_version = self.GetToolVersion(tool, "dev")
         tool_version = ToolVersions.UpdateToolVersion(self.user,
             tool_version, version["ShortDescription"], 
             version["LongDescription"], version["Command"]
         )
         
         #update parameters
         for i, p in enumerate(version["Parameters"]):
             parameter = self.UpdateParameter(p, i)
         
         #update/add expected outputs
         for o in version["ExpectedOutputs"]:
             if o["ExpectedOutputID"]:
                 self.UpdateExpectedOutput(o)
             else:
                 self.AddExpectedOutput(tool, o)
         
         #update/add default resources
         Resources.UpdateResources(self.user, tool_version, 
             settings.JMS_SETTINGS["resource_manager"]["name"],
             version["Resources"]
         )
         
     return tool
Beispiel #4
0
                     #if the ${VALUE} variable is not located in the string, append the value to the end
                     #File.print_to_file("/tmp/file.txt", str(e) + ": " + p)
                     p += " %s" % val                
                 
                 params += ' %s' % p
             
             elif param.ParameterType.ParameterTypeID == 3:
                 params += ' %s' % p
         
     command += params
     
     jobstage.Commands = command
     
     #Get resources for tool version
     #TODO: user customized resources
     resources = Resources.GetResources(self.user, version, module_name)
     for resource in resources:
         #move to data layer
         jsr = JobStageResource.objects.create(ResourceManager=module_name, 
             JobStage=jobstage, Key=resource.Key, Value=resource.Value,
             Label=resource.Label)
     
     jobstage.save()
     
 job_script = self.SetupJobDirectory(jobstage, files, stage_index)
 
 r = ResourceManager(self.user)
 cluster_id = r.ExecuteJobScript(job_script)
 with open("/tmp/job_id.txt", 'w') as f:
     print >> f, job_script
     print >> f, cluster_id