[BI-2806] Remove trials cache#516
Conversation
| return getTrialsFromBrAPI(program, trialQueryParams); | ||
| } | ||
|
|
||
| private Map<String, BrAPITrial> fetchProgramExperiments(UUID programId) throws ApiException { |
There was a problem hiding this comment.
Don't really love the way github is presenting this.
fetchProgramExperiments() is essentially what was called by the trialCache every time it was updated.
This method was removed completely along with the cache.
The "change" to this method is not really a change at all, this is a brand new method specifically for grabbing trials from BrAPI.
| return trials; | ||
| } | ||
|
|
||
| private List<BrAPITrial> getTrialsByExRef(String referenceSource, String referenceId, Program program) throws ApiException { |
There was a problem hiding this comment.
This method was unused and removed.
| } | ||
|
|
||
| public List<BrAPITrial> getExperiments(UUID programId) throws ApiException, DoesNotExistException { | ||
| // TODO: Edit this to filter/paginate trials |
| // get requested environments for the experiment | ||
| log.debug(logHash + ": fetching environments for export"); | ||
| List<BrAPIStudy> expStudies = studyDAO.getStudiesByExperimentID(experimentId, program); | ||
| List<BrAPIStudy> expStudies = studyDAO.getStudiesByExperimentID(UUID.fromString(expExRefId), program); |
There was a problem hiding this comment.
Study lookup will still occur on BI generated ID stored in exrefs. We can change this in this epic after we finish removing the cache for other entities. We will run into similar changes updating other entities in the process of removing the cache I'm sure.
There was a problem hiding this comment.
Link to epic just points to this PR
| // Make request to delete experiment. | ||
| trialDAO.deleteBrAPITrial(program, trial, hard); | ||
| // Get all lists for the trial. | ||
| // TODO: Get lists by trialDbId if trials get decoupled from datasets. |
There was a problem hiding this comment.
Lists still require the BI-API generated ID as well.
| .orElseThrow(() -> new IllegalStateException("No BI external reference found")) | ||
| .getReferenceID()); | ||
|
|
||
| study.trialDbId(Utilities.getExternalReference(study.getExternalReferences(), Utilities.generateReferenceSource(referenceSource, ExternalReferenceSource.TRIALS)) |
There was a problem hiding this comment.
This is kind of a get ahead of the curve change. It might be able to remain as is, but might be tough to find later on when we use trialDbIds directly for studies.
There was a problem hiding this comment.
Ya probably ok for poc but could cause confusing issues mixing deltabreed UUIDs and BrAPI UUIDs.
|
|
||
| // TODO: Remove for trialDbId once cache is removed for that entity | ||
| private void setDbIds(BrAPITrial trial) { | ||
| trial.trialDbId(Utilities.getExternalReference(trial.getExternalReferences(), Utilities.generateReferenceSource(referenceSource, ExternalReferenceSource.TRIALS)) |
There was a problem hiding this comment.
This was preventing the frontend effectively from being able to use brapiTrialDbIds in the router. Bit of a nasty bugger. Expecting more changes like this in the future for other entities.
There was a problem hiding this comment.
Another thing I think we'll need to resolve is having inconsistent UUIDs like using the BrAPI trialDbId here but then the DeltaBreed program UUID below.
| .getBrAPIObject() | ||
| .setTrialDbId(createdTrial.getTrialDbId()); | ||
| // TODO: May need to set the main ID for pending objects with the BrAPI ID for downstream usage once cache is removed. | ||
| trialByNameNoScope.get(createdTrialName) |
There was a problem hiding this comment.
I'm pretty sure we can live without this change. Originally I made this change to see if it would help the unit tests pick up the dbId in the workflow responses but to no avail.
| String.format("%s/%s", BRAPI_REFERENCE_SOURCE, ExternalReferenceSource.TRIALS.getName())) | ||
| .orElseThrow(() -> new InternalServerException("An Experiment ID was not found in any of the external references")); | ||
| UUID experimentId = UUID.fromString(experimentIDRef.getReferenceId()); | ||
| UUID experimentId = UUID.fromString(existingTrial.getTrialDbId()); |
There was a problem hiding this comment.
Originating caller of this method is never used. We might want to do away with this whole call stack at this point
|
I've tagged all developers to review this code since it's essentially the basis of changes that will need to be made throughout 1.5. This will be good for exposure to get familiar with this kind of code as we make changes to it. |
davedrp
left a comment
There was a problem hiding this comment.
Nicely documented. Thanks
|
I've added the |
HMS17
left a comment
There was a problem hiding this comment.
Looks good and seconding the nicely commented! Approved contingent on the todos getting cards associated with them before merging.
humsika
left a comment
There was a problem hiding this comment.
Everything looks good to me.
nickpalladino
left a comment
There was a problem hiding this comment.
Nice work, few comments, more thoughts than anything actionable other than possible future work. Do we already have cards to address the bi-api brapi endpoints like /observationunits?trialDbId. Currently that will use the passed in trialDbId for an exref filter in the brapi search but the /trials endpoint will return the trialDbId now instead of the deltabreed UUID so if that is used to retrieve the id the id won't match.
|
|
||
| // TODO: Remove for trialDbId once cache is removed for that entity | ||
| private void setDbIds(BrAPITrial trial) { | ||
| trial.trialDbId(Utilities.getExternalReference(trial.getExternalReferences(), Utilities.generateReferenceSource(referenceSource, ExternalReferenceSource.TRIALS)) |
There was a problem hiding this comment.
Another thing I think we'll need to resolve is having inconsistent UUIDs like using the BrAPI trialDbId here but then the DeltaBreed program UUID below.
| .orElseThrow(() -> new IllegalStateException("No BI external reference found")) | ||
| .getReferenceID()); | ||
|
|
||
| study.trialDbId(Utilities.getExternalReference(study.getExternalReferences(), Utilities.generateReferenceSource(referenceSource, ExternalReferenceSource.TRIALS)) |
There was a problem hiding this comment.
Ya probably ok for poc but could cause confusing issues mixing deltabreed UUIDs and BrAPI UUIDs.
| brapiProgramDbId = programDAO.getProgramBrAPI(program).getProgramDbId(); | ||
| } | ||
|
|
||
| // TODO: Configurable max amount of trials per program, or paginate. |
| } | ||
|
|
||
| @Override | ||
| public List<BrAPITrial> getTrialsByName(List<String> trialNames, Program program) throws ApiException { |
There was a problem hiding this comment.
We could probably add a card to update this to use a brapi search instead as a low priority
| @Inject | ||
| public BrAPITrialDAOImpl(ProgramCacheProvider programCacheProvider, | ||
| ProgramDAO programDAO, | ||
| public BrAPITrialDAOImpl(ProgramDAO programDAO, |
There was a problem hiding this comment.
Was kind of thinking we might be able to create a non-cache implementation of the DAO interface but see the interface changed and will have different assumptions about ids so probably not.
There was a problem hiding this comment.
I didn't feel the need to do that because there didn't seem a need to keep the cache implementation version around
Because it's related to the trial cache it might make more sense to make a bugfix for it. |
Description
Story: BI-2806
The body of changes in this MR effectively removes the cache implementation for BrAPITrials in bi-api.
There's quite a lot in here, so I'll try to sum up the important areas:
BrAPITrialDAOImpl was edited to
Various entities in need of relation to a trial were updated to use the bi-api generated trial ex ref id from the trial itself like Study, List. These can be changed after the cache is removed
Fixed some instances where certain controllers automatically updated the BrAPITrialDbId in the entity to the bi generated id, which was breaking compatability.
Unit tests were updated to support the changes. Many of these unit tests depended on the bi-api generated uuid from the workflow response to pass through to methods which validated everything. This doesn't really work with the cache gone for trials because now it needs to validate on the trialDbId for the created record. Tests have been updated to grab these IDs from the brapiDb once the workflows complete.
Dependencies
bi-web
Testing
Regression on just about anything Experiment related, including:
Verify there are no log messages related to caching trials for a program by looking at logs once above tests have been completed.
Checklist: