alab_management.builders.experimentbuilder module#
- class ExperimentBuilder(name, tags=None, **metadata)[source]#
Bases:
object
It takes a list of samples and a list of tasks, and returns a dictionary that can be used to generate an input file for the experiment to run.
- Parameters:
name (str) – The name of the experiment.
- add_sample(name, tags=None, **metadata)[source]#
Add a sample to the batch. Each sample already has multiple tasks binded to it. Each batch is a directed graph of tasks.
- Parameters:
name (str) – The name of the sample. This must be unique within this ExperimentBuilder.
tags (List[str]) – A list of tags to attach to the sample.
**metadata – Any additional keyword arguments will be attached to this sample as metadata.
- Return type:
- Returns:
A SampleBuilder object. This can be used to add tasks to the sample.
- add_task(task_id, task_name, task_kwargs, samples)[source]#
This function adds a task to the sample. You should use this function only for special cases which are not handled by the add_sample function.
- Parameters:
task_id (str) – The object id of the task in mongodb
task_name (str) – The name of the task.
task_kwargs (Dict[str, Any]) – Any additional keyword arguments will be attached to this sample as metadata.
samples (List[SampleBuilder]) – A list of samples to which this task is binded to.
- Return type:
None
- Returns:
None
- generate_input_file(filename, fmt='json')[source]#
Genreate an input file for the experiment command.
- Parameters:
filename (str) – The name of the file to be generated.
fmt (Literal["json", "yaml"]) – The format of the file to be generated.
- Return type:
None
- Returns:
None.
- plot(ax=None)[source]#
Plot the directed graph of tasks.
- Parameters:
ax (matplotlib.axes.Axes) – The axes on which to plot the graph.
- Return type:
None
- Returns:
None.
- submit(address='http://localhost:8895', **kwargs)[source]#
Submit the experiment to server.
- Parameters:
address (str) – The address of the server. It is defaulted to http://localhost:8895, which is the default address of the alabos server.
**kwargs – Additional keyword arguments to be passed to the requests.post function.
- Return type:
ObjectId
- Returns:
The object id of the experiment.
- get_experiment_result(exp_id, address='http://localhost:8895', **kwargs)[source]#
Get the result of the experiment.
- Parameters:
exp_id (
ObjectId
|str
) – The object id of the experiment.address (
str
) – The address of the server. It is defaulted to http://localhost:8895, which is the default address of the alabos server.**kwargs – Additional keyword arguments to be passed to the requests.get function.
- Returns:
See the dashboard code for the response format.
alab_management.dashboard.routes.experiment.query_experiment_results()
- get_experiment_status(exp_id, address='http://localhost:8895', **kwargs)[source]#
Get the status of the experiment.
- Parameters:
exp_id (ObjectId) – The object id of the experiment.
address (str) – The address of the server. It is defaulted to http://localhost:8895, which is the default address of the alabos server.
**kwargs – Additional keyword arguments to be passed to the requests.get function.
- Returns:
The status of the experiment.
.. seealso:: – See the dashboard code for the response format.
alab_management.dashboard.routes.experiment.query_experiment()