Skip to content

SCRUM-4817 put Model entities into ES #1311

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

Open
wants to merge 2 commits into
base: stage
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
package org.alliancegenome.indexer.config;

import org.alliancegenome.indexer.indexers.AlleleIndexer;
import org.alliancegenome.indexer.indexers.DatasetIndexer;
import org.alliancegenome.indexer.indexers.DiseaseIndexer;
import org.alliancegenome.indexer.indexers.GeneIndexer;
import org.alliancegenome.indexer.indexers.GoIndexer;
import org.alliancegenome.indexer.indexers.ModelIndexer;
import org.alliancegenome.indexer.indexers.*;
import org.alliancegenome.indexer.indexers.curation.DiseaseAnnotationCurationIndexer;
import org.alliancegenome.indexer.indexers.curation.DiseaseSummaryCurationIndexer;
import org.alliancegenome.indexer.indexers.curation.GeneGeneticInteractionCurationIndexer;
Expand Down Expand Up @@ -33,6 +28,7 @@ public enum IndexerConfig {
PhenotypeAnnotationIndexer("phenotypeAnnotation", PhenotypeAnnotationCurationIndexer.class, 4, 1500, 1500, 2, 1),
ReleaseInfoIndexer("release", ReleaseInfoIndexer.class, 1, 1, 1, 1, 1),
DiseaseSummaryIndexer("diseaseSummary", DiseaseSummaryCurationIndexer.class, 4, 1500, 1500, 4, 1),
AffectedGenomicModelIndexer("affectedGenomicModels", AffectedGenomicModelIndexer.class, 30, 1500, 1500, 4, 1),
GeneToGeneOrthologyIndexer("geneToGeneOrthology", GeneToGeneOrthologyIndexer.class, 4, 1500, 1500, 8, 1),
//GeneExpressionAnnotationIndexer("geneExpressionAnnotation", GeneExpressionAnnotationIndexer.class, 4, 1500, 1500, 2, 1),
//GeneSearchResultCurationIndexer("geneSearchResult", GeneSearchResultCurationIndexer.class, 4, 250, 1000, 4, 1),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package org.alliancegenome.indexer.indexers;

import lombok.extern.slf4j.Slf4j;
import org.alliancegenome.curation_api.model.document.es.AffectedGenomicModelDocument;
import org.alliancegenome.curation_api.response.SearchResponse;
import org.alliancegenome.es.util.ProcessDisplayHelper;
import org.alliancegenome.indexer.config.IndexerConfig;
import org.alliancegenome.indexer.indexers.curation.service.ModelService;
import org.apache.commons.collections4.CollectionUtils;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.concurrent.LinkedBlockingDeque;

@Slf4j
public class AffectedGenomicModelIndexer extends Indexer {

private final ModelService service = new ModelService();

public AffectedGenomicModelIndexer(IndexerConfig config) {
super(config);
}

private ProcessDisplayHelper display = new ProcessDisplayHelper(2000);
private int totalRecords;

@Override
public void index() {
try {
Set<String> allModelIds = service.getAllModelIds();
LinkedBlockingDeque<String> queue = new LinkedBlockingDeque<>(allModelIds);
display.startProcess("Pulling Affective Genomic Model Documents", queue.size());
totalRecords = allModelIds.size();
initiateThreading(queue);
} catch (Exception e) {
log.error("Error while indexing...", e);
System.exit(-1);
}
}

protected void startSingleThread(LinkedBlockingDeque<String> queue) {
List<AffectedGenomicModelDocument> list = new ArrayList<>();
while (true) {
try {
if (list.size() >= indexerConfig.getBufferSize()) {
indexDocuments(list);
list.clear();
}
if (queue.isEmpty()) {
if (list.size() > 0) {
indexDocuments(list);
list.clear();
}
return;
}

String key = queue.takeFirst();
SearchResponse<AffectedGenomicModelDocument> response = service.getModelDocument(key);
if (CollectionUtils.isEmpty(response.getResults())) {
log.debug("No model found for " + key);
continue;
}
list.addAll(response.getResults());
display.progressProcess((long) (response.getResults().size()));
} catch (Exception e) {
log.error("Error while indexing...", e);
System.exit(-1);
return;
}
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package org.alliancegenome.indexer.indexers.curation.interfaces;

import com.fasterxml.jackson.annotation.JsonView;
import jakarta.ws.rs.*;
import jakarta.ws.rs.core.MediaType;
import org.alliancegenome.curation_api.model.document.es.AffectedGenomicModelDocument;
import org.alliancegenome.curation_api.response.SearchResponse;
import org.alliancegenome.curation_api.view.View;

import java.util.HashMap;

@Path("/model")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public interface GeneModelInterface {
@POST
@Path("/gene-documents")
@JsonView({View.ForPublic.class})
SearchResponse<AffectedGenomicModelDocument> findForPublic(
@DefaultValue("0") @QueryParam("page") Integer page,
@DefaultValue("10") @QueryParam("limit") Integer limit,
HashMap<String, Object> params);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be removed and we use the one in curation.

Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package org.alliancegenome.indexer.indexers.curation.service;

import com.fasterxml.jackson.databind.ObjectMapper;
import org.alliancegenome.core.config.ConfigHelper;
import org.alliancegenome.curation_api.model.document.es.AffectedGenomicModelDocument;
import org.alliancegenome.curation_api.response.SearchResponse;
import org.alliancegenome.indexer.RestConfig;
import org.alliancegenome.indexer.indexers.curation.interfaces.GeneModelInterface;
import si.mazi.rescu.RestProxyFactory;

import java.util.HashMap;
import java.util.Set;

public class ModelService extends BaseService {

protected ObjectMapper mapper = RestConfig.config.getJacksonObjectMapperFactory().createObjectMapper();

private final GeneModelInterface modelApi = RestProxyFactory.createProxy(GeneModelInterface.class, ConfigHelper.getCurationApiUrl(), RestConfig.config);

public Set<String> getAllGeneIds() {
return getAllNeoAlleleIDs();
}

public Set<String> getAllModelIds() {
return getAllNeoModelIDs();
}

public SearchResponse<AffectedGenomicModelDocument> getModelDocument(String modelId) {
HashMap<String, Object> params = new HashMap<>();
params.put("primaryExternalId", modelId);
return modelApi.findForPublic(0, 1, params);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we we pulling these in batches from curation. As one at time I would think is going to be slow.

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public void progressProcess(String data, long amount) {

double percent = 0;
if (totalSize > 0) {
percent = sizeCounter.get() / totalSize;
percent = ((double) sizeCounter.get() / (double) totalSize);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.coding.UnnecessaryParenthesesCheck> reported by reviewdog 🐶
Unnecessary parentheses around assignment right-hand side.

}
long processedAmount = sizeCounter.get() - lastSizeCounter;
StringBuffer sb = new StringBuffer(this.message);
Expand Down
Loading