jina.enums

Miscellaneous enums used in Jina.

To use these enums in YAML config, following the example below:

chunk_idx:
  uses: index/chunk.yml
  parallel: ${{PARALLEL}}
  parallel_type: !PollingType ANY
  # or
  parallel_type: ANY
  # or
  parallel_type: any
class jina.enums.EnumType(*args, **kwargs)[source]

Bases: enum.EnumMeta

The metaclass for BetterEnum.

Register a new EnumType

Parameters
  • args – args passed to super()

  • kwargs – kwargs passed to super()

Returns

the registry class

static register_class(cls)[source]

Register the class for dumping loading.

Parameters

cls – Target class.

Returns

Registered class.

class jina.enums.BetterEnum(value)[source]

Bases: enum.IntEnum

The base class of Enum used in Jina.

classmethod from_string(s)[source]

Parse the enum from a string.

Parameters

s (str) – string representation of the enum value

Returns

enum value

class jina.enums.SchedulerType(value)[source]

Bases: jina.enums.BetterEnum

The enum for Scheduler Type.

LOAD_BALANCE = 0

balance the workload between Peas, faster peas get more work

ROUND_ROBIN = 1
class jina.enums.PollingType(value)[source]

Bases: jina.enums.BetterEnum

The enum for representing the parallel type of peas in a pod.

ANY = 1

one of the shards will receive the message

ALL = 2

all shards will receive the message, blocked until all done with the message

ALL_ASYNC = 3

(reserved) all replica will receive the message, but any one of them can return, useful in backup

property is_push

Check if PollingType is using push protocol.

Return type

bool

Returns

True if this PollingType is using push protocol else False.

property is_block

Check if PollingType is using block protocol.

Return type

bool

Returns

True if this PollingType is requiring block protocol else False.

class jina.enums.LogVerbosity(value)[source]

Bases: jina.enums.BetterEnum

Verbosity level of the logger.

DEBUG = 10
INFO = 20
SUCCESS = 25
WARNING = 30
ERROR = 40
CRITICAL = 50
class jina.enums.SocketType(value)[source]

Bases: jina.enums.BetterEnum

Enums for representing the socket type in a pod.

PULL_BIND = 0
PULL_CONNECT = 1
PUSH_BIND = 2
PUSH_CONNECT = 3
SUB_BIND = 4
SUB_CONNECT = 5
PUB_BIND = 6
PUB_CONNECT = 7
PAIR_BIND = 8
PAIR_CONNECT = 9
ROUTER_BIND = 10
DEALER_CONNECT = 11
property is_bind

Check if this socket is using bind protocol.

Return type

bool

Returns

True if this socket is using bind protocol else False.

property is_receive

Check if this socket is used for receiving data.

Return type

bool

Returns

True if this socket is used for receiving data else False.

property is_pubsub

Check if this socket is used for publish or subscribe data.

Returns

True if this socket is used for publish or subscribe data else False.

property paired

Get the paired SocketType.

Return type

SocketType

Returns

a paired SocketType.

class jina.enums.FlowOutputType(value)[source]

Bases: jina.enums.BetterEnum

The enum for representing flow output config.

SHELL_PROC = 0

a shell-script, run each microservice as a process

SHELL_DOCKER = 1

a shell-script, run each microservice as a container

DOCKER_SWARM = 2

a docker-swarm YAML config

K8S = 3

a Kubernetes YAML config

class jina.enums.FlowBuildLevel(value)[source]

Bases: jina.enums.BetterEnum

The enum for representing a flow’s build level.

Some jina.flow.Flow class functions require certain build level to run.

EMPTY = 0

Nothing is built

GRAPH = 1

The underlying graph is built, you may visualize the flow

class jina.enums.PeaRoleType(value)[source]

Bases: jina.enums.BetterEnum

The enum of a Pea role.

SINGLETON = 0
HEAD = 1
TAIL = 2
PARALLEL = 3
class jina.enums.PodRoleType(value)[source]

Bases: jina.enums.BetterEnum

The enum of a Pod role for visualization.

POD = 0
JOIN = 1
INSPECT = 2
GATEWAY = 3
INSPECT_AUX_PASS = 4
JOIN_INSPECT = 5
property is_inspect

If the role is inspect pod related.

Return type

bool

Returns

True if the Pod role is inspect related else False.

class jina.enums.RequestType(value)[source]

Bases: jina.enums.BetterEnum

The enum of Client mode.

INDEX = 0
SEARCH = 1
DELETE = 2
UPDATE = 3
CONTROL = 4
TRAIN = 5
DUMP = 6
class jina.enums.CompressAlgo(value)[source]

Bases: jina.enums.BetterEnum

The enum of Compress algorithms.

Note

LZ4 requires additional package, to install it use pip install “jina[lz4]”

NONE = 0
LZ4 = 1
ZLIB = 2
GZIP = 3
BZ2 = 4
LZMA = 5
class jina.enums.OnErrorStrategy(value)[source]

Bases: jina.enums.BetterEnum

The level of error handling.

Warning

In theory, all methods below do not 100% guarantee the success execution on the sequel flow. If something is wrong in the upstream, it is hard to CARRY this exception and moving forward without ANY side-effect.

IGNORE = 0
SKIP_EXECUTOR = 1

Skip all Executors in the sequel, but drivers are still called

SKIP_HANDLE = 2

Skip all Drivers & Executors in the sequel, only pre_hook and post_hook are called

THROW_EARLY = 3

Immediately throw the exception, the sequel flow will not be running at all

class jina.enums.FlowInspectType(value)[source]

Bases: jina.enums.BetterEnum

Inspect strategy in the flow.

HANG = 0
REMOVE = 1
COLLECT = 2
property is_keep

Check if the target is inspected.

Return type

bool

Returns

True if the target is inspected else False.

class jina.enums.RemoteAccessType(value)[source]

Bases: jina.enums.BetterEnum

Remote access type when connect to the host.

SSH = 0
JINAD = 1
class jina.enums.BuildTestLevel(value)[source]

Bases: jina.enums.BetterEnum

Test level in jina hub build, higher level includes lower levels.

NONE = 0
EXECUTOR = 1
POD_NONDOCKER = 2
POD_DOCKER = 3
FLOW = 4
class jina.enums.DataInputType(value)[source]

Bases: jina.enums.BetterEnum

Data input type in the request generator.

AUTO = 0
DOCUMENT = 1
CONTENT = 2
class jina.enums.RuntimeBackendType(value)[source]

Bases: jina.enums.BetterEnum

Type of backend in runtime.

THREAD = 0
PROCESS = 1
jina.enums.replace_enum_to_str(obj)[source]

Transform BetterEnum type into string.

Parameters

obj – Target obj.

Returns

Transformed obj with string type values.