jina.jaml.parsers.flow.v1 module

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

  • deployments 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 Deployment 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:

    1. !Flow
    2. version: '1.0'
    3. deployments:
    4. - name: executor0 # notice the change here, name is now an attribute
    5. method: add # by default method is always add, available: add, needs, inspect
    6. needs: gateway
    7. - name: executor1 # notice the change here, name is now an attribute
    8. method: add # by default method is always add, available: add, needs, inspect
    9. needs: gateway
    10. - method: inspect # add an inspect node on executor1
    11. - method: needs # let's try something new in Flow YAML v1: needs
    12. needs: [executor1, executor0]
  • version = ‘1’

    the version number this parser designed for

  • parse(cls, data)[source]

    • Parameters

      • cls (type) – the class registered for dumping/loading

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

      Return type

      Flow

      Returns

      the Flow YAML parser given the syntax version number

  • dump(data)[source]

    • Parameters

      data (Flow) – versioned flow object

      Return type

      Dict

      Returns

      the dictionary given a versioned flow object