Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update cBioPortal to dynamically load ch Components only when property clickhouse_enabled is set #11256

Merged
merged 5 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ jobs:
name: Instantiate a cbioportal instance
environment:
DOCKER_REPO: cbioportal/cbioportal-dev
CLICKHOUSE_MODE: true
APP_CLICKHOUSE_MODE: "true"
command: |
cd cbioportal-test
export DOCKER_IMAGE_CBIOPORTAL=$DOCKER_REPO:$CIRCLE_SHA1-web-shenandoah
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ jobs:
run: |
cd ./data && ./init.sh && rm -rf ./studies/* && cd ../config && \
cat $PORTAL_SOURCE_DIR/src/main/resources/application.properties | \
sed 's|spring.datasource.mysql.url=.*|spring.datasource.mysql.url=jdbc:mysql://cbioportal-database:3306/cbioportal?useSSL=false|' | \
sed 's|spring.datasource.mysql.username=.*|spring.datasource.mysql.username=cbio_user|' | \
sed 's|spring.datasource.mysql.password=.*|spring.datasource.mysql.password=somepassword|' \
sed 's|spring.datasource.url=.*|spring.datasource.url=jdbc:mysql://cbioportal-database:3306/cbioportal?useSSL=false|' | \
sed 's|spring.datasource.username=.*|spring.datasource.username=cbio_user|' | \
sed 's|spring.datasource.password=.*|spring.datasource.password=somepassword|' \
> application.properties
- name: 'Copy cgds.sql file into Docker Compose'
run: cp ./cbioportal/src/main/resources/db-scripts/cgds.sql ./cbioportal-docker-compose/data/.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
package org.cbioportal.persistence.mybatis;

import org.cbioportal.model.AlterationCountByGene;
import org.cbioportal.model.CaseListDataCount;
import org.cbioportal.model.ClinicalAttribute;
import org.cbioportal.model.ClinicalData;
import org.cbioportal.model.ClinicalDataCount;
import org.cbioportal.model.ClinicalDataCountItem;
import org.cbioportal.model.ClinicalEventTypeCount;
import org.cbioportal.model.CopyNumberCountByGene;
import org.cbioportal.model.GenericAssayDataCountItem;
import org.cbioportal.model.GenomicDataCount;
import org.cbioportal.model.GenomicDataCountItem;
import org.cbioportal.model.MolecularProfile;
import org.cbioportal.model.PatientTreatment;
import org.cbioportal.model.Sample;
import org.cbioportal.model.SampleTreatment;
import org.cbioportal.model.StudyViewFilterContext;
import org.cbioportal.persistence.StudyViewRepository;
import org.cbioportal.utils.config.annotation.ConditionalOnProperty;
import org.cbioportal.web.parameter.ClinicalDataType;
import org.cbioportal.web.parameter.GenericAssayDataBinFilter;
import org.cbioportal.web.parameter.GenericAssayDataFilter;
import org.cbioportal.web.parameter.GenomicDataBinFilter;
import org.cbioportal.web.parameter.GenomicDataFilter;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;
import java.util.Set;

@Repository
@ConditionalOnProperty(name = "clickhouse_mode", havingValue = "false", matchIfMissing = true)
public class UnImplementedStudyViewMyBatisRepository implements StudyViewRepository {

private static final String UNSUPPORTED_OPERATION = "StudyViewRepository Feature Not supported... Contact cbio admin.";

@Override
public List<Sample> getFilteredSamples(StudyViewFilterContext studyViewFilterContext) {
throw new UnsupportedOperationException(UNSUPPORTED_OPERATION);
}

@Override
public List<String> getFilteredStudyIds(StudyViewFilterContext studyViewFilterContext) {
throw new UnsupportedOperationException(UNSUPPORTED_OPERATION);
}

@Override
public List<ClinicalData> getSampleClinicalData(StudyViewFilterContext studyViewFilterContext, List<String> attributeIds) {
throw new UnsupportedOperationException(UNSUPPORTED_OPERATION);
}

@Override
public List<ClinicalData> getPatientClinicalData(StudyViewFilterContext studyViewFilterContext, List<String> attributeIds) {
throw new UnsupportedOperationException(UNSUPPORTED_OPERATION);

}

@Override
public List<AlterationCountByGene> getMutatedGenes(StudyViewFilterContext studyViewFilterContext) {
throw new UnsupportedOperationException(UNSUPPORTED_OPERATION);
}

@Override
public List<AlterationCountByGene> getStructuralVariantGenes(StudyViewFilterContext studyViewFilterContext) {
throw new UnsupportedOperationException(UNSUPPORTED_OPERATION);
}

@Override
public List<CopyNumberCountByGene> getCnaGenes(StudyViewFilterContext studyViewFilterContext) {
throw new UnsupportedOperationException(UNSUPPORTED_OPERATION);
}

@Override
public List<ClinicalDataCountItem> getClinicalDataCounts(StudyViewFilterContext studyViewFilterContext, List<String> filteredAttributes) {
throw new UnsupportedOperationException(UNSUPPORTED_OPERATION);
}

@Override
public List<GenomicDataCount> getMolecularProfileSampleCounts(StudyViewFilterContext studyViewFilterContext) {
throw new UnsupportedOperationException(UNSUPPORTED_OPERATION);
}

@Override
public Map<String, ClinicalDataType> getClinicalAttributeDatatypeMap() {
throw new UnsupportedOperationException(UNSUPPORTED_OPERATION);
}

@Override
public List<CaseListDataCount> getCaseListDataCountsPerStudy(StudyViewFilterContext studyViewFilterContext) {
throw new UnsupportedOperationException(UNSUPPORTED_OPERATION);
}

@Override
public Map<String, Integer> getTotalProfiledCounts(StudyViewFilterContext studyViewFilterContext, String alterationType, List<MolecularProfile> molecularProfiles) {
throw new UnsupportedOperationException(UNSUPPORTED_OPERATION);
}

@Override
public List<ClinicalAttribute> getClinicalAttributes() {
throw new UnsupportedOperationException(UNSUPPORTED_OPERATION);
}

@Override
public List<ClinicalAttribute> getClinicalAttributesForStudies(List<String> studyIds) {
throw new UnsupportedOperationException(UNSUPPORTED_OPERATION);
}

@Override
public int getFilteredSamplesCount(StudyViewFilterContext studyViewFilterContext) {
throw new UnsupportedOperationException(UNSUPPORTED_OPERATION);
}

@Override
public int getFilteredPatientCount(StudyViewFilterContext studyViewFilterContext) {
throw new UnsupportedOperationException(UNSUPPORTED_OPERATION);
}

@Override
public Map<String, Set<String>> getMatchingGenePanelIds(StudyViewFilterContext studyViewFilterContext, String alterationType) {
throw new UnsupportedOperationException(UNSUPPORTED_OPERATION);
}

@Override
public int getTotalProfiledCountsByAlterationType(StudyViewFilterContext studyViewFilterContext, String alterationType) {
throw new UnsupportedOperationException(UNSUPPORTED_OPERATION);
}

@Override
public int getSampleProfileCountWithoutPanelData(StudyViewFilterContext studyViewFilterContext, String alterationType) {
throw new UnsupportedOperationException(UNSUPPORTED_OPERATION);
}

@Override
public List<ClinicalEventTypeCount> getClinicalEventTypeCounts(StudyViewFilterContext studyViewFilterContext) {
throw new UnsupportedOperationException(UNSUPPORTED_OPERATION);
}

@Override
public List<PatientTreatment> getPatientTreatments(StudyViewFilterContext studyViewFilterContext) {
throw new UnsupportedOperationException(UNSUPPORTED_OPERATION);
}

@Override
public int getTotalPatientTreatmentCount(StudyViewFilterContext studyViewFilterContext) {
throw new UnsupportedOperationException(UNSUPPORTED_OPERATION);
}

@Override
public List<SampleTreatment> getSampleTreatments(StudyViewFilterContext studyViewFilterContext) {
throw new UnsupportedOperationException(UNSUPPORTED_OPERATION);
}

@Override
public int getTotalSampleTreatmentCount(StudyViewFilterContext studyViewFilterContext) {
throw new UnsupportedOperationException(UNSUPPORTED_OPERATION);
}

@Override
public List<GenomicDataCountItem> getCNACounts(StudyViewFilterContext studyViewFilterContext, List<GenomicDataFilter> genomicDataFilters) {
throw new UnsupportedOperationException(UNSUPPORTED_OPERATION);
}

@Override
public List<GenericAssayDataCountItem> getGenericAssayDataCounts(StudyViewFilterContext studyViewFilterContext, List<GenericAssayDataFilter> genericAssayDataFilters) {
throw new UnsupportedOperationException(UNSUPPORTED_OPERATION);
}

@Override
public Map<String, Integer> getMutationCounts(StudyViewFilterContext studyViewFilterContext, GenomicDataFilter genomicDataFilter) {
throw new UnsupportedOperationException(UNSUPPORTED_OPERATION);
}

@Override
public List<GenomicDataCountItem> getMutationCountsByType(StudyViewFilterContext studyViewFilterContext, List<GenomicDataFilter> genomicDataFilters) {
return List.of();
}

@Override
public List<ClinicalDataCount> getGenomicDataBinCounts(StudyViewFilterContext studyViewFilterContext, List<GenomicDataBinFilter> genomicDataBinFilters) {
return List.of();
}

@Override
public List<ClinicalDataCount> getGenericAssayDataBinCounts(StudyViewFilterContext studyViewFilterContext, List<GenericAssayDataBinFilter> genericAssayDataBinFilters) {
return List.of();
}

@Override
public List<MolecularProfile> getGenericAssayProfiles() {
return List.of();
}

@Override
public List<MolecularProfile> getFilteredMolecularProfilesByAlterationType(StudyViewFilterContext studyViewFilterContext, String alterationType) {
return List.of();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.cbioportal.model.Sample;
import org.cbioportal.persistence.mybatis.typehandler.SampleTypeTypeHandler;
import org.cbioportal.utils.config.annotation.ConditionalOnProperty;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.annotation.MapperScan;
import org.mybatis.spring.boot.autoconfigure.ConfigurationCustomizer;
Expand Down Expand Up @@ -33,7 +34,19 @@ public void customize(org.apache.ibatis.session.Configuration configuration) {
}

@Bean("sqlSessionFactory")
public SqlSessionFactoryBean sqlSessionFactory(@Qualifier("mysqlDataSource") DataSource dataSource, ApplicationContext applicationContext) throws IOException {
@ConditionalOnProperty(name = "clickhouse_mode", havingValue = "true")
public SqlSessionFactoryBean sqlSessionFactorySpecifyDataSource(@Qualifier("mysqlDataSource") DataSource dataSource, ApplicationContext applicationContext) throws IOException {
return sqlSessionFactory(dataSource, applicationContext);
}

@Bean("sqlSessionFactory")
@ConditionalOnProperty(name = "clickhouse_mode", havingValue = "false", matchIfMissing = true)
public SqlSessionFactoryBean sqlSessionFactoryDefault(DataSource dataSource, ApplicationContext applicationContext) throws IOException {
return sqlSessionFactory(dataSource, applicationContext);
}


private SqlSessionFactoryBean sqlSessionFactory(DataSource dataSource, ApplicationContext applicationContext) throws IOException {
SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
sessionFactory.setDataSource(dataSource);
sessionFactory.setMapperLocations(
Expand All @@ -43,8 +56,9 @@ public SqlSessionFactoryBean sqlSessionFactory(@Qualifier("mysqlDataSource") Dat
return sessionFactory;
}

@Bean
public DataSourceTransactionManager transactionManager(@Qualifier("mysqlDataSource") DataSource dataSource) {
return new DataSourceTransactionManager(dataSource);
}
@Bean
@ConditionalOnProperty(name = "clickhouse_mode", havingValue = "true")
public DataSourceTransactionManager transactionManager(@Qualifier("mysqlDataSource") DataSource dataSource) {
return new DataSourceTransactionManager(dataSource);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.cbioportal.persistence.helper.AlterationFilterHelper;
import org.cbioportal.persistence.helper.StudyViewFilterHelper;
import org.cbioportal.service.util.StudyViewColumnarServiceUtil;
import org.cbioportal.utils.config.annotation.ConditionalOnProperty;
import org.cbioportal.web.parameter.ClinicalDataType;
import org.cbioportal.web.parameter.GenericAssayDataBinFilter;
import org.cbioportal.web.parameter.GenericAssayDataFilter;
Expand All @@ -38,6 +39,7 @@
import java.util.stream.Collectors;

@Repository
@ConditionalOnProperty(name = "clickhouse_mode", havingValue = "true")
public class StudyViewMyBatisRepository implements StudyViewRepository {

private final StudyViewMapper studyViewMapper;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.cbioportal.persistence.mybatisclickhouse.config;

import org.cbioportal.persistence.mybatis.typehandler.SampleTypeTypeHandler;
import org.cbioportal.utils.config.annotation.ConditionalOnProperty;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Qualifier;
Expand All @@ -13,6 +14,7 @@


@Configuration
@ConditionalOnProperty(name = "clickhouse_mode", havingValue = "true")
@MapperScan(value= "org.cbioportal.persistence.mybatisclickhouse", sqlSessionFactoryRef ="sqlColumnarSessionFactory")
public class PersistenceColumnarConfig {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.cbioportal.properties;

import org.springframework.beans.factory.annotation.Qualifier;
import org.cbioportal.utils.config.annotation.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
Expand All @@ -9,6 +9,7 @@
import javax.sql.DataSource;

@Configuration
@ConditionalOnProperty(name = "clickhouse_mode", havingValue = "true")
public class CustomDataSourceConfiguration {
@Bean
@ConfigurationProperties("spring.datasource.mysql")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.cbioportal.service.exception.StudyNotFoundException;
import org.cbioportal.service.treatment.TreatmentCountReportService;
import org.cbioportal.service.util.StudyViewColumnarServiceUtil;
import org.cbioportal.utils.config.annotation.ConditionalOnProperty;
import org.cbioportal.web.parameter.ClinicalDataType;
import org.cbioportal.web.parameter.CustomSampleIdentifier;
import org.cbioportal.web.parameter.GenericAssayDataBinFilter;
Expand All @@ -38,6 +39,7 @@
import java.util.stream.Collectors;

@Service
@ConditionalOnProperty(name = "clickhouse_mode", havingValue = "true")
public class StudyViewColumnarServiceImpl implements StudyViewColumnarService {


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@
import org.cbioportal.model.StudyViewFilterContext;
import org.cbioportal.model.TemporalRelation;
import org.cbioportal.persistence.StudyViewRepository;
import org.cbioportal.utils.config.annotation.ConditionalOnProperty;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Set;
import java.util.stream.Stream;

@Service
@ConditionalOnProperty(name = "clickhouse_mode", havingValue = "true")
public class TreatmentCountReportServiceImpl implements TreatmentCountReportService {

private final StudyViewRepository studyViewRepository;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.cbioportal.service.CustomDataService;
import org.cbioportal.service.StudyViewColumnarService;
import org.cbioportal.service.util.CustomDataSession;
import org.cbioportal.utils.config.annotation.ConditionalOnProperty;
import org.cbioportal.web.columnar.util.CustomDataFilterUtil;
import org.cbioportal.web.columnar.util.NewClinicalDataBinUtil;
import org.cbioportal.web.parameter.*;
Expand All @@ -25,6 +26,7 @@
// but BasicDataBinner can support clinical data counts too
// after we switched clinical data counts to use this, then We can remove ClinicalDataBinner
@Component
@ConditionalOnProperty(name = "clickhouse_mode", havingValue = "true")
public class BasicDataBinner {
private final StudyViewColumnarService studyViewColumnarService;
private final DataBinner dataBinner;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.cbioportal.model.ClinicalDataCount;
import org.cbioportal.model.ClinicalDataCountItem;
import org.cbioportal.service.StudyViewColumnarService;
import org.cbioportal.utils.config.annotation.ConditionalOnProperty;
import org.cbioportal.web.columnar.util.NewClinicalDataBinUtil;
import org.cbioportal.web.parameter.ClinicalDataBinCountFilter;
import org.cbioportal.web.parameter.ClinicalDataBinFilter;
Expand All @@ -21,6 +22,7 @@
import java.util.stream.Collectors;

@Component
@ConditionalOnProperty(name = "clickhouse_mode", havingValue = "true")
public class ClinicalDataBinner {
private final StudyViewColumnarService studyViewColumnarService;
private final DataBinner dataBinner;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.cbioportal.service.ViolinPlotService;
import org.cbioportal.service.exception.StudyNotFoundException;
import org.cbioportal.service.util.CustomDataSession;
import org.cbioportal.utils.config.annotation.ConditionalOnProperty;
import org.cbioportal.web.columnar.util.CustomDataFilterUtil;
import org.cbioportal.web.columnar.util.NewStudyViewFilterUtil;
import org.cbioportal.web.config.annotation.InternalApi;
Expand Down Expand Up @@ -78,6 +79,7 @@
@RestController()
@RequestMapping("/api")
@Validated
@ConditionalOnProperty(name = "clickhouse_mode", havingValue = "true")
public class StudyViewColumnStoreController {

private final StudyViewColumnarService studyViewColumnarService;
Expand Down
Loading
Loading