Add Options.apply_binds to allow applications to bind before calling user code
In DaVinci a few cases have come up where code ends up looking like:
@configurable
def my_thing(process="MyDefault"):
...
Users then use this thing by running:
my_thing(process=options.process)
This gets a bit annoying when code starts being nested with there being multiple layers of
def my_func(process="MyDefault"):
return my_other_func(process=process)
def my_other_func(process="MyDefault"):
return my_thing(process=process)
A slightly better option is to make process
a keyword only argument and bind:
@configurable
def my_thing(*, process):
...
def my_func():
return my_other_func()
def my_other_func():
return my_thing()
# Usage looks like
with my_thing.bind(process=options.process):
my_func()
This MR expands this slightly by allowing the application-specific Options
class to automatically apply binds so the user code doesn't need to use bind. See DaVinci!731 (merged) for an example of this being used.
Merge request reports
Activity
Filter activity
Please register or sign in to reply