Skip to content

io

Classes

TaskIO

Bases: ABC

Abstract Task I/O interface.

Responsible for reading, writing, and removing task state data to persistent storage.

Attributes

base_url abstractmethod property
base_url: str

Base URL for the task I/O

Functions

build_url abstractmethod
build_url(obj_name: str) -> str

Builds a URL for a given object name

exists abstractmethod
exists(obj_name: str) -> bool

Checks if a state data file exists in persistent storage

from_base_url staticmethod
from_base_url(
    base_url: str, encoding: str = "utf-8", **kwargs
) -> TaskIO
list abstractmethod
list(prefix: str) -> List[str]

Lists objects in the persistent storage that match the specified prefix, typically this will be the task ID

read abstractmethod
read(obj_name: str) -> str

Reads state datafile from persistent storage

remove abstractmethod
remove(obj_name: str) -> None

Removes state datafile from persistent storage

write abstractmethod
write(obj_name: str, data: str) -> None

Writes state data to persistent storage

TaskIOFile

TaskIOFile(base_url: str, encoding: str = 'utf-8')

Bases: TaskIO

Task I/O implementation for file-based storage

Attributes

base_url property
base_url: str

Returns the base URL.

Returns:

  • str ( str ) –

    The base URL.

Functions

build_url
build_url(obj_name: str) -> str

Builds a URL for a given object name by appending it to the base URL.

Parameters:

  • obj_name (str) –

    The object name to convert.

Returns:

  • str ( str ) –

    The corresponding filesystem path.

exists
exists(obj_name: str) -> bool

Checks if a state data file exists.

Parameters:

  • obj_name (str) –

    The object name to be appended to the base URL.

Returns:

  • bool ( bool ) –

    True if the file exists, False otherwise.

list
list(prefix: str) -> List[str]

Lists objects in the persistent storage that match the specified prefix, typically this will be the task ID

read
read(obj_name: str) -> str

Reads state data from a file.

Parameters:

  • obj_name (str) –

    The object name to be appended to the base URL.

Returns:

  • str ( str ) –

    The data read from the file.

remove
remove(obj_name: str) -> None

Removes a state data file.

Parameters:

  • obj_name (str) –

    The object name to be appended to the base URL.

write
write(obj_name: str, data: str) -> None

Writes state data to a file.

Parameters:

  • obj_name (str) –

    The object name to be appended to the base URL.

  • data (str) –

    The data to write to the file.