Experiment.run()#

Experiment.run(path: Optional[Union[str, pathlib.Path]] = None, **kwargs)[source]#

Runs the experiment.

Parameters
  • path – Path to the experiment directory, containing script.py. If None, alfred looks for a script.py in the directory from which this method is executed.

  • open_browser – Indicates, whether alfred should try to open a new browser window automatically.

  • debug – Indicates, whether the underlying flask app should be run in debug mode. Defaults to None, which leads to taking the value from option ‘open_browser’ in section ‘general’ of config.conf.

  • test – If true, the experiment is started in test mode. Session IDs and the experiment version receive a prefix of “test-“.

Changed in version 2.3.0: Added parameter test.

Notes

Warning

If you execute this method in your script.py, make sure to use an if __name__ == "__main__" protector (see example)!

See also

There are two other useful ways of running your alfred experiment:

  1. Define a run.py in your Experiment directory (see alfred3.run)

  2. Use the command line interface (see cli)

    alfred3 run
    

Examples

A convenient way of running short alfred experiments is to call this method at the end of your script.py:

import alfred3 as al
exp = al.Experiment()
exp += al.Page(name="demo")

if __name__ == "__main__":
    exp.run()

To start an experiment in test mode:

import alfred3 as al
exp = al.Experiment()
exp += al.Page(name="demo")

if __name__ == "__main__":
    exp.run(test=True)

To start an experiment without trying to open a browser window automatically:

import alfred3 as al
exp = al.Experiment()
exp += al.Page(name="demo")

if __name__ == "__main__":
    exp.run(open_browser=False)