From fca1b3943d21880c764ff20333664b9970398baa Mon Sep 17 00:00:00 2001 From: Luke Sikina Date: Wed, 10 Jan 2024 11:40:35 -0500 Subject: [PATCH] [ALS-5656] Make TimeSeriesProcessor handle missing concept paths - In GIC land, we get queries that have a concept path that is present in some other site, but not the one the query is getting run in - The TimeseriesProcessor needs to not explode when this happens --- .../avillach/hpds/processing/AbstractProcessor.java | 13 +++++++++++++ .../hpds/processing/TimeseriesProcessor.java | 7 ++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/AbstractProcessor.java b/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/AbstractProcessor.java index 6323a400..c8a06b15 100644 --- a/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/AbstractProcessor.java +++ b/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/AbstractProcessor.java @@ -667,6 +667,19 @@ protected PhenoCube getCube(String path) { } } + /** + * Get a cube without throwing an error if not found. + * Useful for federated pic-sure's where there are fewer + * guarantees about concept paths. + */ + protected Optional> nullableGetCube(String path) { + try { + return Optional.ofNullable(store.get(path)); + } catch (ExecutionException e) { + return Optional.empty(); + } + } + public TreeMap getDictionary() { return phenotypeMetaStore.getMetaStore(); } diff --git a/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/TimeseriesProcessor.java b/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/TimeseriesProcessor.java index dee9246e..e751901c 100644 --- a/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/TimeseriesProcessor.java +++ b/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/TimeseriesProcessor.java @@ -103,11 +103,12 @@ private void addDataForConcepts(Collection pathList, Set exporte continue; } ArrayList dataEntries = new ArrayList(); - PhenoCube cube = abstractProcessor.getCube(conceptPath); - if(cube == null) { - log.warn("Attempting export of non-existant concept: " + conceptPath); + Optional> maybeCube = abstractProcessor.nullableGetCube(conceptPath); + if(maybeCube.isEmpty()) { + log.warn("Attempting export of non-existant concept: {}", conceptPath); continue; } + PhenoCube cube = maybeCube.get(); log.debug("Exporting " + conceptPath); List valuesForKeys = cube.getValuesForKeys(idList); for (Object kvObj : valuesForKeys) {