flytekit.utils.pbhash
Directory
Classes
Class | Description |
---|---|
Message |
Abstract base class for protocol messages. |
flytekit.utils.pbhash.Message
Abstract base class for protocol messages.
Protocol message classes are almost always generated by the protocol compiler. These generated types subclass Message and implement the methods shown below.
Methods
Method | Description |
---|---|
ByteSize() |
Returns the serialized size of this message |
Clear() |
Clears all data that was set in the message |
ClearExtension() |
Clears the contents of a given extension |
ClearField() |
Clears the contents of a given field |
CopyFrom() |
Copies the content of the specified message into the current message |
DiscardUnknownFields() |
Clears all fields in the :class:UnknownFieldSet |
FromString() |
None |
HasExtension() |
Checks if a certain extension is present for this message |
HasField() |
Checks if a certain field is set for the message |
IsInitialized() |
Checks if the message is initialized |
ListFields() |
Returns a list of (FieldDescriptor, value) tuples for present fields |
MergeFrom() |
Merges the contents of the specified message into current message |
MergeFromString() |
Merges serialized protocol buffer data into this message |
ParseFromString() |
Parse serialized protocol buffer data in binary form into this message |
SerializePartialToString() |
Serializes the protocol message to a binary string |
SerializeToString() |
Serializes the protocol message to a binary string |
SetInParent() |
Mark this as present in the parent |
UnknownFields() |
Returns the UnknownFieldSet |
WhichOneof() |
Returns the name of the field that is set inside a oneof group |
ByteSize()
def ByteSize()
Returns the serialized size of this message.
Recursively calls ByteSize() on all contained messages.
Returns: int: The number of bytes required to serialize this message.
Clear()
def Clear()
Clears all data that was set in the message.
ClearExtension()
def ClearExtension(
field_descriptor,
):
Clears the contents of a given extension.
Parameter | Type |
---|---|
field_descriptor |
ClearField()
def ClearField(
field_name,
):
Clears the contents of a given field.
Inside a oneof group, clears the field set. If the name neither refers to a
defined field or oneof group, :exc:ValueError
is raised.
Parameter | Type |
---|---|
field_name |
CopyFrom()
def CopyFrom(
other_msg,
):
Copies the content of the specified message into the current message.
The method clears the current message and then merges the specified message using MergeFrom.
Parameter | Type |
---|---|
other_msg |
DiscardUnknownFields()
def DiscardUnknownFields()
Clears all fields in the :class:UnknownFieldSet
.
This operation is recursive for nested message.
FromString()
def FromString(
s,
):
Parameter | Type |
---|---|
s |
HasExtension()
def HasExtension(
field_descriptor,
):
Checks if a certain extension is present for this message.
Extensions are retrieved using the :attr:Extensions
mapping (if present).
Parameter | Type |
---|---|
field_descriptor |
HasField()
def HasField(
field_name,
):
Checks if a certain field is set for the message.
For a oneof group, checks if any field inside is set. Note that if the
field_name is not defined in the message descriptor, :exc:ValueError
will
be raised.
Parameter | Type |
---|---|
field_name |
IsInitialized()
def IsInitialized()
Checks if the message is initialized.
Returns: bool: The method returns True if the message is initialized (i.e. all of its required fields are set).
ListFields()
def ListFields()
Returns a list of (FieldDescriptor, value) tuples for present fields.
A message field is non-empty if HasField() would return true. A singular primitive field is non-empty if HasField() would return true in proto2 or it is non zero in proto3. A repeated field is non-empty if it contains at least one element. The fields are ordered by field number.
Returns: list[tuple(FieldDescriptor, value)]: field descriptors and values for all fields in the message which are not empty. The values vary by field type.
MergeFrom()
def MergeFrom(
other_msg,
):
Merges the contents of the specified message into current message.
This method merges the contents of the specified message into the current message. Singular fields that are set in the specified message overwrite the corresponding fields in the current message. Repeated fields are appended. Singular sub-messages and groups are recursively merged.
Parameter | Type |
---|---|
other_msg |
MergeFromString()
def MergeFromString(
serialized,
):
Merges serialized protocol buffer data into this message.
When we find a field in serialized
that is already present
in this message:
- If it’s a “repeated” field, we append to the end of our list.
- Else, if it’s a scalar, we overwrite our field.
- Else, (it’s a nonrepeated composite), we recursively merge into the existing composite.
Parameter | Type |
---|---|
serialized |
ParseFromString()
def ParseFromString(
serialized,
):
Parse serialized protocol buffer data in binary form into this message.
Like :func:MergeFromString()
, except we clear the object first.
Raises: message.DecodeError if the input cannot be parsed.
Parameter | Type |
---|---|
serialized |
SerializePartialToString()
def SerializePartialToString(
kwargs,
):
Serializes the protocol message to a binary string.
This method is similar to SerializeToString but doesn’t check if the message is initialized.
Keyword Args: deterministic (bool): If true, requests deterministic serialization of the protobuf, with predictable ordering of map keys.
Returns: bytes: A serialized representation of the partial message.
Parameter | Type |
---|---|
kwargs |
**kwargs |
SerializeToString()
def SerializeToString(
kwargs,
):
Serializes the protocol message to a binary string.
Keyword Args: deterministic (bool): If true, requests deterministic serialization of the protobuf, with predictable ordering of map keys.
Returns: A binary string representation of the message if all of the required fields in the message are set (i.e. the message is initialized).
Raises:
EncodeError: if the message isn’t initialized (see :func:IsInitialized
).
Parameter | Type |
---|---|
kwargs |
**kwargs |
SetInParent()
def SetInParent()
Mark this as present in the parent.
This normally happens automatically when you assign a field of a sub-message, but sometimes you want to make the sub-message present while keeping it empty. If you find yourself using this, you may want to reconsider your design.
UnknownFields()
def UnknownFields()
Returns the UnknownFieldSet.
Returns: UnknownFieldSet: The unknown fields stored in this message.
WhichOneof()
def WhichOneof(
oneof_group,
):
Returns the name of the field that is set inside a oneof group.
If no field is set, returns None.
Parameter | Type |
---|---|
oneof_group |