graviti.utility.file#

Graviti file related class.

Module Contents#

Classes#

FileBase

This class represents the file in a DataFrame.

RemoteFile

This class represents the file on Graviti platform.

File

This class represents the local file.

class graviti.utility.file.FileBase[source]#

Bases: graviti.utility.repr.ReprMixin

This class represents the file in a DataFrame.

abstract open(self)[source]#

Return the binary file pointer of this file.

Raises

NotImplementedError – The method of the base class should not be called.

Return type

Union[graviti.utility.requests.UserResponse, _io.BufferedReader]

property url(self)[source]#

Get the url of the file.

Returns

The url of the file.

Return type

str

property checksum(self)[source]#

Get the checksum of the file.

Returns

The checksum of the file.

Return type

str

static from_pyarrow(scalar)[source]#

Create File or RemoteFile instance with pyarrow struct scalar.

Parameters

scalar (pyarrow.StructScalar) – The input pyarrow struct scalar.

Returns

The File or RemoteFile instance.

Return type

Union[RemoteFile, File]

to_pyobj(self)[source]#

Dump the local file to a python dict.

Returns

A python dict representation of the local file.

Return type

Dict[str, str]

class graviti.utility.file.RemoteFile(url, checksum)[source]#

Bases: FileBase

This class represents the file on Graviti platform.

Parameters
  • url (str) – The url string of the file.

  • checksum (str) – The checksum of the file.

open(self)[source]#

Return the binary file pointer of this file.

Returns

The remote file pointer.

Return type

Union[graviti.utility.requests.UserResponse, _io.BufferedReader]

class graviti.utility.file.File(path)[source]#

Bases: FileBase

This class represents the local file.

Parameters

path (str) – The local path of the file.

property url(self)[source]#

Get the url of the file.

Returns

The url of the file.

Return type

str

property checksum(self)[source]#

Get the sha1 checksum of the local file.

Returns

The sha1 checksum of the local file.

Return type

str

open(self)[source]#

Return the binary file pointer of this file.

Returns

The local file pointer.

Return type

_io.BufferedReader