Flow YAML Syntax¶
jina.Flow can be loaded from a YAML config file. It follows the following syntax as the example below:
!Flow version: '1.0' with: restful: true pods: - name: pod0 # notice the change here, name is now an attribute method: add # by default method is always add, available: add, needs, inspect uses: _pass needs: gateway - name: pod1 # notice the change here, name is now an attribute method: add # by default method is always add, available: add, needs, inspect uses: _pass needs: gateway - method: inspect # add an inspect node on pod1 - method: needs # let's try something new in Flow YAML v1: needs needs: [pod1, pod0]
A valid Flow specification starts with
!Flow as the first line.
The version number string of Flow YAML schema.
Don’t forget to quote your version number, it must be a string.
A list of arguments in the
jina.Flow.__init__()function. Check jina flow --help for details. Extra
kwargswill be passed to all pods as the common
The list of
jina.peapods.Podcontained in the flow. The key is the name of this pod and the value is a map of arguments accepted by jina pod --help. Besides those
kwargs, there are some optional fields one can set:
The user defined name of the Pod. Optional. When not given, it will named as
The method for appending this Pod into the Flow. Optional, by default it’s
add: same as
needs: same as
inspect: same as
Identifies any Pods that must complete successfully before this Pod will run. It can be a string or array of strings. By default,
needsalways contains the previous Pod, unless written in other way.
needscan be used to create intra-Pod parallelization. For example, the Flow below runs
!Flow version: '1.0' pods: - name: pod1 - name: pod2 - name: pod3 needs: pod1 - name: pod4 needs: [pod2, pod3]