Skip to content

Commit

Permalink
Merge pull request #48 from icgc-argo/rc/2.5.0
Browse files Browse the repository at this point in the history
Rc/2.5.0
  • Loading branch information
jaserud authored Jan 18, 2021
2 parents cfaf782 + 83ce992 commit 24842f7
Show file tree
Hide file tree
Showing 19 changed files with 390 additions and 46 deletions.
40 changes: 20 additions & 20 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
def dockerHubRepo = "icgcargo/song-search"
def dockerRepo = "ghcr.io/icgc-argo/song-search"
def gitHubRepo = "icgc-argo/song-search"
def chartVersion = "1.1.0"
def chartVersion = "1.2.0"
def commit = "UNKNOWN"
def version = "UNKNOWN"

Expand Down Expand Up @@ -69,15 +69,15 @@ spec:
}
steps {
container('docker') {
withCredentials([usernamePassword(credentialsId:'argoDockerHub', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) {
sh 'docker login -u $USERNAME -p $PASSWORD'
withCredentials([usernamePassword(credentialsId:'argoContainers', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) {
sh 'docker login ghcr.io -u $USERNAME -p $PASSWORD'
}

// DNS error if --network is default
sh "docker build --network=host . -t ${dockerHubRepo}:edge -t ${dockerHubRepo}:${commit}"
sh "docker build --network=host . -t ${dockerRepo}:edge -t ${dockerRepo}:${commit}"

sh "docker push ${dockerHubRepo}:${commit}"
sh "docker push ${dockerHubRepo}:edge"
sh "docker push ${dockerRepo}:${commit}"
sh "docker push ${dockerRepo}:edge"
}
}
}
Expand All @@ -93,10 +93,10 @@ spec:
[$class: 'StringParameterValue', name: 'AP_HELM_CHART_VERSION', value: "${chartVersion}"],
[$class: 'StringParameterValue', name: 'AP_ARGS_LINE', value: "--set-string image.tag=${commit}" ]
])
sleep(time:30,unit:"SECONDS")
build(job: "/provision/rdpc-gateway-restart", parameters: [
[$class: 'StringParameterValue', name: 'AP_RDPC_ENV', value: 'dev' ],
])
// sleep(time:30,unit:"SECONDS")
// build(job: "/provision/rdpc-gateway-restart", parameters: [
// [$class: 'StringParameterValue', name: 'AP_RDPC_ENV', value: 'dev' ],
// ])
}
}
stage('Build & Publish Release') {
Expand All @@ -110,15 +110,15 @@ spec:
sh "git push https://${GIT_USERNAME}:${GIT_PASSWORD}@github.com/${gitHubRepo} --tags"
}

withCredentials([usernamePassword(credentialsId:'argoDockerHub', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) {
sh 'docker login -u $USERNAME -p $PASSWORD'
withCredentials([usernamePassword(credentialsId:'argoContainers', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) {
sh 'docker login ghcr.io -u $USERNAME -p $PASSWORD'
}

// DNS error if --network is default
sh "docker build --network=host . -t ${dockerHubRepo}:latest -t ${dockerHubRepo}:${version}"
sh "docker build --network=host . -t ${dockerRepo}:latest -t ${dockerRepo}:${version}"

sh "docker push ${dockerHubRepo}:${version}"
sh "docker push ${dockerHubRepo}:latest"
sh "docker push ${dockerRepo}:${version}"
sh "docker push ${dockerRepo}:latest"
}
}
}
Expand All @@ -134,10 +134,10 @@ spec:
[$class: 'StringParameterValue', name: 'AP_HELM_CHART_VERSION', value: "${chartVersion}"],
[$class: 'StringParameterValue', name: 'AP_ARGS_LINE', value: "--set-string image.tag=${version}" ]
])
sleep(time:30,unit:"SECONDS")
build(job: "/provision/rdpc-gateway-restart", parameters: [
[$class: 'StringParameterValue', name: 'AP_RDPC_ENV', value: 'qa' ],
])
// sleep(time:30,unit:"SECONDS")
// build(job: "/provision/rdpc-gateway-restart", parameters: [
// [$class: 'StringParameterValue', name: 'AP_RDPC_ENV', value: 'qa' ],
// ])
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</parent>
<groupId>bio.overture</groupId>
<artifactId>song-search</artifactId>
<version>2.4.0</version>
<version>2.5.0</version>
<name>song-search</name>
<description>GQL microservice for searching maestro generated song indexes</description>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package bio.overture.songsearch.config.constants;

