Source code for jina.types.request.mixin

from abc import abstractmethod

from ..arrays import DocumentArray
from ...proto import jina_pb2


[docs]class DocsPropertyMixin: """Mixin class of docs property."""
[docs] @abstractmethod def body(self): """Requred body property .. # noqa: DAR201 """ ...
@property def docs(self) -> 'DocumentArray': """Get the :class: `DocumentArray` with sequence `body.docs` as content. .. # noqa: DAR201""" self.is_used = True return DocumentArray(self.body.docs)
[docs]class GroundtruthPropertyMixin: """Mixin class of groundtruths property."""
[docs] @abstractmethod def body(self): """Requred body property .. # noqa: DAR201 """ ...
@property def groundtruths(self) -> 'DocumentArray': """Get the groundtruths in :class: `DocumentArray` type. .. # noqa: DAR201""" self.is_used = True return DocumentArray(self.body.groundtruths)
[docs]class CommandMixin: """Mixin class of command property."""
[docs] @abstractmethod def proto(self): """Requred proto property .. # noqa: DAR201 """ ...
@property def command(self) -> str: """Get the command. .. #noqa: DAR201""" self.is_used = True return jina_pb2.RequestProto.ControlRequestProto.Command.Name( self.proto.control.command )