public File(String name, Type type, Format format, Bioformat bioformat, String path, String description, FileStatus status, long size, int release) { this(name, type, format, bioformat, null, path, null, TimeUtils.getTime(), TimeUtils.getTime(), description, status, false, size, null, new Experiment(), Collections.emptyList(), new Job(), Collections.emptyList(), new FileIndex(), release, Collections.emptyList(), Collections.emptyMap(), Collections.emptyMap()); }
@Deprecated public QueryResult<Job> create(long studyId, String name, String toolName, String description, String executor, Map<String, String> params, String commandLine, URI tmpOutDirUri, long outDirId, List<File> inputFiles, List<File> outputFiles, Map<String, Object> attributes, Map<String, Object> resourceManagerAttributes, Job.JobStatus status, long startTime, long endTime, QueryOptions options, String sessionId) throws CatalogException { Job job = new Job(-1, null, name, "", toolName, null, "", description, startTime, endTime, executor, "", commandLine, false, status, -1, new File().setUid(outDirId), inputFiles, outputFiles, Collections.emptyList(), params, -1, attributes, resourceManagerAttributes); return create(String.valueOf(studyId), job, options, sessionId); }
public File(Type type, Format format, Bioformat bioformat, String path, String description, FileStatus status, long size, List<Sample> samples, long jobId, Software software, Map<String, Object> stats, Map<String, Object> attributes) { this("", type, format, bioformat, null, path, null, TimeUtils.getTime(), TimeUtils.getTime(), description, status, false, size, software, new Experiment(), samples, new Job().setUid(jobId), Collections.emptyList(), new FileIndex(), -1, Collections.emptyList(), stats, attributes); }
public QueryResult<Job> queue(String studyStr, String jobName, String description, String executable, Job.Type type, Map<String, String> params, List<File> input, List<File> output, File outDir, Map<String, Object> attributes, String token) throws CatalogException { Job job = new Job(jobName, null, executable, type, input, output, outDir, params, -1) .setDescription(description) .setToolId("variant_index") .setAttributes(attributes); return create(studyStr, job, QueryOptions.empty(), token); }
public QueryResult<Job> create(String studyStr, String jobName, String description, String toolId, String execution, String outDir, Map<String, String> params, String sessionId) throws CatalogException { ParamUtils.checkObj(toolId, "toolId"); if (StringUtils.isEmpty(jobName)) { jobName = toolId + "_" + TimeUtils.getTime(); } ObjectMap attributes = new ObjectMap(); attributes.putIfNotNull(Job.OPENCGA_OUTPUT_DIR, outDir); attributes.putIfNotNull(Job.OPENCGA_STUDY, studyStr); Job job = new Job(jobName, toolId, execution, Job.Type.ANALYSIS, description, params, attributes); return create(studyStr, job, QueryOptions.empty(), sessionId); }
if (simulate) { //Simulate a job. Do not create it. jobQueryResult = new QueryResult<>("simulatedJob", (int) (System.currentTimeMillis() - start), 1, 1, "", "", Collections.singletonList( new Job(jobName, catalogManager.getUserManager().getUserId(sessionId), toolName, description, commandLine, outDir, inputFiles, 1))); } else {
File.Bioformat.NONE, dir.toUri(), destinyPath, null, TimeUtils.getTime(), TimeUtils.getTime(), description, new File.FileStatus(File.FileStatus.READY), true, 0, null, new Experiment(), Collections.emptyList(), new Job(), Collections.emptyList(), null, catalogManager.getStudyManager().getCurrentRelease(study, userId), Collections.emptyList(), Collections.emptyMap(), Collections.emptyMap());
File.Bioformat.NONE, filePath.toUri(), destinyPath, null, TimeUtils.getTime(), TimeUtils.getTime(), description, new File.FileStatus(File.FileStatus.READY), true, size, null, new Experiment(), Collections.emptyList(), new Job(), Collections.emptyList(), null, catalogManager.getStudyManager().getCurrentRelease(study, userId), Collections.emptyList(), Collections.emptyMap(), Collections.emptyMap());
new Experiment(), Collections.emptyList(), new Job(), Collections.emptyList(), null, catalogManager.getStudyManager().getCurrentRelease(study, userId), Collections.emptyList(), null, null); folder.setUuid(UUIDUtils.generateOpenCGAUUID(UUIDUtils.Entity.FILE));
@Test public void createJobTest() throws CatalogDBException { Job job = new Job() .setStatus(new Job.JobStatus()); long studyId = user3.getProjects().get(0).getStudies().get(0).getUid(); job.setId("jobName1"); System.out.println(catalogJobDBAdaptor.insert(job, studyId, null)); // long analysisId = catalogDBAdaptor.getAnalysisId(studyId, "analysis1Alias"); job.setId("jobName2"); System.out.println(catalogJobDBAdaptor.insert(job, studyId, null)); try { catalogJobDBAdaptor.insert(job, -1, null); fail("error: expected exception"); } catch (CatalogDBException e) { System.out.println("correct exception: " + e); } }
@Test public void getJobTest() throws CatalogException { long studyId = user3.getProjects().get(0).getStudies().get(0).getUid(); Job job = catalogJobDBAdaptor.insert(new Job("name", user3.getId(), "", "", "", new File().setUid(4), Collections.emptyList(), 1), studyId, null).first(); long jobId = job.getUid(); job = catalogJobDBAdaptor.get(jobId, null).first(); System.out.println(job); try { catalogJobDBAdaptor.get(-1, null); fail("error: expected exception"); } catch (CatalogDBException e) { System.out.println("correct exception: " + e); } }
File.Bioformat.NONE, normalizedUri, externalPathDestinyStr, checksum, TimeUtils.getTime(), TimeUtils.getTime(), description, new File.FileStatus(File.FileStatus.READY), true, size, null, new Experiment(), Collections.emptyList(), new Job(), Collections.emptyList(), null, catalogManager.getStudyManager().getCurrentRelease(study, userId), Collections.emptyList(), Collections.emptyMap(), Collections.emptyMap());
@Test public void deleteJobTest() throws CatalogException { long studyId = user3.getProjects().get(0).getStudies().get(0).getUid(); Job job = catalogJobDBAdaptor.insert(new Job("name", user3.getId(), "", "", "", new File().setUid(4), Collections.emptyList(), 1), studyId, null).first(); long jobId = job.getUid(); assertEquals(Job.JobStatus.PREPARED, job.getStatus().getName()); catalogJobDBAdaptor.delete(jobId); thrown.expect(CatalogDBException.class); thrown.expectMessage("not exist"); catalogJobDBAdaptor.get(jobId, QueryOptions.empty()); }
@Test public void SetVisitedJob() throws CatalogException { long studyId = user3.getProjects().get(0).getStudies().get(0).getUid(); Job jobBefore = catalogJobDBAdaptor.insert(new Job("name", user3.getId(), "", "", "", new File().setUid(4), Collections.emptyList(), 1), studyId, null).first(); long jobId = jobBefore.getUid(); assertTrue(!jobBefore.isVisited()); ObjectMap params = new ObjectMap(JobDBAdaptor.QueryParams.VISITED.key(), true); catalogJobDBAdaptor.update(jobBefore.getUid(), params, QueryOptions.empty()); Job jobAfter = catalogJobDBAdaptor.get(jobId, null).first(); assertTrue(jobAfter.isVisited()); }
@Test public void updateInputAndOutputFiles() throws Exception { Job job = new Job() .setOutDir(new File().setUid(5)) .setStatus(new Job.JobStatus()); long studyId = user3.getProjects().get(0).getStudies().get(0).getUid(); job.setName("jobName1"); QueryResult<Job> insert = catalogJobDBAdaptor.insert(job, studyId, null); List<File> fileInput = Arrays.asList( new File().setUid(5L).setName("file1").setStatus(new File.FileStatus()), new File().setUid(6L).setName("file2").setStatus(new File.FileStatus()), new File().setUid(7L).setName("file3").setStatus(new File.FileStatus()) ); List<File> fileOutput = Arrays.asList( new File().setUid(15L).setName("file1").setStatus(new File.FileStatus()), new File().setUid(16L).setName("file2").setStatus(new File.FileStatus()), new File().setUid(17L).setName("file3").setStatus(new File.FileStatus()) ); ObjectMap params = new ObjectMap() .append(JobDBAdaptor.QueryParams.INPUT.key(), fileInput) .append(JobDBAdaptor.QueryParams.OUTPUT.key(), fileOutput); QueryResult<Job> update = catalogJobDBAdaptor.update(insert.first().getUid(), params, QueryOptions.empty()); assertEquals(3, update.first().getInput().size()); assertEquals(3, update.first().getOutput().size()); assertTrue(Arrays.asList(5L, 6L, 7L).containsAll(update.first().getInput().stream().map(File::getUid).collect(Collectors.toList()))); assertTrue(Arrays.asList(15L, 16L, 17L) .containsAll(update.first().getOutput().stream().map(File::getUid).collect(Collectors.toList()))); }
/** * Job methods * *************************** */ @Test public void testCreateJob() throws CatalogException, IOException { Query query = new Query(StudyDBAdaptor.QueryParams.OWNER.key(), "user"); String studyId = catalogManager.getStudyManager().get(query, null, sessionIdUser).first().getId(); File outDir = catalogManager.getFileManager().createFolder(studyId, Paths.get("jobs", "myJob").toString(), null, true, null, QueryOptions.empty(), sessionIdUser).first(); catalogManager.getJobManager().create(studyId,new Job().setId("myJob").setToolId("samtool").setDescription("description") .setOutDir(outDir).setExecution("echo \"Hello world!\"").setStatus(new Job.JobStatus(Job.JobStatus.PREPARED)), null, sessionIdUser); catalogManager.getJobManager().create(studyId, new Job().setId("myReadyJob").setToolId("samtool").setDescription("description") .setOutDir(outDir).setExecution("echo \"Hello world!\"").setStatus(new Job.JobStatus(Job.JobStatus.READY)), null, sessionIdUser); catalogManager.getJobManager().create(studyId, new Job().setId("myQueuedJob").setToolId("samtool").setDescription("description") .setOutDir(outDir).setExecution("echo \"Hello world!\"").setStatus(new Job.JobStatus(Job.JobStatus.QUEUED)), null, sessionIdUser); catalogManager.getJobManager().create(studyId, new Job().setId("myErrorJob").setToolId("samtool").setDescription("description") .setOutDir(outDir).setExecution("echo \"Hello world!\"").setStatus(new Job.JobStatus(Job.JobStatus.ERROR)), null, sessionIdUser); query = new Query() .append(JobDBAdaptor.QueryParams.STATUS_NAME.key(), Arrays.asList(Job.JobStatus.PREPARED, Job.JobStatus.QUEUED, Job.JobStatus.RUNNING, Job.JobStatus.DONE)); QueryResult<Job> unfinishedJobs = catalogManager.getJobManager().get(String.valueOf(studyId), query, null, sessionIdUser); assertEquals(2, unfinishedJobs.getNumResults()); QueryResult<Job> allJobs = catalogManager.getJobManager().get(String.valueOf(studyId), (Query) null, null, sessionIdUser); assertEquals(4, allJobs.getNumResults()); }
@Test public void getAllJobs() throws CatalogException { Job job = new Job() .setId("job1") .setToolId("toolId") .setOutDir(new File().setPath(data_d1_d2)); long job1 = catalogManager.getJobManager().create(studyFqn, job, null, ownerSessionId).first().getUid(); job.setId("job2"); long job2 = catalogManager.getJobManager().create(studyFqn, job, null, ownerSessionId).first().getUid(); job.setId("job3"); long job3 = catalogManager.getJobManager().create(studyFqn, job, null, ownerSessionId).first().getUid(); job.setId("job4"); long job4 = catalogManager.getJobManager().create(studyFqn, job, null, ownerSessionId).first().getUid(); checkGetAllJobs(Arrays.asList(job1, job2, job3, job4), ownerSessionId); //Owner can see everything checkGetAllJobs(Collections.emptyList(), externalSessionId); //Can't see inside data_d1_d2_d3 }
@Test public void testGetAllJobs() throws CatalogException { Query query = new Query(StudyDBAdaptor.QueryParams.OWNER.key(), "user"); String studyId = catalogManager.getStudyManager().get(query, null, sessionIdUser).first().getId(); catalogManager.getJobManager().create(studyId, new Job().setId("myErrorJob").setToolId("samtools"), null, sessionIdUser); QueryResult<Job> allJobs = catalogManager.getJobManager().get(studyId, (Query) null, null, sessionIdUser); assertEquals(1, allJobs.getNumTotalResults()); assertEquals(1, allJobs.getNumResults()); }