jina.jaml.parsers.flow.v1

class jina.jaml.parsers.flow.v1.V1Parser[source]

Bases: jina.jaml.parsers.base.VersionedYAMLParser

V1Parser introduces new syntax and features:

  • It has a top-level field version

  • pods is now a List of Dict (rather than a Dict as prev.)

  • name is now optional

  • new field method can be used to specify how to add this Pod into the Flow, availables are:
    • add: (default) equal to Flow.add(…)

    • needs: (default) equal to Flow.needs(…)

    • inspect: (default) equal to Flow.inspect(…)

An example V1 YAML config can be found below:
!Flow
version: '1.0'
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]
version = '1'
parse(cls, data)[source]

Return the Flow YAML parser given the syntax version number

Parameters

data (Dict) – flow yaml file loaded as python dict

Return type

Flow

dump(data)[source]

Return the dictionary given a versioned flow object

Parameters

data (Flow) – versioned flow object

Return type

Dict