Skip to content

Commit

Permalink
update spring boot to match cbioportal - spring boot 3, spring 6, spr…
Browse files Browse the repository at this point in the history
…ing batch 5
  • Loading branch information
mandawilson committed Feb 26, 2024
1 parent d217c2d commit 3169800
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 50 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016 Memorial Sloan-Kettering Cancer Center.
* Copyright (c) 2016 - 2024 Memorial Sloan-Kettering Cancer Center.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
Expand Down Expand Up @@ -36,37 +36,33 @@
import org.cbioportal.models.AnnotatedRecord;

import org.springframework.batch.core.*;
import org.springframework.batch.item.*;
import org.springframework.batch.core.configuration.annotation.*;
import org.springframework.context.annotation.*;
import org.springframework.batch.core.job.builder.JobBuilder;
import org.springframework.batch.core.repository.JobRepository;
import org.springframework.batch.core.step.builder.StepBuilder;
import org.springframework.batch.item.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.batch.core.configuration.annotation.StepScope;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.*;
import org.springframework.transaction.PlatformTransactionManager;

/**
* @author Zachary Heins
*/
@Configuration
@EnableBatchProcessing
@ComponentScan(basePackages="org.cbioportal.annotator")
public class BatchConfiguration
{
public static final String ANNOTATION_JOB = "annotationJob";

@Autowired
public JobBuilderFactory jobBuilderFactory;

@Autowired
public StepBuilderFactory stepBuilderFactory;

@Value("${chunk:1000000}")
private String chunk;
private String chunkSize;

@Bean
public Job annotationJob()
public Job annotationJob(JobRepository jobRepository, Step step)
{
return jobBuilderFactory.get(ANNOTATION_JOB)
.start(step())
return new JobBuilder(ANNOTATION_JOB, jobRepository)
.start(step)
.build();
}

Expand All @@ -76,10 +72,10 @@ public AnnotationUtil annotationUtil() {
}

@Bean
public Step step()
public Step step(JobRepository jobRepository, PlatformTransactionManager transactionManager)
{
return stepBuilderFactory.get("step")
.<AnnotatedRecord, String> chunk(Integer.parseInt(chunk))
return new StepBuilder("step", jobRepository)
.<AnnotatedRecord, String> chunk(Integer.parseInt(chunkSize), transactionManager)
.reader(reader())
.processor(processor())
.writer(writer())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016 - 2020 Memorial Sloan-Kettering Cancer Center.
* Copyright (c) 2016 - 2024 Memorial Sloan-Kettering Cancer Center.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public void close() throws ItemStreamException {
}

@Override
public void write(List<? extends String> items) throws Exception {
public void write(Chunk<? extends String> items) throws Exception {
if (recordsToWriteCount > 0) {
flatFileItemWriter.write(items);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ public void check_if_maf_file_still_the_same_when_annotating_with_uniprot_transc
.addString("outputFilename", actualFile)
.addString("replace", String.valueOf(true))
.addString("isoformOverride", "uniprot")
.addString("errorReportLocation", null)
.toJobParameters();
testWith(jobParameters, expectedFile, actualFile);
}
Expand All @@ -87,7 +86,6 @@ public void check_if_maf_file_still_the_same_when_annotating_with_mskcc_transcri
.addString("outputFilename", actualFile)
.addString("replace", String.valueOf(true))
.addString("isoformOverride", "mskcc")
.addString("errorReportLocation", null)
.toJobParameters();
testWith(jobParameters, expectedFile, actualFile);
}
Expand All @@ -104,7 +102,6 @@ public void check_if_minimal_example_maf_file_still_the_same_when_annotating_wit
.addString("outputFilename", actualFile)
.addString("replace", String.valueOf(true))
.addString("isoformOverride", "uniprot")
.addString("errorReportLocation", null)
.toJobParameters();
testWith(jobParameters, expectedFile, actualFile);
}
Expand All @@ -121,7 +118,6 @@ public void check_if_corner_cases_example_maf_file_still_the_same_when_annotatin
.addString("outputFilename", actualFile)
.addString("replace", String.valueOf(true))
.addString("isoformOverride", "uniprot")
.addString("errorReportLocation", null)
.toJobParameters();
testWith(jobParameters, expectedFile, actualFile);
}
Expand All @@ -138,7 +134,6 @@ public void check_if_corner_cases_example_maf_file_still_the_same_when_annotatin
.addString("outputFilename", actualFile)
.addString("replace", String.valueOf(true))
.addString("isoformOverride", "mskcc")
.addString("errorReportLocation", null)
.toJobParameters();
testWith(jobParameters, expectedFile, actualFile);
}
Expand All @@ -155,7 +150,6 @@ public void check_if_corner_cases_example_maf_file_still_the_same_when_annotatin
.addString("outputFilename", actualFile)
.addString("replace", String.valueOf(true))
.addString("isoformOverride", "uniprot")
.addString("errorReportLocation", null)
.toJobParameters();
testWith(jobParameters, expectedFile, actualFile);
}
Expand All @@ -172,7 +166,6 @@ public void check_if_corner_cases_example_maf_file_still_the_same_when_annotatin
.addString("outputFilename", actualFile)
.addString("replace", String.valueOf(true))
.addString("isoformOverride", "mskcc")
.addString("errorReportLocation", null)
.toJobParameters();
testWith(jobParameters, expectedFile, actualFile);
}
Expand All @@ -194,7 +187,6 @@ public void run_vcf2maf_test_case_mskcc() throws Exception {
.addString("outputFilename", actualFile)
.addString("replace", String.valueOf(true))
.addString("isoformOverride", "mskcc")
.addString("errorReportLocation", null)
.toJobParameters();
testWith(jobParameters, expectedFile, actualFile);
}
Expand All @@ -216,7 +208,6 @@ public void run_vcf2maf_test_case_uniprot() throws Exception {
.addString("outputFilename", actualFile)
.addString("replace", String.valueOf(true))
.addString("isoformOverride", "uniprot")
.addString("errorReportLocation", null)
.toJobParameters();
testWith(jobParameters, expectedFile, actualFile);
}
Expand All @@ -233,7 +224,6 @@ public void check_if_my_variant_info_provides_gnomad_annotations() throws Except
.addString("outputFilename", actualFile)
.addString("replace", String.valueOf(true))
.addString("isoformOverride", "uniprot")
.addString("errorReportLocation", null)
.toJobParameters();
testWith(jobParameters, expectedFile, actualFile);
}
Expand All @@ -250,7 +240,6 @@ public void check_if_nucleotide_context_provides_Ref_Tri_and_Var_Tri_columns() t
.addString("outputFilename", actualFile)
.addString("replace", String.valueOf(true))
.addString("isoformOverride", "uniprot")
.addString("errorReportLocation", null)
.toJobParameters();
testWith(jobParameters, expectedFile, actualFile);
}
Expand All @@ -268,7 +257,6 @@ public void test_output_format_extended() throws Exception {
.addString("outputFormat", "extended")
.addString("replace", String.valueOf(true))
.addString("isoformOverride", "uniprot")
.addString("errorReportLocation", null)
.addString("postIntervalSize", String.valueOf(-1))
.toJobParameters();
testWith(jobParameters, expectedFile, actualFile);
Expand All @@ -287,7 +275,6 @@ public void test_output_format_minimal() throws Exception {
.addString("outputFormat", "minimal")
.addString("replace", String.valueOf(true))
.addString("isoformOverride", "uniprot")
.addString("errorReportLocation", null)
.addString("postIntervalSize", String.valueOf(-1))
.toJobParameters();
testWith(jobParameters, expectedFile, actualFile);
Expand All @@ -310,7 +297,6 @@ public void test_output_format_with_formatFileHeaders() throws Exception {
.addString("outputFormat", "Hugo_Symbol,Entrez_Gene_Id,Center,NCBI_Build,Chromosome,Annotation_Status")
.addString("replace", String.valueOf(true))
.addString("isoformOverride", "uniprot")
.addString("errorReportLocation", null)
.addString("postIntervalSize", String.valueOf(-1))
.toJobParameters();
testWith(jobParameters, expectedFile, actualFile);
Expand All @@ -328,7 +314,6 @@ public void test_if_output_contains_original_genomic_location() throws Exception
.addString("outputFilename", actualFile)
.addString("replace", String.valueOf(true))
.addString("isoformOverride", "mskcc")
.addString("errorReportLocation", null)
.addString("postIntervalSize", String.valueOf(-1))
.addString("addOriginalGenomicLocation", String.valueOf(true))
.toJobParameters();
Expand All @@ -347,7 +332,6 @@ public void test_strip_off_first_matching_base() throws Exception {
.addString("outputFilename", actualFile)
.addString("replace", String.valueOf(true))
.addString("isoformOverride", "mskcc")
.addString("errorReportLocation", null)
.addString("postIntervalSize", String.valueOf(-1))
.addString("stripMatchingBases", "first")
.toJobParameters();
Expand All @@ -366,7 +350,6 @@ public void test_no_strip_off_matching_bases() throws Exception {
.addString("outputFilename", actualFile)
.addString("replace", String.valueOf(true))
.addString("isoformOverride", "mskcc")
.addString("errorReportLocation", null)
.addString("postIntervalSize", String.valueOf(-1))
.addString("stripMatchingBases", "none")
.toJobParameters();
Expand All @@ -385,7 +368,6 @@ public void test_ignore_original_genomic_location_in_input() throws Exception {
.addString("outputFilename", actualFile)
.addString("replace", String.valueOf(true))
.addString("isoformOverride", "mskcc")
.addString("errorReportLocation", null)
.addString("postIntervalSize", String.valueOf(-1))
.addString("stripMatchingBases", "none")
.addString("ignoreOriginalGenomicLocation", String.valueOf(true))
Expand All @@ -404,4 +386,4 @@ private void testWith(JobParameters jobParameters, String expectedPath, String a
assertEquals("COMPLETED", actualJobExitStatus.getExitCode());
AssertFile.assertFileEquals(expectedResult, actualResult);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016 - 2020 Memorial Sloan-Kettering Cancer Center.
* Copyright (c) 2016 - 2024 Memorial Sloan-Kettering Cancer Center.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
Expand Down Expand Up @@ -67,7 +67,7 @@
*
*/

@Configuration
@Configuration(enforceUniqueMethods=false)
public class GenomeNexusImpl implements Annotator {

@Value("${genomenexus.base:https://www.genomenexus.org}")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018 - 2020 Memorial Sloan-Kettering Cancer Center.
* Copyright (c) 2018 - 2024 Memorial Sloan-Kettering Cancer Center.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
Expand Down Expand Up @@ -64,7 +64,7 @@
*
* @author ochoaa
*/
@Configuration
@Configuration(enforceUniqueMethods=false)
public class MockGenomeNexusImpl extends GenomeNexusImpl {

private final boolean REPLACE = false;
Expand Down
1 change: 1 addition & 0 deletions databaseAnnotator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017 Memorial Sloan-Kettering Cancer Center.
* Copyright (c) 2017-2024 Memorial Sloan-Kettering Cancer Center.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
Expand Down Expand Up @@ -75,8 +75,8 @@ public void close() throws ItemStreamException {
}

@Override
public void write(List<? extends MutationEvent> list) throws Exception {
for (MutationEvent event : list) {
public void write(Chunk<? extends MutationEvent> chunk) throws Exception {
for (MutationEvent event : chunk) {
updateMutationEventInDb(event);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
*/

@Configuration
@EnableBatchProcessing
@ComponentScan(basePackages="org.cbioportal.annotator")
public class BatchConfiguration {

Expand Down
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.18</version>
<version>3.1.4</version>
</parent>

<properties>
<java.version>21</java.version>
<slf4j.version>1.7.30</slf4j.version>
<spring.version>5.3.31</spring.version>
<jackson.version>2.11.2</jackson.version>
<spring.version>6.0.12</spring.version>
<jackson.version>2.14.3</jackson.version>
<mockito.version>5.10.0</mockito.version>
</properties>

Expand Down

0 comments on commit 3169800

Please sign in to comment.