jina.jaml.helper module#
- class jina.jaml.helper.JinaConstructor[source]#
Bases:
FullConstructor
Convert List into tuple when doing hashing.
- class jina.jaml.helper.JinaLoader(stream, runtime_args=None)[source]#
Bases:
Reader
,Scanner
,Parser
,Composer
,JinaConstructor
,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'>>, '!HubbleReturnStatus': <bound method BetterEnum._from_yaml of <enum 'HubbleReturnStatus'>>, '!NormalizerErrorCode': <bound method BetterEnum._from_yaml of <enum 'NormalizerErrorCode'>>, '!StandaloneExecutorType': <bound method BetterEnum._from_yaml of <enum 'StandaloneExecutorType'>>, '!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.get_jina_loader_with_runtime(runtime_args=None)[source]#
Create a JinaLoader init function which already stored the runtime_args in the init function, usefully for yaml.load(stream,loader=JinaLoader) which needs a class with a init function with only one parameter
- Parameters
runtime_args (
Optional
[Dict
[str
,Any
]]) – Optional runtime_args to be directly passed without being parsed into a yaml config- Returns
A function that initialize a JinaLoader with the runtime_args stored within the function
- 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.