An empty Flow can be created via:
from jina import Flow f = Flow()
Use a Flow¶
f, always open it as a context manager, just like you open a file. This is considered the best practice in
with f: ...
Flow follows a lazy construction pattern: it won’t actually run until you use
with to open it.
Once a Flow is open via
with, you can send data requests to it. However, you cannot change its construction
.add() any more until it leaves the
The context exits when its inner code is finished. A Flow’s context without inner code will immediately exit. To
prevent that, use
.block() to suspend the current process.
with f: f.block() # block the current process
Visualize a Flow¶
from jina import Flow f = Flow().add().plot('f.svg')
In Jupyter Lab/Notebook, the
Flow object is rendered automatically without needing to call