The @ooze.startup decorator

Overview

Typically you use ooze.run() to run your application using the Ooze dependency graph. Ooze.run can determine what to run by two mechanics: an argument given or a callable that has been decorated with @ooze.startup.

Here’s how it looks when you use an argument:

 1import ooze
 2
 3@ooze.provide
 4def get_version():
 5    with open('version.txt') as infile:
 6        return infile.read()
 7
 8def main(get_version):
 9    print(f"Version: {get_version()})
10    ...
11
12ooze.run(main)

You can see that the main function is passed to ooze.run as an argument. When Ooze tries to run main, it will attempt to satisfy any dependencies that it has automatically.

If, for some reason, you’d prefer NOT to pass your starting-point function into the ooze.run function, you can omit it. You simply have to “tag” your starting point with the ooze.startup decorator:

 1import ooze
 2
 3@ooze.provide
 4def get_version():
 5    with open('version.txt') as infile:
 6        return infile.read()
 7
 8@ooze.startup
 9def main(get_version):
10    print(f"Version: {get_version()})
11    ...
12
13ooze.run()

Ooze will look for the last function that has been decorated with @ooze.startup and will execute that function as if it has been passed in as an argument.