1.7 Integration with Sacred

NOTE: These cells are not executable code, but are meant to serve as a guideline for setting up a Sacred project with signac

Here we demonstrate how to integrate a sacred experiment with signac-flow. Assuming the following sacred experiment defined in a experiment.py module:

from sacred import Experiment

ex = Experiment('jupyter_ex', interactive=True)


@ex.automain
def hello(foo):
    print("hello", foo)

Then we can integrate that experiment on a per job basis as defined in project.py :

from flow import FlowProject
class SacredProject(FlowProject):
    pass


@SacredProject.operation
def run_experiment(job):
    ex.add_config(**job.sp())
    ex.observers[:] = [FileStorageObserver.create(job.fn("my_runs"))]
    ex.run()