# Jina YAML Syntax Reference¶

Jina configurations use YAML syntax, and must have either a .yml or .yaml file extension. If you’re new to YAML and want to learn more, see Learn YAML in five minutes.

## Executor YAML Syntax¶

All executors defined in jina.executors can be loaded from a YAML config via jina.executors.BaseExecutor.load_config() or via the CLI jina pod --uses.

The executor YAML config follows the syntax below.

!BasePbIndexer
with:
index_filename: doc.gzip
metas:  # <- metas defined in :modjina.executors.metas
name: doc_indexer  # a customized name
workspace: $TEST_WORKDIR  !SomeExecutorClass The class of the executor, can be any class inherited from jina.executors.BaseExecutor. Note that it must starts with ! to tell the YAML parser that the section below is describing this class. with A list of arguments in the __init__() function of this executor. One can use environment variables here to expand the variables. metas A list of meta arguments defined in jina.executors.metas. If an executor has no __init__() or __init__() requires no arguments, then one do not need to write with at all. In the minimum case, if you don’t want to specify any with and metas, you can simply write: # encoder.yml !AwesomeExecutor  Or even not using this YAML but simply write: import jina.executors.BaseExecutor a = BaseExecutor.load_config('AwesomeExecutor')  ## CompoundExecutor YAML Syntax¶ A compound executor is a set of executors bundled together, as defined in jina.executors.compound. It follows the syntax above with an additional feature: routing. !CompoundExecutor components: - !NumpyIndexer with: num_dim: -1 index_key: HNSW32 index_filename: vec.idx metas: name: my_vec_indexer - !BasePbIndexer with: index_filename: chunk.gzip metas: name: chunk_meta_indexer with: routes: meta_add: chunk_meta_indexer: add meta_query: chunk_meta_indexer: query query: my_vec_indexer: query add: my_vec_indexer: add metas: name: chunk_compound_indexer workspace:$TEST_WORKDIR

components

A list of executors specified. Note that metas.name must be specified if you want to later quote this executor in with.routes.

with
routes
A:
B: C


It defines a function mapping so that a new function A() is created for this compound executor and points to B.C(). Note that B must be a valid name defined in components.metas.name

## Referencing Variables in Executor and CompoundExecutor YAML¶

In the YAML config, one can reference environment variables with $ENV, or using {path.variable} to reference the variable defined inside the YAML. For example, components: - with: index_filename: metaproto metas: name: test_meta good_var: - 1 - 2 bad_var: '{root.metas.name}' - with: index_filename: npidx metas: name: test_numpy bad_var: '{root.components[0].metas.good_var[1]}' # expand to the string 'real-compound' float_var: '{root.float.val}' # expand to the float 0.232 mixed: '{root.float.val}-{root.components[0].metas.good_var[1]}-{root.metas.name}' # expand to the string '0.232-2-real-compound' mixed_env: '{root.float.val}-$ENV1'  # expand to the string '0.232-a'
name_shortcut: '{this.name}'  # expand to the string 'test_nunpy'
metas:
name: real-compound
rootvar: 123
float:
val: 0.232

root.var

Referring to the top-level variable defined in the root.

this.var

Referring to the same-level variable.

Note

One must quote the string when using referenced values, i.e. '{root.metas.name}' but not {root.metas.name}.

## Driver YAML Sytanx¶

jina.drivers.Driver helps the jina.executors to handle the network traffic by interpreting the traffic data (e.g. Protobuf) into the format that the Executor can understand and handle (e.g. Numpy array). Drivers can be specified using keyword requests and on

!CompoundExecutor
components:
- !Splitter
metas:
name: splitter
- !Sentencizer
with:
min_sent_len: 3
max_sent_len: 128
punct_chars: '.,;!?:'
metas:
name: sentencizer
name: crafter
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 1, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.25559142231941223, "perplexity": 21776.061423734704}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2021-17/segments/1618038916163.70/warc/CC-MAIN-20210419173508-20210419203508-00412.warc.gz"}