import static lombok.AccessLevel.PRIVATE;

import lombok.NoArgsConstructor;

@NoArgsConstructor(access = PRIVATE)
public class EsDefaults {
// Default values from ES pagination:
// https://www.elastic.co/guide/en/elasticsearch/reference/7.x/paginate-search-results.html
public static final Integer ES_PAGE_DEFAULT_SIZE = 10;
public static final Integer ES_PAGE_DEFAULT_FROM = 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

package bio.overture.songsearch.config;
package bio.overture.songsearch.config.constants;

import static lombok.AccessLevel.PRIVATE;

Expand All @@ -39,4 +39,7 @@ public class SearchFields {
public static final String SUBMITTER_SAMPLE_ID = "submitterSampleId";
public static final String MATCHED_NORMAL_SUBMITTER_SAMPLE_ID = "matchedNormalSubmitterSampleId";
public static final String RUN_ID = "runId";
public static final String PUBLISHED_AT = "publishedAt";
public static final String UPDATED_AT = "updatedAt";
public static final String FIRST_PUBLISHED_AT = "firstPublishedAt";
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@

package bio.overture.songsearch.graphql;

import bio.overture.songsearch.model.Analysis;
import bio.overture.songsearch.model.SampleMatchedAnalysisPair;
import static bio.overture.songsearch.utils.JacksonUtils.convertValue;
import static java.util.stream.Collectors.toUnmodifiableList;

import bio.overture.songsearch.model.*;
import bio.overture.songsearch.service.AnalysisService;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import graphql.schema.DataFetcher;
import java.util.List;
Expand All @@ -42,18 +45,40 @@ public AnalysisDataFetcher(AnalysisService analysisService) {
}

@SuppressWarnings("unchecked")
public DataFetcher<List<Analysis>> getAnalysesDataFetcher() {
public DataFetcher<SearchResult<Analysis>> getAnalysesDataFetcher() {
return environment -> {
val args = environment.getArguments();

val filter = ImmutableMap.<String, Object>builder();
val page = ImmutableMap.<String, Integer>builder();
val sorts = ImmutableList.<Sort>builder();

if (args != null) {
if (args.get("filter") != null) filter.putAll((Map<String, Object>) args.get("filter"));
if (args.get("page") != null) page.putAll((Map<String, Integer>) args.get("page"));
if (args.get("sorts") != null) {
val rawSorts = (List<Object>) args.get("sorts");
sorts.addAll(
rawSorts.stream()
.map(sort -> convertValue(sort, Sort.class))
.collect(toUnmodifiableList()));
}
}
return analysisService.searchAnalyses(filter.build(), page.build(), sorts.build());
};
}

@SuppressWarnings("unchecked")
public DataFetcher<AggregationResult> getAggregateAnalysesDataFetcher() {
return environment -> {
val args = environment.getArguments();

val filter = ImmutableMap.<String, Object>builder();

if (args != null) {
if (args.get("filter") != null) filter.putAll((Map<String, Object>) args.get("filter"));
}
return analysisService.getAnalyses(filter.build(), page.build());
return analysisService.aggregateAnalyses(filter.build());
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

package bio.overture.songsearch.graphql;

import static bio.overture.songsearch.config.SearchFields.ANALYSIS_ID;
import static bio.overture.songsearch.config.SearchFields.RUN_ID;
import static bio.overture.songsearch.config.constants.SearchFields.ANALYSIS_ID;
import static bio.overture.songsearch.config.constants.SearchFields.RUN_ID;
import static bio.overture.songsearch.utils.CommonUtils.asImmutableMap;
import static com.google.common.base.Strings.isNullOrEmpty;
import static java.util.stream.Collectors.toList;
Expand Down
33 changes: 31 additions & 2 deletions src/main/java/bio/overture/songsearch/graphql/FileDataFetcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,15 @@

package bio.overture.songsearch.graphql;

import static bio.overture.songsearch.utils.JacksonUtils.convertValue;
import static java.util.stream.Collectors.toUnmodifiableList;

import bio.overture.songsearch.model.AggregationResult;
import bio.overture.songsearch.model.File;
import bio.overture.songsearch.model.SearchResult;
import bio.overture.songsearch.model.Sort;
import bio.overture.songsearch.service.FileService;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import graphql.schema.DataFetcher;
import java.util.List;
Expand All @@ -40,18 +47,40 @@ public FileDataFetcher(FileService fileService) {
}

@SuppressWarnings("unchecked")
public DataFetcher<List<File>> getFilesDataFetcher() {
public DataFetcher<SearchResult<File>> getFilesDataFetcher() {
return environment -> {
val args = environment.getArguments();

val filter = ImmutableMap.<String, Object>builder();
val page = ImmutableMap.<String, Integer>builder();
val sorts = ImmutableList.<Sort>builder();

if (args != null) {
if (args.get("filter") != null) filter.putAll((Map<String, Object>) args.get("filter"));
if (args.get("page") != null) page.putAll((Map<String, Integer>) args.get("page"));
if (args.get("sorts") != null) {
val rawSorts = (List<Object>) args.get("sorts");
sorts.addAll(
rawSorts.stream()
.map(sort -> convertValue(sort, Sort.class))
.collect(toUnmodifiableList()));
}
}
return fileService.searchFiles(filter.build(), page.build(), sorts.build());
};
}

@SuppressWarnings("unchecked")
public DataFetcher<AggregationResult> getAggregateFilesDataFetcher() {
return environment -> {
val args = environment.getArguments();

val filter = ImmutableMap.<String, Object>builder();

if (args != null) {
if (args.get("filter") != null) filter.putAll((Map<String, Object>) args.get("filter"));
}
return fileService.getFiles(filter.build(), page.build());
return fileService.aggregateFiles(filter.build());
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,14 @@ private RuntimeWiring buildWiring() {
.type(
newTypeWiring("Query")
.dataFetcher("analyses", analysisDataFetcher.getAnalysesDataFetcher()))
.type(
newTypeWiring("Query")
.dataFetcher(
"aggregateAnalyses", analysisDataFetcher.getAggregateAnalysesDataFetcher()))
.type(newTypeWiring("Query").dataFetcher("files", fileDataFetcher.getFilesDataFetcher()))
.type(
newTypeWiring("Query")
.dataFetcher("aggregateFiles", fileDataFetcher.getAggregateFilesDataFetcher()))
.type(
newTypeWiring("Query")
.dataFetcher(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package bio.overture.songsearch.model;

import lombok.Value;

@Value
public class AggregationResult {
Long totalHits;
}
6 changes: 6 additions & 0 deletions src/main/java/bio/overture/songsearch/model/Analysis.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ public class Analysis {

private Workflow workflow;

private String updatedAt;

private String publishedAt;

private String firstPublishedAt;

@SneakyThrows
public static Analysis parse(@NonNull Map<String, Object> sourceMap) {
return MAPPER.convertValue(sourceMap, Analysis.class);
Expand Down
22 changes: 22 additions & 0 deletions src/main/java/bio/overture/songsearch/model/SearchResult.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package bio.overture.songsearch.model;

import java.util.List;
import lombok.Value;

@Value
public class SearchResult<T> {
List<T> content;
Info info;

public SearchResult(List<T> content, Boolean hasNextFrom, Long totalHits) {
this.content = content;
this.info = new Info(hasNextFrom, totalHits, content.size());
}

@Value
public static class Info {
Boolean hasNextFrom;
Long totalHits;
Integer contentCount;
}
}
9 changes: 9 additions & 0 deletions src/main/java/bio/overture/songsearch/model/Sort.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package bio.overture.songsearch.model;

import lombok.Data;

@Data
public class Sort {
String fieldName;
String order;
}
Loading

0 comments on commit 24842f7

Please sign in to comment.