Closed liyier90 closed 1 year ago
Can you write up a tutorial Using Callbacks
under the Peaking Duck
tutorial section on using callbacks and giving some sample codes/pipelines as illustrations?
Added a "Using Callbacks" section to Peaking Duck tutorial. Includes:
output.sqlite
custom node with a callback
Enables users to attach callback functions to nodes to be run at certain points/events in the pipeline.
Implemented events:
run_begin
: BeforeNode.run()
run_end
: AfterNode.run()
Supported callback types:
UI: Users will specify callbacks for the node under the
callbacks
config key. Each callback is specified as:Incorrect callback definitions are skipped with a warning log, program is not halted.
Implementation detail: In
_edit_config()
of bothAbstractNode
andDeclarativeLoader
, avoid going deeper into nested dictionary if the key iscallbacks
. This allows us to define the callbacks config in PeekingDuck asand in pipeline config as
This allows us to implement more callback events in the future without have to add the event key to all the config files in PeekingDuck.
Sample usage: Extract callbacks.zip into your project directory. Ensure that the
callbacks
directory is at the same level asdev_callback.yml
. You should have the following directory layout:Run
dev_callback.yml
and you should see logging outputs such ascalled 1
fromcallback_1()
inmy_callbacks.py
called z
fromcb_1()
incb_dir/mycb.py
Suppressing logging
fromMyCallback.callback_2()
inmy_callbacks.py
Exceed zone limit ...
fromMyCallback.callback_3()
inmy_callbacks.py
Update db with frame_count ...
fromcb_obj.track_count_callback()
insql_callback.py
Additional changes:
key
argument fromobj_det_class_name_to_id()