graviti.portex.base#

The base elements of Portex type.

Module Contents#

Classes#

PortexType

The base class of portex type.

Functions#

read_yaml(path)

Read a yaml file into Portex type.

read_json(path)

Read a json file into Portex type.

Attributes#

graviti.portex.base.PYARROW_TYPE_ID_TO_PORTEX_TYPE[source]#
class graviti.portex.base.PortexType[source]#

The base class of portex type.

get_keys(self, _=None)[source]#

Get the keys to locate the data.

Returns

The keys to locate the data.

Parameters

_ (Optional[str]) –

Return type

List[Tuple[str, Ellipsis]]

property imports(self)[source]#

Get the PortexType imports.

Returns

The Imports instance of this PortexType.

Return type

graviti.portex.package.Imports

classmethod from_pyobj(cls, content, _imports=None)[source]#

Create Portex type instance from python dict.

Parameters
Returns

A Portex type instance created from the input python dict.

Return type

_T

classmethod from_pyarrow(cls, pyarrow_type)[source]#

Create Portex type instance from PyArrow type.

Parameters

pyarrow_type (pyarrow.DataType) – The PyArrow type.

Raises

TypeError – When the PyArrow type is not supported.

Returns

The created Portex type instance.

Return type

PortexType

classmethod from_json(cls, content)[source]#

Create Portex type instance from JSON string.

Parameters

content (str) – A JSON string representing a Portex type.

Returns

A Portex type instance created from the input JSON string.

Return type

PortexType

classmethod from_yaml(cls, content)[source]#

Create Portex type instance from YAML string.

Parameters

content (str) – A YAML string representing a Portex type.

Returns

A Portex type instance created from the input YAML string.

Return type

PortexType

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)[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.

Return type

pyarrow.DataType

copy(self)[source]#

Get a copy of the portex type.

Returns

A copy of the portex type.

Parameters

self (_T) –

Return type

_T

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

PortexType

graviti.portex.base.read_json(path)[source]#

Read a json file into Portex type.

Parameters

path (graviti.utility.PathLike) – The path of the json file.

Returns

A Portex type instance created from the input json file.

Return type

PortexType