jina.jaml.helper module
class jina.jaml.helper.JinaConstructor[source]
Bases: yaml.constructor.FullConstructor
Convert List into tuple when doing hashing.
get_hashable_key(key)[source]
Get the hash value of key.
Parameters
key – key value to be hashed.
Returns
Hash value of key.
construct_mapping(node, deep=True)[source]
Build the mapping from node.
Parameters
node – the node to traverse
deep – required param from YAML constructor
Returns
Mapped data
class jina.jaml.helper.JinaResolver[source]
Bases: yaml.resolver.Resolver
Remove on|On|ON as bool resolver.
class jina.jaml.helper.JinaLoader(stream)[source]
Bases: yaml.reader.Reader
, yaml.scanner.Scanner
, yaml.parser.Parser
, yaml.composer.Composer
, jina.jaml.helper.JinaConstructor, jina.jaml.helper.JinaResolver
The Jina loader which should be able to load YAML safely.
Parameters
stream – the stream to load.
Initialize the scanner.
- yaml_constructors = {‘tag:yaml.org,2002:null’: <function SafeConstructor.construct_yaml_null>, ‘tag:yaml.org,2002:bool’: <function SafeConstructor.construct_yaml_bool>, ‘tag:yaml.org,2002:int’: <function SafeConstructor.construct_yaml_int>, ‘tag:yaml.org,2002:float’: <function SafeConstructor.construct_yaml_float>, ‘tag:yaml.org,2002:binary’: <function SafeConstructor.construct_yaml_binary>, ‘tag:yaml.org,2002:timestamp’: <function SafeConstructor.construct_yaml_timestamp>, ‘tag:yaml.org,2002:omap’: <function SafeConstructor.construct_yaml_omap>, ‘tag:yaml.org,2002:pairs’: <function SafeConstructor.construct_yaml_pairs>, ‘tag:yaml.org,2002:set’: <function SafeConstructor.construct_yaml_set>, ‘tag:yaml.org,2002:str’: <function SafeConstructor.construct_yaml_str>, ‘tag:yaml.org,2002:seq’: <function SafeConstructor.construct_yaml_seq>, ‘tag:yaml.org,2002:map’: <function SafeConstructor.construct_yaml_map>, None: <function SafeConstructor.construct_undefined>, ‘tag:yaml.org,2002:python/none’: <function SafeConstructor.construct_yaml_null>, ‘tag:yaml.org,2002:python/bool’: <function SafeConstructor.construct_yaml_bool>, ‘tag:yaml.org,2002:python/str’: <function FullConstructor.construct_python_str>, ‘tag:yaml.org,2002:python/unicode’: <function FullConstructor.construct_python_unicode>, ‘tag:yaml.org,2002:python/bytes’: <function FullConstructor.construct_python_bytes>, ‘tag:yaml.org,2002:python/int’: <function SafeConstructor.construct_yaml_int>, ‘tag:yaml.org,2002:python/long’: <function FullConstructor.construct_python_long>, ‘tag:yaml.org,2002:python/float’: <function SafeConstructor.construct_yaml_float>, ‘tag:yaml.org,2002:python/complex’: <function FullConstructor.construct_python_complex>, ‘tag:yaml.org,2002:python/list’: <function SafeConstructor.construct_yaml_seq>, ‘tag:yaml.org,2002:python/tuple’: <function FullConstructor.construct_python_tuple>, ‘tag:yaml.org,2002:python/dict’: <function SafeConstructor.construct_yaml_map>, ‘!JAMLCompatible’: <bound method JAMLCompatible._from_yaml of <class ‘jina.jaml.JAMLCompatible’>>, ‘!BetterEnum’: <bound method BetterEnum._from_yaml of <enum ‘BetterEnum’>>, ‘!PollingType’: <bound method BetterEnum._from_yaml of <enum ‘PollingType’>>, ‘!LogVerbosity’: <bound method BetterEnum._from_yaml of <enum ‘LogVerbosity’>>, ‘!FlowBuildLevel’: <bound method BetterEnum._from_yaml of <enum ‘FlowBuildLevel’>>, ‘!GatewayProtocolType’: <bound method BetterEnum._from_yaml of <enum ‘GatewayProtocolType’>>, ‘!PodRoleType’: <bound method BetterEnum._from_yaml of <enum ‘PodRoleType’>>, ‘!DeploymentRoleType’: <bound method BetterEnum._from_yaml of <enum ‘DeploymentRoleType’>>, ‘!RequestType’: <bound method BetterEnum._from_yaml of <enum ‘RequestType’>>, ‘!CompressAlgo’: <bound method BetterEnum._from_yaml of <enum ‘CompressAlgo’>>, ‘!OnErrorStrategy’: <bound method BetterEnum._from_yaml of <enum ‘OnErrorStrategy’>>, ‘!FlowInspectType’: <bound method BetterEnum._from_yaml of <enum ‘FlowInspectType’>>, ‘!DataInputType’: <bound method BetterEnum._from_yaml of <enum ‘DataInputType’>>, ‘!RuntimeBackendType’: <bound method BetterEnum._from_yaml of <enum ‘RuntimeBackendType’>>, ‘!ProgressBarStatus’: <bound method BetterEnum._from_yaml of <enum ‘ProgressBarStatus’>>, ‘!EmbeddingClsType’: <bound method BetterEnum._from_yaml of <enum ‘EmbeddingClsType’>>, ‘!BaseExecutor’: <bound method JAMLCompatible._from_yaml of <class ‘jina.serve.executors.BaseExecutor’>>, ‘!ReducerExecutor’: <bound method JAMLCompatible._from_yaml of <class ‘jina.serve.executors.ReducerExecutor’>>, ‘!Flow’: <bound method JAMLCompatible._from_yaml of <class ‘jina.orchestrate.flow.base.Flow’>>, ‘!AsyncFlow’: <bound method JAMLCompatible._from_yaml of <class ‘jina.orchestrate.flow.asyncio.AsyncFlow’>>, ‘!MyIndexer’: <bound method JAMLCompatible._from_yaml of <class ‘jina.helloworld.fashion.my_executors.MyIndexer’>>, ‘!MyEncoder’: <bound method JAMLCompatible._from_yaml of <class ‘jina.helloworld.fashion.my_executors.MyEncoder’>>, ‘!MyConverter’: <bound method JAMLCompatible._from_yaml of <class ‘jina.helloworld.fashion.my_executors.MyConverter’>>}
jina.jaml.helper.parse_config_source(path, allow_stream=True, allow_yaml_file=True, allow_raw_yaml_content=True, allow_class_type=True, allow_dict=True, allow_json=True, extra_search_paths=None, \args, **kwargs*)[source]
Check if the text or text stream is valid.
Parameters
path (
Union
[str
,TextIO
,Dict
]) – the multi-kind source of the configs.allow_stream (
bool
) – flagallow_yaml_file (
bool
) – flagallow_raw_yaml_content (
bool
) – flagallow_class_type (
bool
) – flagallow_dict (
bool
) – flagallow_json (
bool
) – flagextra_search_paths (
Optional
[List
[str
]]) – extra paths to search forargs – unused
kwargs – unused
Return type
Tuple
[TextIO
,Optional
[str
]]Returns
a tuple, the first element is the text stream, the second element is the file path associate to it if available.
jina.jaml.helper.complete_path(path, extra_search_paths=None)[source]
Complete the path of file via searching in abs and relative paths.
Parameters
path (
str
) – path of file.extra_search_paths (
Optional
[List
[str
]]) – extra paths to conduct search
Return type
str
Returns
Completed file path.
jina.jaml.helper.load_py_modules(d, extra_search_paths=None)[source]
Find ‘py_modules’ in the dict recursively and then load them.
Parameters
d (
Dict
) – the dictionary to traverseextra_search_paths (
Optional
[List
[str
]]) – any extra paths to search
Return type
None