Search Result Sets as Input Parameters

In large experiment setups it is challenging to keep track of all result sets that are floating around. This is especially true if you want to select result sets according to the metadata as input parameters for other experiments.

Imagine you have a set of “InferenceResults”, which have the key “arch” in their metadata. You want to select an instance of these result sets as an input parameter. This is possible when using functions as input parameters.

If an input parameter is a function, it will be called with the experiment instance as first argument, after all other parameters are parsed (from the command line):

from versuchung.search import *

inputs = {
    "arch": String("x86"),

     # Here come computed arguments
     "inference_s390": lambda self:\
           search_experiment(InferenceResults,
                           search_path_go_up_till(self.base_directory, "data"),
                           {'arch': "s390"}),

     "inference": lambda self:\
           search_experiment(InferenceResults,
                           search_path_go_up_till(self.base_directory, "data"),
                           {'arch': self.arch.value}),
}

Here two inputs are computed. inference_s390 is calulated dynamically, but isn’t dependent on any other input parameter. The result set is a directory, which is an upper directory to the current one, and is named “data”.

The inference parameter is similar, but dependent on the “arch” input parameter.

versuchung.search.assert_metadata_common(metadata_field, experiments)[source]

Ensure that all experiments have the same value in their metadata according to the metadata_field

versuchung.search.assert_metadata_unique(metadata_field, experiments)[source]

Ensure that all experiments have a different value in their metadata according to the metadata_field

versuchung.search.search_experiment(experiment_type, directory, selector=None)[source]

Like search_experiment_results(), but returns only one experiment result set. And fails if it is ambigious

versuchung.search.search_experiment_results(experiment_type, directory, selector=None, follow_links=True)[source]

In large experiment setups it is hard to keep track of all result sets, which were produced. Therefore a search on the “result set database” is implemented with this function.

Parameters:
  • experiment_type – The experiment class object you are looking for
  • directory – Which directory to search for (recursivly)
  • selector – function that gets an experiment_type instance and returns a bool
Return type:

a list of experiment_type objects

The selector can also be a dict will be wrapped automatically with search_selector_metadata().

>>> search_experiment_results(MyExperiment, ".", lambda e: "home" in e.path)
  List(MyExperiment, <MyExperiment object at 0xb74805ec>])
versuchung.search.search_path_go_up_till(path, till)[source]

Go up in the given path (which is of type string), until the directory is called till

versuchung.search.search_selector_metadata(metadata_dict)[source]

Creates a selector to be used with search_experiment_results. The selector will only select experiments where all metadata keys eqyal to the given metadata_dict.