cursus.registry.hybrid.utils

Streamlined Utility Functions for Hybrid Registry System

This module provides essential utility functions without over-engineering. Replaces complex utility classes with simple, focused functions.

exception RegistryLoadError(message, unresolvable_types=None, available_builders=None)[source]

Bases: RegistryError

Error loading registry from file.

load_registry_module(file_path)[source]

Load registry module from file.

Parameters:

file_path (str) – Path to the registry file

Returns:

Loaded module object

Raises:

RegistryLoadError – If module loading fails

Return type:

Any

get_step_names_from_module(module)[source]

Extract STEP_NAMES from loaded module.

Parameters:

module (Any) – Loaded registry module

Returns:

STEP_NAMES dictionary

Return type:

Dict[str, Dict[str, Any]]

from_legacy_format(step_name, step_info, registry_type='core', workspace_id=None)[source]

Convert legacy STEP_NAMES format to StepDefinition.

Parameters:
  • step_name (str) – Name of the step

  • step_info (Dict[str, Any]) – Legacy step information dictionary

  • registry_type (str) – Type of registry (‘core’, ‘workspace’, ‘override’)

  • workspace_id (str) – Workspace identifier for workspace steps

Returns:

StepDefinition object

Return type:

StepDefinition

to_legacy_format(definition)[source]

Convert StepDefinition to legacy STEP_NAMES format using field list.

Parameters:

definition (StepDefinition) – StepDefinition object

Returns:

Legacy format dictionary

Return type:

Dict[str, Any]

convert_registry_dict(registry_dict, registry_type='core', workspace_id=None)[source]

Convert a complete registry dictionary to StepDefinition objects.

Parameters:
  • registry_dict (Dict[str, Dict[str, Any]]) – Dictionary of step_name -> step_info

  • registry_type (str) – Type of registry

  • workspace_id (str) – Workspace identifier

Returns:

Dictionary of step_name -> StepDefinition

Return type:

Dict[str, StepDefinition]

validate_registry_type(registry_type)[source]

Validate registry type using enum values.

Parameters:

registry_type (str) – Registry type to validate

Returns:

Validated registry type

Raises:

ValueError – If registry type is invalid

Return type:

str

validate_step_name(step_name)[source]

Validate step name format.

Parameters:

step_name (str) – Step name to validate

Returns:

Validated and stripped step name

Raises:

ValueError – If step name is invalid

Return type:

str

validate_workspace_id(workspace_id)[source]

Validate workspace ID format.

Parameters:

workspace_id (str | None) – Workspace ID to validate

Returns:

Validated workspace ID or None

Raises:

ValueError – If workspace ID is invalid

Return type:

str | None

validate_registry_data(registry_type, step_name, workspace_id=None)[source]

Validate registry data using direct validation functions.

Parameters:
  • registry_type (str) – Registry type to validate

  • step_name (str) – Step name to validate

  • workspace_id (str) – Optional workspace ID to validate

Returns:

True if valid

Raises:

ValueError – If validation fails

Return type:

bool

format_registry_error(error_type, **kwargs)[source]

Generic error formatter using templates.

Parameters:
  • error_type (str) – Type of error to format

  • **kwargs – Template variables

Returns:

Formatted error message

Return type:

str

format_step_not_found_error(step_name, workspace_context=None, available_steps=None)[source]

Format step not found error messages using generic formatter.

format_registry_load_error(registry_path, error_details)[source]

Format registry loading error messages using generic formatter.

format_validation_error(component_name, validation_issues)[source]

Format validation error messages using generic formatter.