Package ai.libs.jaicore.experiments
Interface IExperimentDatabaseHandle
-
- All Known Implementing Classes:
AExperimenterSQLHandle
,ExperimenterMySQLHandle
public interface IExperimentDatabaseHandle
This interface is used by the ExperimentRunner to get, create, and update experiment entries.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description ExperimentDBEntry
createAndGetExperiment(Experiment experiment)
Creates a new experiment entry and returns it.java.util.List<ExperimentDBEntry>
createAndGetExperiments(java.util.List<Experiment> experiments)
Creates a new experiment entry and returns it.void
deleteDatabase()
Deletes everything known to the experiment database.void
deleteExperiment(ExperimentDBEntry exp)
Deletes an experiment from the databasevoid
finishExperiment(ExperimentDBEntry exp)
Signals that an experiment has been finished successfully.void
finishExperiment(ExperimentDBEntry exp, java.lang.Throwable errror)
Signals that an experiment has failed with an exception.java.util.List<ExperimentDBEntry>
getAllExperiments()
Returns a list of all experiments contained in the databasejava.util.List<ExperimentDBEntry>
getConductedExperiments()
Returns a list of all experiments contained in the database marked as being conducted.java.util.Collection<java.lang.String>
getConsideredValuesForKey(java.lang.String key)
ExperimentDBEntry
getExperimentWithId(int id)
Gets the experiment with the given id.int
getNumberOfAllExperiments()
Returns a list of all experiments contained in the databasejava.util.List<ExperimentDBEntry>
getOpenExperiments()
Returns a list of all experiments contained in the database that have not been started yet.java.util.List<ExperimentDBEntry>
getRandomOpenExperiments(int limit)
Returns a list of all experiments contained in the database that have not been started yet.java.util.List<ExperimentDBEntry>
getRunningExperiments()
Returns a list of all experiments that are currently being conducted.void
setup(IExperimentSetConfig config)
Prepares everything so that upcoming calls for create and update will be managed according to the specified configuration.void
startExperiment(ExperimentDBEntry exp)
Updates non-keyfield values of the experiment.void
updateExperiment(ExperimentDBEntry exp, java.util.Map<java.lang.String,? extends java.lang.Object> values)
Updates non-keyfield values of the experiment.boolean
updateExperimentConditionally(ExperimentDBEntry exp, java.util.Map<java.lang.String,java.lang.String> conditions, java.util.Map<java.lang.String,? extends java.lang.Object> values)
-
-
-
Method Detail
-
setup
void setup(IExperimentSetConfig config) throws ExperimentDBInteractionFailedException
Prepares everything so that upcoming calls for create and update will be managed according to the specified configuration.- Parameters:
config
- Description of the experiment setup- Throws:
ExperimentDBInteractionFailedException
-
getConsideredValuesForKey
java.util.Collection<java.lang.String> getConsideredValuesForKey(java.lang.String key) throws ExperimentDBInteractionFailedException
- Parameters:
key
- The key attribute- Throws:
ExperimentDBInteractionFailedException
-
getAllExperiments
java.util.List<ExperimentDBEntry> getAllExperiments() throws ExperimentDBInteractionFailedException
Returns a list of all experiments contained in the database- Returns:
- List of all experiments
- Throws:
ExperimentDBInteractionFailedException
-
getNumberOfAllExperiments
int getNumberOfAllExperiments() throws ExperimentDBInteractionFailedException
Returns a list of all experiments contained in the database
-
getConductedExperiments
java.util.List<ExperimentDBEntry> getConductedExperiments() throws ExperimentDBInteractionFailedException
Returns a list of all experiments contained in the database marked as being conducted.- Returns:
- List of all experiments conducted so far
- Throws:
ExperimentDBInteractionFailedException
-
getOpenExperiments
java.util.List<ExperimentDBEntry> getOpenExperiments() throws ExperimentDBInteractionFailedException
Returns a list of all experiments contained in the database that have not been started yet.- Returns:
- List of all experiments conducted so far
- Throws:
ExperimentDBInteractionFailedException
-
getRandomOpenExperiments
java.util.List<ExperimentDBEntry> getRandomOpenExperiments(int limit) throws ExperimentDBInteractionFailedException
Returns a list of all experiments contained in the database that have not been started yet.- Parameters:
limit
- Maximum number of open experiments that should be returned- Returns:
- List of all experiments conducted so far
- Throws:
ExperimentDBInteractionFailedException
-
getRunningExperiments
java.util.List<ExperimentDBEntry> getRunningExperiments() throws ExperimentDBInteractionFailedException
Returns a list of all experiments that are currently being conducted.- Returns:
- List of all experiments conducted so far
- Throws:
ExperimentDBInteractionFailedException
-
getExperimentWithId
ExperimentDBEntry getExperimentWithId(int id) throws ExperimentDBInteractionFailedException
Gets the experiment with the given id.- Parameters:
id
-- Returns:
- Throws:
ExperimentDBInteractionFailedException
-
createAndGetExperiment
ExperimentDBEntry createAndGetExperiment(Experiment experiment) throws ExperimentDBInteractionFailedException, ExperimentAlreadyExistsInDatabaseException
Creates a new experiment entry and returns it.- Parameters:
experiment
-- Returns:
- The id of the created experiment
- Throws:
ExperimentDBInteractionFailedException
ExperimentAlreadyExistsInDatabaseException
-
createAndGetExperiments
java.util.List<ExperimentDBEntry> createAndGetExperiments(java.util.List<Experiment> experiments) throws ExperimentDBInteractionFailedException, ExperimentAlreadyExistsInDatabaseException
Creates a new experiment entry and returns it.- Parameters:
experiments
- the experiments to be created- Returns:
- The id of the created experiment
- Throws:
ExperimentDBInteractionFailedException
ExperimentAlreadyExistsInDatabaseException
-
startExperiment
void startExperiment(ExperimentDBEntry exp) throws ExperimentAlreadyStartedException, ExperimentUpdateFailedException
Updates non-keyfield values of the experiment.- Parameters:
exp
- The experiment that is started on the current machine- Throws:
ExperimentUpdateFailedException
ExperimentAlreadyStartedException
-
updateExperiment
void updateExperiment(ExperimentDBEntry exp, java.util.Map<java.lang.String,? extends java.lang.Object> values) throws ExperimentUpdateFailedException
Updates non-keyfield values of the experiment.- Parameters:
exp
- The experiment entry in the databasevalues
- A key-value store where keys are names of result fields. The values will be associated to each key in the database.- Throws:
ExperimentUpdateFailedException
-
updateExperimentConditionally
boolean updateExperimentConditionally(ExperimentDBEntry exp, java.util.Map<java.lang.String,java.lang.String> conditions, java.util.Map<java.lang.String,? extends java.lang.Object> values) throws ExperimentUpdateFailedException
- Throws:
ExperimentUpdateFailedException
-
finishExperiment
void finishExperiment(ExperimentDBEntry exp) throws ExperimentDBInteractionFailedException
Signals that an experiment has been finished successfully. A corresponding timestamp will be attached to the experiment entry.- Parameters:
exp
-- Throws:
ExperimentDBInteractionFailedException
-
finishExperiment
void finishExperiment(ExperimentDBEntry exp, java.lang.Throwable errror) throws ExperimentDBInteractionFailedException
Signals that an experiment has failed with an exception. The timestamp and the exception will be stored with the experiment.- Parameters:
exp
-errror
-- Throws:
ExperimentDBInteractionFailedException
-
deleteExperiment
void deleteExperiment(ExperimentDBEntry exp) throws ExperimentDBInteractionFailedException
Deletes an experiment from the database- Parameters:
exp
-- Throws:
ExperimentDBInteractionFailedException
-
deleteDatabase
void deleteDatabase() throws ExperimentDBInteractionFailedException
Deletes everything known to the experiment database. Note that database is understood as an abstract term. In a true database, this could just be a table.
-
-