cursus.step_catalog.adapters.contract_adapter

Modernized contract discovery adapters using unified StepCatalog system.

This module provides streamlined adapters that leverage the unified StepCatalog for discovery operations while maintaining backward compatibility.

class ContractDiscoveryResult(contract=None, contract_name=None, discovery_method='step_catalog', error_message=None)[source]

Bases: object

Legacy result class for contract discovery operations.

Maintains backward compatibility with existing tests and code.

class ContractDiscoveryEngineAdapter(workspace_root)[source]

Bases: object

Modernized adapter using unified StepCatalog for all discovery operations.

Replaces: src/cursus/validation/alignment/discovery/contract_discovery.py All methods now use the step catalog’s built-in discovery capabilities.

discover_contracts_with_scripts()[source]

MODERNIZED: Use step catalog’s built-in method.

Historically the primary contract-discovery entry for the Level-2 alignment tester (now removed — contract<->spec alignment is a construction-time invariant; FZ 31e1d3h/D5); the method stays as a general script-backed-contract discovery helper.

discover_all_contracts()[source]

MODERNIZED: Discover all steps that have contracts using step catalog.

Used by alignment validation system.

extract_contract_reference_from_spec(spec_file)[source]

MODERNIZED: Extract contract reference from spec file using step catalog.

Used by alignment validation system to find which step corresponds to a spec file.

Parameters:

spec_file (str) – Name of the spec file (e.g., “xgboost_training_spec.py”)

Returns:

Step name if found, None otherwise

Return type:

str | None

build_entry_point_mapping()[source]

MODERNIZED: Build entry point mapping from step names to script paths.

Used by tests and legacy systems that expect entry point mappings.

Returns:

Dictionary mapping step names to script file paths

Return type:

Dict[str, str]

class ContractDiscoveryManagerAdapter(test_data_dir=None, workspace_root=None)[source]

Bases: object

Modernized adapter using unified StepCatalog with minimal business logic.

Replaces: src/cursus/validation/script_testing (formerly runtime/contract_discovery.py) Focuses on test-specific functionality while leveraging step catalog for discovery.

discover_contract(step_name, canonical_name=None)[source]

MODERNIZED: Use StepCatalog’s load_contract_class for discovery.

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

  • canonical_name (str | None) – Optional canonical name for the step

Returns:

String path for backward compatibility, or None if not found

Return type:

str | None

get_contract_input_paths(contract, step_name)[source]

Get contract input paths with local adaptation.

get_contract_output_paths(contract, step_name)[source]

Get contract output paths with local adaptation.

get_contract_environ_vars(contract)[source]

Get environment variables from contract.

get_contract_job_args(contract, step_name)[source]

Get job arguments from contract.