/** * Get the experiment object for given application & experiment label. * <p> * If metadata cache is enabled then fetch from cache else fetch from database. * * @param applicationName * @param experimentLabel * @return experiment object */ protected Experiment getExperiment(Application.Name applicationName, Experiment.Label experimentLabel) { Experiment result = null; if (metadataCacheEnabled) { //First fetch experiment list sorted by priorities (contains non-deleted experiment-ids). //This experiment-priority list is the source of truth for ALL assignment flows while looking up experiment... Optional<PrioritizedExperimentList> prioritizedExperimentListOptional = metadataCache.getPrioritizedExperimentListMap(applicationName); if (prioritizedExperimentListOptional.isPresent()) { //Iterate as per experiment priority and look for the matching experiment by their label for (PrioritizedExperiment prioritizedExperiment : prioritizedExperimentListOptional.get().getPrioritizedExperiments()) { if (experimentLabel.equals(prioritizedExperiment.getLabel())) { //Upon match, get the complete experiment object from cache result = metadataCache.getExperimentById(prioritizedExperiment.getID()).orElse(null); break; } } } } else { result = repository.getExperiment(applicationName, experimentLabel); } return result; }
"Cannot change application name when the experiment is in TERMINATED state"); if (updates.getLabel() != null && !updates.getLabel().equals(experiment.getLabel())) { throw new IllegalArgumentException("Invalid label \"" + updates.getLabel() + "\" " + "Cannot change label when the experiment is in TERMINATED state");
/** * {@inheritDoc} */ @Override public void checkForIllegalPausedRunningUpdate(Experiment experiment, Experiment updates) { /* Throw an exception if the experiment is in RUNNING/PAUSED state and if applicationName or Label is being updated. Also, if startTime/endTime is being updated with a value that has already passed or when the established startTime/endTime has already passed. */ if (experiment.getState().equals(RUNNING) || experiment.getState().equals(PAUSED)) { if (updates.getApplicationName() != null && !updates.getApplicationName().equals(experiment.getApplicationName())) throw new IllegalArgumentException("Cannot change AppName when the experiment is not in DRAFT state"); if (updates.getLabel() != null && !updates.getLabel().equals(experiment.getLabel())) throw new IllegalArgumentException("Cannot change Label when the experiment is not in DRAFT state"); if (updates.getStartTime() != null && !updates.getStartTime().equals(experiment.getStartTime())) checkForIllegalExperimentStartTime(experiment, updates); if (updates.getEndTime() != null && !updates.getEndTime().equals(experiment.getEndTime())) checkForIllegalExperimentEndTime(experiment, updates); } }
if (updates.getLabel() != null && !updates.getLabel().equals(experiment.getLabel())) { builder.withLabel(updates.getLabel()); requiresUpdate = true;