snowflake.snowpark_checkpoints.io_utils.IODefaultStrategy

class snowflake.snowpark_checkpoints.io_utils.IODefaultStrategy

Bases: EnvStrategy

Methods

file_exists(path: str) bool

Check if a file exists.

Parameters:

path – The path to the file.

Returns:

True if the file exists, False otherwise.

Return type:

bool

folder_exists(path: str) bool

Check if a folder exists.

Parameters:

path – The path to the folder.

Returns:

True if the folder exists, False otherwise.

Return type:

bool

getcwd() str

Get the current working directory.

Returns:

The current working directory.

Return type:

str

ls(path: str, recursive: bool = False) list[str]

List the contents of a directory.

Parameters:
  • path – The path to the directory.

  • recursive – If True, list the contents recursively.

Returns:

A list of the contents of the directory.

Return type:

list[str]

mkdir(path: str, exist_ok: bool = False) None

Create a directory.

Parameters:
  • path – The name of the directory to create.

  • exist_ok – If False, an error is raised if the directory already exists.

read(file_path: str, mode: str = 'r', encoding: str | None = None) str

Read content from a file.

Parameters:
  • file_path – The path to the file to read from.

  • mode – The mode in which to open the file.

  • encoding – The encoding to use for reading the file.

Returns:

The content of the file.

Return type:

str

read_bytes(file_path: str) bytes

Read binary content from a file.

Parameters:

file_path – The path to the file to read from.

Returns:

The binary content of the file.

Return type:

bytes

telemetry_path_files(path: str) Path

Get the path to the telemetry files.

Parameters:

path – The path to the telemetry directory.

Returns:

The path object representing the telemetry files.

Return type:

Path

write(file_path: str, file_content: str, overwrite: bool = True) None

Write content to a file.

Parameters:
  • file_path – The name of the file to write to.

  • file_content – The content to write to the file.

  • overwrite – If True, overwrite the file if it exists.