Skip to content

Commit

Permalink
Merge branch 'hotfix-1.30.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
arteymix committed Sep 14, 2023
2 parents 9ae38cc + b17fca4 commit a46519e
Show file tree
Hide file tree
Showing 313 changed files with 3,359 additions and 3,942 deletions.
2 changes: 1 addition & 1 deletion gemma-cli/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>gemma</artifactId>
<groupId>gemma</groupId>
<version>1.30.0</version>
<version>1.30.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>gemma-cli</artifactId>
Expand Down
19 changes: 5 additions & 14 deletions gemma-cli/src/main/config/log4j.properties
Original file line number Diff line number Diff line change
Expand Up @@ -109,27 +109,18 @@ log4j.logger.org.springframework.beans.GenericTypeAwarePropertyDescriptor=FATAL
log4j.logger.org.springframework.security.access.event.LoggerListener=INFO
log4j.logger.org.springframework.security.authentication.event.LoggerListener=ERROR

# DWR
# suppress inspection "SpellCheckingInspection"
log4j.logger.org.directwebremoting=WARN

# Apache Commons
log4j.logger.org.apache.commons=WARN

# Compass
log4j.logger.org.compass=WARN
# annoying message we can't fix from Compass.
log4j.logger.org.compass.gps.device.hibernate.indexer=DEBUG

# JavaSpaces
# suppress inspection "SpellCheckingInspection"
log4j.logger.ubic.gemma.grid.javaspaces=INFO

# Hibernate
log4j.logger.org.hibernate=WARN
# Avoid warnings about expired objects.
log4j.logger.org.hibernate.cache.ReadWriteCache=ERROR
# Avoid warnings about collection fail-safe cleanup.
log4j.logger.org.hibernate.engine.loading.LoadContexts=ERROR
log4j.logger.net.sf.ehcache.hibernate.strategy.AbstractReadWriteEhcacheAccessStrategy=ERROR
log4j.logger.org.hibernate.cache.ehcache.internal.strategy.AbstractReadWriteEhcacheAccessStrategy=ERROR
log4j.logger.org.hibernate.cache.ehcache.internal.strategy.AbstractReadWriteEhcacheAccessStrategy=ERROR

# Hibernate Search
# This is necessary to see progress in IndexGemmaCLI command
log4j.logger.org.hibernate.search.impl.SimpleIndexingProgressMonitor=INFO
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package ubic.gemma.core.apps;

import org.apache.commons.cli.Options;
import ubic.gemma.model.common.auditAndSecurity.eventType.FailedSampleCorrelationAnalysisEvent;
import ubic.gemma.model.expression.experiment.BioAssaySet;
import ubic.gemma.model.expression.experiment.ExpressionExperiment;
import ubic.gemma.persistence.service.analysis.expression.sampleCoexpression.SampleCoexpressionAnalysisService;
Expand Down Expand Up @@ -63,11 +64,6 @@ protected void buildOptions( Options options ) {
super.addForceOption( options );
}

private void audit( ExpressionExperiment ee ) {
auditTrailService.addUpdateEvent( ee, "Generated sample correlation matrix" );
addSuccessObject( ee );
}

