Defining a Experiment¶
As every experiment must inherit from the
versuchung.experiment.Experiment class their attributes and methods are absolutly basic to versuchung.
Experiment(default_experiment_instance=None, title=None, inputs=None, outputs=None)¶
Can be used as: input parameter
A experiment can also executed by calling it,
executewill be called.
__init__(default_experiment_instance=None, title=None, inputs=None, outputs=None)¶
The constructor of an experiment just fills in the necessary attributes but has no sideeffects on the outside world.
Parameters: default_experiment_instance (str.) – If used as input parameter, this is the default result set used. For example
Calling this method will execute the experiment
Parameters: args (list.) – The command line arguments, normally
Kwargs: The keyword arguments can be used to overwrite the default values of the experiment, without assembling a command line.
The normal mode of operation is to give
But with keyword arguments the following two expression result in the same result set:
>>> experiment.execute(["--input_parameter", "foo"]) >>> experiment.execute(input_parameter="foo")
This method is invocated on the dict which is stored in $result_dir/metadata before the result_hash is calculated. This helps to take influence on the input parameters which alter the experiment hash. So use it with care.
Can be implemented by the user.
In the input dictionary all input parameters are defined. They may and will influence the metadata and the metadata hash. Only objects which are marked as input parameters may be used here. The key in this
dictis used as
nameattribute and propagated to the parameters. From these input parameters the command line interface is created.
>>> self.inputs["string_parameter"] <versuchung.types.String object at 0xb73fabec> >>> self.inputs.string_parameter <versuchung.types.String object at 0xb73fabec> >>> self.i.string_parameter <versuchung.types.String object at 0xb73fabec>
Return the metadata as python dict. This works for experiments, which are running at the moment, and for already finished experiments by reading the /metadata file.
The name of the object. This is in execution mode (Experiment instance is the executed experiment) the result set name (str). When the experiment is used as input parameter it is the key-value in the
Similar to the
inputsattribute, in the output dictionary all experiment results are defined. Only objects that are explicitly marked as output parameters can be used here.
>>> self.inputs["experiment"].outputs["out_file"] <versuchung.types.File object at 0xb736220c> >>> self.i.experiment.o.out_file <versuchung.types.File object at 0xb736220c>
This method is the heart of every experiment and must be implemented by the user. It is called when the experiment is executed. Before all input parameters are parsed, the output directory is set up. Afterwards all temporary data is removed and the output parameters are deinitialized.
Must be implemented by the user.
Title of the experiment, this is normally the classname
Version of the experiment, defaults to 1. The version is included in the metadata and used for the metadata hash.