Skip to content

Commit

Permalink
Merge pull request #2314 from opencb/TASK-4770
Browse files Browse the repository at this point in the history
TASK-4770 Error running migration calculate_pedigree_graph
  • Loading branch information
jtarraga committed Oct 4, 2023
2 parents 469c293 + 56b67e1 commit ed3533e
Showing 1 changed file with 20 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,28 @@ public class CalculatePedigreeGraphMigration extends MigrationTool {
protected void run() throws Exception {
MigrationRun migrationRun = getMigrationRun();

// Map study studyFqn -> job
Map<String, Job> jobs = new HashMap<>();
for (JobReferenceParam jobReference : migrationRun.getJobs()) {
Job job = catalogManager.getJobManager().get(jobReference.getStudyId(), jobReference.getId(), new QueryOptions(), token)
.first();
logger.info("Registering job {} for study {} to migrate", job.getId(), job.getStudy().getId());
logger.info("Reading already executed job '{}' for study '{}' with status '{}'",
job.getId(),
job.getStudy().getId(),
job.getInternal().getStatus().getId());
jobs.put(job.getStudy().getId(), job);
}
for (String study : getStudies()) {

Set<String> studies = new LinkedHashSet<>(getStudies());
logger.info("Study IDs (num. total = {}) to initialize pedigree graphs: {}", studies.size(), StringUtils.join(studies, ", "));

// Ensure that studies with already executed jobs are included in the migration run
getMigrationRun().getJobs().forEach(j -> studies.add(j.getStudyId()));

logger.info("Study IDs (num. total = {}) after adding studies from migration jobs: {}", studies.size(),
StringUtils.join(studies, ", "));

for (String study : studies) {
Job job = jobs.get(study);
if (job != null) {
String status = job.getInternal().getStatus().getId();
Expand All @@ -61,8 +75,9 @@ protected void run() throws Exception {
logger.info("Adding new job to migrate/initialize pedigree graph for study {}", study);
ObjectMap params = new ObjectMap()
.append(ParamConstants.STUDY_PARAM, study);
getMigrationRun().addJob(catalogManager.getJobManager().submit(study, PedigreeGraphInitAnalysis.ID, Enums.Priority.MEDIUM,
params, null, null, null, new ArrayList<>(), token).first());
Job newJob = catalogManager.getJobManager().submit(study, PedigreeGraphInitAnalysis.ID, Enums.Priority.MEDIUM,
params, null, null, null, new ArrayList<>(), token).first();
getMigrationRun().addJob(newJob);
}
}

Expand All @@ -73,7 +88,7 @@ public List<String> getStudies() throws CatalogException {
for (Project project : catalogManager.getProjectManager().search(new Query(), projectOptions, token).getResults()) {
if (CollectionUtils.isNotEmpty(project.getStudies())) {
for (Study study : project.getStudies()) {
String id = project.getId() + ":" + study.getId();
String id = study.getFqn();
for (Family family : catalogManager.getFamilyManager().search(id, new Query(), familyOptions, token).getResults()) {
if (PedigreeGraphUtils.hasMinTwoGenerations(family)
&& (family.getPedigreeGraph() == null || StringUtils.isEmpty(family.getPedigreeGraph().getBase64()))) {
Expand Down

0 comments on commit ed3533e

Please sign in to comment.