private void processExperiment( ExpressionExperiment ee ) {
if ( !force && this.noNeedToRun( ee, null ) ) {
return;
Expand All @@ -77,13 +73,17 @@ private void processExperiment( ExpressionExperiment ee ) {
.getBean( SampleCoexpressionAnalysisService.class );

ee = eeService.thawLiter( ee );
if ( force ) {
sampleCoexpressionAnalysisService.compute( ee );
} else {
sampleCoexpressionAnalysisService.computeIfNecessary( ee );
try {
if ( force ) {
sampleCoexpressionAnalysisService.compute( ee );
} else {
sampleCoexpressionAnalysisService.computeIfNecessary( ee );
}
addSuccessObject( ee );
} catch ( Exception e ) {
auditTrailService.addUpdateEvent( ee, FailedSampleCorrelationAnalysisEvent.class, null, e );
addErrorObject( ee, e );
}

this.audit( ee );
}

}
6 changes: 3 additions & 3 deletions gemma-cli/src/main/java/ubic/gemma/core/apps/GemmaCLI.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public static void main( String[] args ) {
.build();
Option otherLogOpt = Option.builder( LOGGER_OPTION )
.longOpt( "logger" ).hasArg()
.desc( "Configure a specific logger verbosity. For example, '--logger ubic.gemma=5' or --logger log4j.logger.org.hibernate.SQL=5" )
.desc( "Configure a specific logger verbosity (0=silent, 5=very verbose; default is custom, see log4j.properties). For example, '--logger ubic.gemma=5' or '--logger org.hibernate.SQL=5'" )
.build();
Options options = new Options()
.addOption( HELP_OPTION, "help", false, "Show help" )
Expand Down Expand Up @@ -145,12 +145,12 @@ public static void main( String[] args ) {

List<String> profiles = new ArrayList<>();
profiles.add( "cli" );

// check for the -testing/--testing flag to load the appropriate application context
if ( commandLine.hasOption( TESTING_OPTION ) ) {
profiles.add( SpringProfiles.TEST );
}

// check for the -testing flag to load the appropriate application context
/* webapp */
ApplicationContext ctx = SpringContextUtil.getApplicationContext( profiles.toArray( new String[0] ) );

/*
Expand Down
213 changes: 73 additions & 140 deletions gemma-cli/src/main/java/ubic/gemma/core/apps/IndexGemmaCLI.java
Original file line number Diff line number Diff line change
@@ -1,168 +1,101 @@
/*
/*
* The Gemma project
*
* Copyright (c) 2006 University of British Columbia
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package ubic.gemma.core.apps;

import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.Option;
import org.apache.commons.cli.Options;
import org.compass.gps.spi.CompassGpsInterfaceDevice;
import ubic.gemma.core.apps.GemmaCLI.CommandGroup;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import ubic.gemma.core.search.IndexerService;
import ubic.gemma.core.util.AbstractCLI;
import ubic.gemma.core.util.AbstractCLIContextCLI;
import ubic.gemma.persistence.util.CompassUtils;
import ubic.gemma.model.analysis.expression.ExpressionExperimentSet;
import ubic.gemma.model.common.Identifiable;
import ubic.gemma.model.common.description.BibliographicReference;
import ubic.gemma.model.expression.arrayDesign.ArrayDesign;
import ubic.gemma.model.expression.designElement.CompositeSequence;
import ubic.gemma.model.expression.experiment.ExpressionExperiment;
import ubic.gemma.model.genome.Gene;
import ubic.gemma.model.genome.biosequence.BioSequence;
import ubic.gemma.model.genome.gene.GeneSet;

import java.io.File;
import java.util.HashSet;
import java.util.Set;
import java.util.stream.Collectors;

@Component
public class IndexGemmaCLI extends AbstractCLI {

/**
* A list of all searchable entities this CLI supports.
*/
private static final IndexableEntity[] indexableEntities = {
new IndexableEntity( "g", "genes", Gene.class ),
new IndexableEntity( "e", "datasets", ExpressionExperiment.class ),
new IndexableEntity( "a", "platforms", ArrayDesign.class ),
new IndexableEntity( "b", "bibliographic references", BibliographicReference.class ),
new IndexableEntity( "s", "probes", CompositeSequence.class ),
new IndexableEntity( "q", "sequences", BioSequence.class ),
new IndexableEntity( "x", "datasets groups", ExpressionExperimentSet.class ),
new IndexableEntity( "y", "gene sets", GeneSet.class )
};

@lombok.Value
private static class IndexableEntity {
String option;
String description;
Class<? extends Identifiable> clazz;
}

/**
* Simple command line to index the gemma db. Can index gene's, Expression experiments or array Designs
*
* @author klc
*/
public class IndexGemmaCLI extends AbstractCLIContextCLI {
@Autowired
private IndexerService indexerService;

private boolean indexAD = false;
private boolean indexB = false;
private boolean indexEE = false;
private boolean indexG = false;
private boolean indexP = false;
private boolean indexQ = false;
private boolean indexX = false;
private boolean indexY = false;
@Value("${gemma.search.dir}")
private File searchDir;

@Override
public CommandGroup getCommandGroup() {
return CommandGroup.SYSTEM;
}
private final Set<Class<? extends Identifiable>> classesToIndex = new HashSet<>();

@Override
public String getCommandName() {
return "searchIndex";
}

@SuppressWarnings("static-access")
@Override
protected void buildOptions( Options options ) {
Option geneOption = Option.builder( "g" ).desc( "Index genes" ).longOpt( "genes" ).build();
options.addOption( geneOption );

Option eeOption = Option.builder( "g" ).desc( "Index Expression Experiments" )
.longOpt( "ExpressionExperiments" ).build();
options.addOption( eeOption );

Option adOption = Option.builder( "a" ).desc( "Index Array Designs" ).longOpt( "ArrayDesigns" )
.build();
options.addOption( adOption );

Option bibliographicOption = Option.builder( "b" ).desc( "Index Bibliographic References" )
.longOpt( "Bibliographic" ).build();
options.addOption( bibliographicOption );

Option probeOption = Option.builder( "s" ).desc( "Index probes" ).longOpt( "probes" ).build();
options.addOption( probeOption );

Option sequenceOption = Option.builder( "q" ).desc( "Index sequences" ).longOpt( "sequences" )
.build();
options.addOption( sequenceOption );

options.addOption( Option.builder( "x" ).desc( "Index EE sets" ).longOpt( "eesets" ).build() );

options.addOption( Option.builder( "y" ).desc( "Index gene sets" ).longOpt( "genesets" ).build() );
public String getShortDesc() {
return "Create or update the searchable indexes for a Gemma production system";
}

@Override
protected void doWork() throws Exception {
/*
* These beans are defined in Spring XML.
*/
if ( this.indexG ) {
this.rebuildIndex( this.getBean( "geneGps", CompassGpsInterfaceDevice.class ), "Gene index" );
}
if ( this.indexEE ) {
this.rebuildIndex( this.getBean( "expressionGps", CompassGpsInterfaceDevice.class ),
"Expression Experiment index" );
}
if ( this.indexAD ) {
this.rebuildIndex( this.getBean( "arrayGps", CompassGpsInterfaceDevice.class ), "Array Design index" );
}
if ( this.indexB ) {
this.rebuildIndex( this.getBean( "bibliographicGps", CompassGpsInterfaceDevice.class ),
"Bibliographic Reference Index" );
}
if ( this.indexP ) {
this.rebuildIndex( this.getBean( "probeGps", CompassGpsInterfaceDevice.class ),
"Probe Reference Index" );
}
if ( this.indexQ ) {
this.rebuildIndex( this.getBean( "biosequenceGps", CompassGpsInterfaceDevice.class ),
"BioSequence Index" );
}

if ( this.indexY ) {
this.rebuildIndex( this.getBean( "experimentSetGps", CompassGpsInterfaceDevice.class ),
"Experiment set Index" );
}

if ( this.indexX ) {
this.rebuildIndex( this.getBean( "geneSetGps", CompassGpsInterfaceDevice.class ), "Gene set Index" );
}
public GemmaCLI.CommandGroup getCommandGroup() {
return GemmaCLI.CommandGroup.SYSTEM;
}

@Override
public String getShortDesc() {
return "Create or update the searchable indexes for a Gemma production system";
protected void buildOptions( Options options ) {
for ( IndexableEntity ie : indexableEntities ) {
options.addOption( ie.option, null, false, "Index " + ie.description );
}
addThreadsOption( options );
}

@Override
protected void processOptions( CommandLine commandLine ) {
if ( commandLine.hasOption( 'e' ) )
indexEE = true;

if ( commandLine.hasOption( 'a' ) )
indexAD = true;

if ( commandLine.hasOption( 'g' ) )
indexG = true;

if ( commandLine.hasOption( 'b' ) )
indexB = true;

if ( commandLine.hasOption( 's' ) )
indexP = true;

if ( commandLine.hasOption( 'q' ) )
indexQ = true;
if ( commandLine.hasOption( 'x' ) )
indexX = true;
if ( commandLine.hasOption( 'y' ) )
indexY = true;

protected void processOptions( CommandLine commandLine ) throws Exception {
for ( IndexableEntity ie : indexableEntities ) {
if ( commandLine.hasOption( ie.option ) ) {
classesToIndex.add( ie.clazz );
}
}
}

private void rebuildIndex( CompassGpsInterfaceDevice device, String whatIndexingMsg ) {

long time = System.currentTimeMillis();

AbstractCLI.log.info( "Rebuilding " + whatIndexingMsg );
CompassUtils.rebuildCompassIndex( device );
time = System.currentTimeMillis() - time;

AbstractCLI.log.info( "Finished rebuilding " + whatIndexingMsg + ". Took (ms): " + time );
AbstractCLI.log.info( " \n " );

@Override
protected void doWork() throws Exception {
if ( classesToIndex.isEmpty() ) {
log.info( String.format( "All entities will be indexed under %s.", searchDir.getAbsolutePath() ) );
indexerService.index( numThreads );
} else {
log.info( String.format( "The following entities will be indexed under %s:\n\t%s",
searchDir.getAbsolutePath(),
classesToIndex.stream().map( Class::getName ).collect( Collectors.joining( "\n\t" ) ) ) );
indexerService.index( classesToIndex, numThreads );
}
}
}
Loading

0 comments on commit a46519e

Please sign in to comment.