graviti.portex.base
#
The base elements of Portex type.
Module Contents#
Classes#
The base class of portex type. |
|
The base class of record like Portex types. |
Functions#
Attributes#
- class graviti.portex.base.PortexType[source]#
The base class of portex type.
- property imports(self)[source]#
Get the PortexType imports.
- Returns
The
Imports
instance of this PortexType.- Return type
- classmethod from_pyobj(cls, content, _imports=None)[source]#
Create Portex type instance from python dict.
- Parameters
content (Dict[str, Any]) – A python dict representing a Portex type.
cls (Type[_T]) –
_imports (Optional[graviti.portex.package.Imports]) –
- Returns
A Portex type instance created from the input python dict.
- Return type
_T
- classmethod from_pyarrow(cls, paarray)[source]#
Create Portex type instance from PyArrow type.
- Parameters
paarray (pyarrow.Array) – The PyArrow array.
cls (Type[_T]) –
- Raises
TypeError – When the PyArrow type is not supported.
- Returns
The created Portex type instance.
- Return type
_T
- classmethod from_json(cls, content)[source]#
Create Portex type instance from JSON string.
- Parameters
content (str) – A JSON string representing a Portex type.
cls (Type[_T]) –
- Returns
A Portex type instance created from the input JSON string.
- Return type
_T
- classmethod from_yaml(cls, content)[source]#
Create Portex type instance from YAML string.
- Parameters
content (str) – A YAML string representing a Portex type.
cls (Type[_T]) –
- Returns
A Portex type instance created from the input YAML string.
- Return type
_T
- to_pyobj(self, _with_imports=True)[source]#
Dump the instance to a python dict.
- Returns
A python dict representation of the Portex type.
- Parameters
_with_imports (bool) –
- Return type
Dict[str, Any]
- to_json(self)[source]#
Dump the instance to a JSON string.
- Returns
A JSON representation of the Portex type.
- Return type
str
- to_yaml(self)[source]#
Dump the instance to a YAML string.
- Returns
A YAML representation of the Portex type.
- Return type
str
- abstract to_pyarrow(self, *, _to_backend=False)[source]#
Convert the Portex type to the corresponding builtin PyArrow DataType.
- Raises
NotImplementedError – The method of the base class should not be called.
- Returns
The corresponding builtin PyArrow DataType.
- Parameters
_to_backend (bool) –
- Return type
pyarrow.DataType
- class graviti.portex.base.PortexRecordBase[source]#
Bases:
PortexType
,graviti.utility.UserMutableMapping
[str
,PortexType
]The base class of record like Portex types.
- insert(self, index, name, portex_type)[source]#
Insert the name and portex_type at the index.
- Parameters
index (int) – The index to insert the field.
name (str) – The name of the field to be inserted.
portex_type (PortexType) – The portex_type of the field to be inserted.
- Return type
None
- astype(self, name, portex_type)[source]#
Convert the type of the field with the given name to the new PortexType.
- Parameters
name (str) – The name of the field to convert.
portex_type (PortexType) – The new PortexType of the field to convert to.
- Return type
None
- graviti.portex.base.read_yaml(path)[source]#
Read a yaml file into Portex type.
- Parameters
path (graviti.utility.PathLike) – The path of the yaml file.
- Returns
A Portex type instance created from the input yaml file.
- Return type