jina.enums module

Miscellaneous enums used in Jina.

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

  1. chunk_idx:
  2. uses: index/chunk.yml
  3. parallel: ${{PARALLEL}}
  4. parallel_type: !PollingType ANY
  5. # or
  6. parallel_type: ANY
  7. # or
  8. 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.PollingType(value)[source]

Bases: jina.enums.BetterEnum

The enum for representing the parallel type of pods in a deployment.

  • 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.FlowBuildLevel(value)[source]

Bases: jina.enums.BetterEnum

The enum for representing a flow’s build level.

Some jina.orchestrate.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 deployment are running

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

Bases: jina.enums.BetterEnum

Gateway communication protocol

  • GRPC = 0

  • HTTP = 1

  • WEBSOCKET = 2

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

Bases: jina.enums.BetterEnum

The enum of a Pod role.

  • HEAD = 0

  • WORKER = 1

  • GATEWAY = 2

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

Bases: jina.enums.BetterEnum

The enum of a Deploymen role for visualization.

  • DEPLOYMENT = 0

  • JOIN = 1

  • INSPECT = 2

  • GATEWAY = 3

  • INSPECT_AUX_PASS = 4

  • JOIN_INSPECT = 5

  • property is_inspect: bool

    If the role is inspect deployment related.

    • Return type

      bool

      Returns

      True if the Deployment 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]”

See also

https://docs.python.org/3/library/archiving.html

  • 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.DataInputType(value)[source]

Bases: jina.enums.BetterEnum

Data input type in the request generator.

  • AUTO = 0

  • DOCUMENT = 1

  • CONTENT = 2

  • DICT = 3

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.