jina.enums module

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: bool

Check if PollingType is using push protocol.

Return type

bool

Returns

True if this PollingType is using push protocol else False.

property is_block: bool

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
ROUTER_CONNECT = 13
property is_bind: bool

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: bool

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: jina.enums.SocketType

Get the paired SocketType.

Return type

SocketType

Returns

a paired SocketType.

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

RUNNING = 2

the graph is started and all pods are running

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

Bases: jina.enums.BetterEnum

Gateway communication protocol

GRPC = 0
HTTP = 1
WEBSOCKET = 2
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: bool

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.

DATA = 0
CONTROL = 1
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_HANDLE = 1

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

THROW_EARLY = 2

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: bool

Check if the target is inspected.

Return type

bool

Returns

True if the target is inspected else False.

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

Bases: jina.enums.BetterEnum

Infrastructure where the Flow runs on.

JINA = 0
K8S = 1
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
class jina.enums.ProgressBarStatus(value)[source]

Bases: jina.enums.BetterEnum

Type of the progress bar status.

WORKING = 0
DONE = 1
CANCELED = 2
ERROR = 3
class jina.enums.EmbeddingClsType(value)[source]

Bases: jina.enums.BetterEnum

Enums for representing the type of embeddings supported.

DENSE = 0
SCIPY_COO = 1
SCIPY_CSR = 2
SCIPY_BSR = 3
SCIPY_CSC = 4
TORCH = 5
TF = 6
property is_sparse: bool

Check if is of sparse type

Return type

bool

Returns

True if the type is sparse

property is_dense: bool

Check if is of dense type

Return type

bool

Returns

True if the type is dense

property is_scipy: bool

Check if is of scipy sparse type

Return type

bool

Returns

True is of scipy sparse type

property is_torch: bool

Check if is of torch sparse type

Return type

bool

Returns

True is of torch sparse type

property is_tf: bool

Check if is of tf sparse type

Return type

bool

Returns

True is of tf sparse type

property scipy_cls_type: str

Return the specific scipy class type (coo, csr, csc, bsr)

Return type

str

Returns

True is of scipy sparse type

property is_scipy_stackable: bool

Return if the specific scipy class is stackable. (BSR and CSC when stacked are converted into COO)

Return type

bool

Returns

True is class is stackable

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

Bases: str, enum.Enum

Enum representing state of remote workspace created by JinaD

PENDING = 'PENDING'
CREATING = 'CREATING'
UPDATING = 'UPDATING'
ACTIVE = 'ACTIVE'
FAILED = 'FAILED'
DELETING = 'DELETING'
jina.enums.replace_enum_to_str(obj)[source]

Transform BetterEnum type into string.

Parameters

obj – Target obj.

Returns

Transformed obj with string type values.