Skip to content

Commit

Permalink
TEMPO additional logging (#1142) (#1153)
Browse files Browse the repository at this point in the history
Added extra logging to help with debugging.
Additonal logs also report whether a cohort attempts to import with
  samples that are unknown to SMILE. The cohort is still imported but incompletely.

Signed-off-by: Angelica Ochoa <[email protected]>
  • Loading branch information
ao508 authored Apr 25, 2024
1 parent b90e4d5 commit aa38403
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.mskcc.smile.model.SmileRequest;
import org.mskcc.smile.model.SmileSample;
import org.mskcc.smile.model.internal.CrdbMappingModel;
import org.mskcc.smile.model.tempo.Tempo;
import org.mskcc.smile.model.web.PublishedSmileSample;
import org.mskcc.smile.model.web.SmileSampleIdMapping;
import org.mskcc.smile.persistence.neo4j.SmileSampleRepository;
Expand All @@ -27,6 +28,7 @@
import org.mskcc.smile.service.TempoService;
import org.mskcc.smile.service.util.SampleDataFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.IncorrectResultSizeDataAccessException;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

Expand Down Expand Up @@ -411,7 +413,22 @@ public SmileSample getDetailedSmileSample(SmileSample sample) throws Exception {
SmilePatient patient = patientService.getPatientByCmoPatientId(cmoPatientId);
sample.setPatient(patient);
sample.setSampleAliases(sampleRepository.findAllSampleAliases(sample.getSmileSampleId()));
sample.setTempo(tempoService.getTempoDataBySampleId(sample));
// not every sample is expected to have tempo data
try {
Tempo tempo = tempoService.getTempoDataBySampleId(sample);
sample.setTempo(tempo);
} catch (IncorrectResultSizeDataAccessException e) {
if (e.getActualSize() < 0) {
LOG.warn("There is no TEMPO data for sample: " + sample.getPrimarySampleAlias());
} else {
StringBuilder b = new StringBuilder();
b.append("Error fetching TEMPO data for sample: ")
.append(sample.getPrimarySampleAlias())
.append(" - actual size '").append(e.getActualSize())
.append("' does not match expected size '").append(e.getExpectedSize()).append("'");
LOG.error(b.toString(), e);
}
}
return sample;
}

Expand Down Expand Up @@ -479,13 +496,13 @@ public Boolean sampleExistsByPrimaryId(String primaryId) {
public List<SmileSample> getSamplesByCohortId(String cohortId) throws Exception {
List<SmileSample> samples = sampleRepository.findSamplesByCohortId(cohortId);

List<SmileSample> detailedSamples = new ArrayList<>();
List<SmileSample> detailedSamples = new ArrayList<>();
for (SmileSample s: samples) {
detailedSamples.add(getDetailedSmileSample(s));
}
return detailedSamples;
}

private List<SampleMetadata> getSampleMetadataWithStatus(List<SampleMetadata> smList) {
for (SampleMetadata sm : smList) {
sm.setStatus(sampleRepository.findStatusForSampleMetadataById(sm.getId()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ public Tempo saveTempoData(Tempo tempo) throws Exception {
}

@Override
@Transactional(rollbackFor = {Exception.class})
public Tempo getTempoDataBySampleId(SmileSample smileSample) throws Exception {
Tempo tempo = tempoRepository.findTempoBySmileSampleId(smileSample.getSmileSampleId());
if (tempo == null) {
Expand All @@ -62,7 +61,6 @@ public Tempo getTempoDataBySampleId(SmileSample smileSample) throws Exception {
}

@Override
@Transactional(rollbackFor = {Exception.class})
public Tempo getTempoDataBySamplePrimaryId(String primaryId) throws Exception {
Tempo tempo = tempoRepository.findTempoBySamplePrimaryId(primaryId);
if (tempo == null) {
Expand Down

0 comments on commit aa38403

Please sign in to comment.