View the Code
See the code for this example on Github.
Invoking Functions in Other Apps
This example demonstrates how to invoke functions in other apps on Beam. Specifically, we cover the scenario with an inference and a retraining function. The retraining function needs a way to tell the inference function to use the latest model. We use anexperimental.Signal()
, which is a special type of event listener that can be triggered from the retrain function.
App 1: Retraining App
This is the retraining app. Below, we register aSignal
that will fire an event to our inference app, which is subscribed to this Signal event.
App 2: Inference App
Below is the inference app, which needs to reload theon_start
function when retraining is finished.
You’ll notice that a Signal is registered with a handler that tells us which function to run when an event is fired.
- In window 1, serve and invoke the inference function
- In window 2, serve and invoke the retrain function
load_latest_model
ran again.
Clearing Signals
Signals will refresh every 1 second while a container is running, untilsignal.clear()
is called. It is recommended to run signal.clear()
after each signal invovocation.