/** * Signals if this experiment is deleted. * * @return <code>true</code> if state == DELETED, <code>false</code> otherwise */ @JsonIgnore public boolean isDeleted() { return state.equals(State.DELETED); }
/** * Signals if this experiment is deleted. * * @return <code>true</code> if state == DELETED, <code>false</code> otherwise */ @JsonIgnore public boolean isDeleted() { return state.equals(Experiment.State.DELETED); }
/** * Signals if this experiment allows to make changes to its data. This is * the case if the current state is DRAFT. * * @return <code>true</code> if changes are valid, <code>false</code> otherwise */ @JsonIgnore public boolean isChangeable() { return state.equals(DRAFT) || state.equals(RUNNING) || state.equals(PAUSED); }
/** * Retrieves the analytics data for the buckets and the experiment itself. * * @param experimentDetail the {@link ExperimentDetail} that needs to be enhanced with analytics data * @param params {@link Parameters} for the Analytics calls- containing the context for example * @return the same object with additional analytic information */ ExperimentDetail getAnalyticData(ExperimentDetail experimentDetail, Parameters params) { // analytics data is only necessary for running/paused/terminated experiments if (!experimentDetail.getState().equals(Experiment.State.DRAFT)) { //experiment level analytics AssignmentCounts assignmentCounts = analytics.getAssignmentCounts(experimentDetail.getId(), params.getContext()); if (!Objects.isNull(assignmentCounts)) { long onlyBucketAssignments = assignmentCounts.getTotalUsers().getBucketAssignments(); experimentDetail.setTotalNumberUsers(onlyBucketAssignments); } ExperimentStatistics expStats = analytics.getExperimentStatistics(experimentDetail.getId(), params); getBucketDetails(experimentDetail, expStats, assignmentCounts); } return experimentDetail; }
/** * {@inheritDoc} */ @Override public void checkStateTransition(Experiment.ID experimentID, Experiment.State currentState, Experiment.State desiredState) { if (desiredState != null && !currentState.equals(desiredState)) { // Throw an exception if the StateTransition is invalid validator.validateStateTransition(currentState, desiredState); /* If moving from a DRAFT state to a RUNNING state a sanity-check is required on the experiment buckets. Fetch the bucket information if the experiment will be (or remain) in an active state (running, paused) because that info is used to create the KV-store entry. * */ if (currentState.equals(DRAFT) && desiredState.equals(RUNNING)) { // Throw an exception if the sanity-check fails BucketList bucketList = buckets.getBuckets(experimentID, false /* don't check experiment again */); validator.validateExperimentBuckets(bucketList.getBuckets()); } } }
/** * {@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); } }
/** * Calculates the last day of the experiment. * <p> * This is generally the experiment end date, but may be an earlier date if * the experiment was TERMINATED early. In this case the modification date * is used. * * @return earliestDay */ @JsonIgnore public DateMidnight calculateLastDay() { DateMidnight earliestDay = new DateMidnight(endTime); if (state.equals(State.TERMINATED)) { DateMidnight modifiedDay = new DateMidnight(modificationTime); if (modifiedDay.isBefore(earliestDay)) { earliestDay = modifiedDay; } } return earliestDay; }
public void validateExperiment(Experiment experiment) { Experiment.State state = experiment.getState(); if (state.equals(Experiment.State.DELETED) || state.equals(Experiment.State.TERMINATED)) { return; } validateLabel(experiment.getLabel()); validateExperimentStartEnd(experiment.getStartTime(), experiment.getEndTime()); validateSamplingPercent(experiment.getSamplingPercent()); validateExperimentRule(experiment.getRule()); validateModelNameNotNullForPersonalizedExperiments(experiment.getIsPersonalizationEnabled() , experiment.getModelName()); }
private void validateExperimentState(Experiment experiment) { Experiment.State state = experiment.getState(); if (!(state.equals(Experiment.State.PAUSED) || state.equals(Experiment.State.RUNNING) || state.equals(Experiment.State.DRAFT))) { Set<Experiment.State> desiredStates = new HashSet<>(); desiredStates.add(Experiment.State.DRAFT); desiredStates.add(Experiment.State.PAUSED); desiredStates.add(Experiment.State.RUNNING); throw new InvalidExperimentStateException(experiment.getID(), desiredStates, experiment.getState()); } }
private void checkBucketConstraint(Experiment experiment, Bucket newBucket) { Bucket test = cassandraRepository.getBucket(newBucket.getExperimentID(), newBucket.getLabel()); if (test != null) { throw new ConstraintViolationException(ConstraintViolationException.Reason.UNIQUE_CONSTRAINT_VIOLATION, "Bucket label must be unique within an experiment", null); } if (!experiment.getState().equals(Experiment.State.DRAFT) && newBucket.isControl() != null && newBucket.isControl()) { throw new ConstraintViolationException(ConstraintViolationException.Reason.APPLICATION_CONSTRAINT_VIOLATION, "Bucket added to a running experiment may not be a control bucket", null); } }
/** * Checks that an experiment has a state "draft" and throws an exception * if it doesn't * * @param experiment Experiment object containing experiment metadata */ public void ensureStateIsDraft(Experiment experiment) { Experiment.State state = experiment.getState(); if (!state.equals(Experiment.State.DRAFT)) { throw new InvalidExperimentStateException(experiment.getID(), Experiment.State.DRAFT, experiment.getState()); } }
/** * Signals if this experiment is deleted. * * @return <code>true</code> if state == DELETED, <code>false</code> otherwise */ @JsonIgnore public boolean isDeleted() { return state.equals(State.DELETED); }
/** * Signals if this experiment allows to make changes to its data. This is * the case if the current state is DRAFT. * * @return <code>true</code> if changes are valid, <code>false</code> otherwise */ @JsonIgnore public boolean isChangeable() { return state.equals(DRAFT) || state.equals(RUNNING) || state.equals(PAUSED); }
private void setState(Experiment.State state) { if (state != null && !Experiment.State.DELETED.equals(state)) this.state = state; else throw new IllegalArgumentException("Experiment.State is not allowed to be null or DELETED for ExperimentDetail"); }
/** * Signals if this experiment is deleted. * * @return <code>true</code> if state == DELETED, <code>false</code> otherwise */ @JsonIgnore public boolean isDeleted() { return state.equals(Experiment.State.DELETED); }
/** * Calculates the last day of the experiment. * <p> * This is generally the experiment end date, but may be an earlier date if * the experiment was TERMINATED early. In this case the modification date * is used. * * @return earliestDay */ @JsonIgnore public DateMidnight calculateLastDay() { DateMidnight earliestDay = new DateMidnight(endTime); if (state.equals(State.TERMINATED)) { DateMidnight modifiedDay = new DateMidnight(modificationTime); if (modifiedDay.isBefore(earliestDay)) { earliestDay = modifiedDay; } } return earliestDay; }
public void validateExperiment(Experiment experiment) { Experiment.State state = experiment.getState(); if (state.equals(Experiment.State.DELETED) || state.equals(Experiment.State.TERMINATED)) { return; } validateLabel(experiment.getLabel()); validateExperimentStartEnd(experiment.getStartTime(), experiment.getEndTime()); validateSamplingPercent(experiment.getSamplingPercent()); validateExperimentRule(experiment.getRule()); validateModelNameNotNullForPersonalizedExperiments(experiment.getIsPersonalizationEnabled() , experiment.getModelName()); }
/** * Checks that an experiment has a state "draft" and throws an exception * if it doesn't * * @param experiment Experiment object containing experiment metadata */ public void ensureStateIsDraft(Experiment experiment) { Experiment.State state = experiment.getState(); if (!state.equals(Experiment.State.DRAFT)) { throw new InvalidExperimentStateException(experiment.getID(), Experiment.State.DRAFT, experiment.getState()); } }