cursus.steps.utils

Step utilities module.

Home for shared, step-adjacent helpers that are NOT per-step artifacts (no .step.yaml row, not discovered by the catalog). Introduced as part of the FZ 31 folder simplification, which emptied the per-step data folders:

  • S3PathHandler (from s3_utils) — S3 path parsing/joining used by the synthesized step builders.

Import it from here (cursus.steps.utils); the former cursus.steps.builders re-export was removed with that folder.

class S3PathHandler[source]

Bases: object

Utility class for handling S3 URIs and paths.

Provides methods to properly manipulate S3 paths while avoiding common issues like double slashes or incorrect path handling that can occur when using standard os.path functions with S3 URIs.

classmethod ensure_directory(uri, filename=None)[source]

Ensure URI represents a directory path (without filename).

Parameters:
  • uri (str) – S3 URI

  • filename (str) – Optional filename to check for at end

Returns:

Directory path without trailing filename

Return type:

str

classmethod get_name(uri)[source]

Get the basename (filename) of an S3 URI.

Parameters:

uri (str) – S3 URI

Returns:

Basename of the URI

Return type:

str

classmethod get_parent(uri)[source]

Get the parent directory of an S3 URI.

Parameters:

uri (str) – S3 URI

Returns:

Parent S3 URI

Return type:

str

classmethod is_valid(uri)[source]

Check if a string is a valid S3 URI.

Parameters:

uri (str) – URI to validate

Returns:

True if valid S3 URI

Return type:

bool

classmethod join(base_uri, *paths)[source]

Join path components with an S3 URI base.

Parameters:
  • base_uri (str) – Base S3 URI

  • *paths (str) – Path components to join

Returns:

Joined S3 URI

Return type:

str

classmethod normalize(uri, description='S3 URI')[source]

Normalize an S3 URI by ensuring no trailing slashes or double slashes.

Parameters:
  • uri (str) – S3 URI to normalize

  • description (str) – Description for logging

Returns:

Normalized S3 URI

Return type:

str

static parse_uri(uri)[source]

Parse an S3 URI into components.

Parameters:

uri (str) – S3 URI to parse

Returns:

(bucket, key)

Return type:

tuple

Raises:

ValueError – If not a valid S3 URI

Modules