cursus.core.compiler.single_node_compiler¶
Single node execution compiler for debugging and rapid iteration.
This module enables developers to execute individual pipeline nodes in isolation by providing manual input overrides, eliminating the need to re-run expensive upstream steps when pipeline failures occur.
- class ValidationResult(is_valid, node_exists, has_configuration, has_builder, valid_input_names=<factory>, invalid_input_names=<factory>, missing_required_inputs=<factory>, invalid_s3_uris=<factory>, errors=<factory>, warnings=<factory>)[source]¶
Bases:
objectResult of node and input validation.
- class ExecutionPreview(target_node, step_type, config_type, input_mappings=<factory>, missing_required_inputs=<factory>, missing_optional_inputs=<factory>, output_paths=<factory>, estimated_instance_type='Unknown', estimated_duration=None, warnings=<factory>)[source]¶
Bases:
objectPreview of single-node execution.
- class SingleNodeCompiler(config_path, sagemaker_session=None, role=None, step_catalog=None, pipeline_parameters=None, project_root=None, anchor_file=None, **kwargs)[source]¶
Bases:
objectSpecialized compiler for single-node pipeline execution.
Enables rapid debugging by creating isolated pipelines containing just one node, with manual input overrides bypassing normal dependency resolution.
Example
>>> compiler = SingleNodeCompiler( ... config_path="configs/pipeline.json", ... sagemaker_session=session, ... role=role ... ) >>> >>> # Validate before execution >>> validation = compiler.validate_node_and_inputs( ... dag=dag, ... target_node="train", ... manual_inputs={"input_path": "s3://bucket/data/"} ... ) >>> >>> if validation.is_valid: ... pipeline = compiler.compile( ... dag=dag, ... target_node="train", ... manual_inputs={"input_path": "s3://bucket/data/"} ... )
- validate_node_and_inputs(dag, target_node, manual_inputs)[source]¶
Validate target node and manual inputs before execution.
- Parameters:
- Returns:
ValidationResult with detailed validation information
- Return type:
- preview_execution(dag, target_node, manual_inputs)[source]¶
Preview execution without creating pipeline.
- Parameters:
- Returns:
ExecutionPreview with detailed execution information
- Return type:
- compile(dag, target_node, manual_inputs, pipeline_name=None, validate_inputs=True, config_map=None, **assembler_kwargs)[source]¶
Compile single-node pipeline with manual inputs.
IMPROVED: config_map is now optional! If not provided, it will be automatically loaded from the config_path using the same mechanism as compile_dag_to_pipeline().
- Parameters:
dag (PipelineDAG | str) – PipelineDAG instance or path to serialized DAG file
target_node (str) – Name of node to execute
manual_inputs (Dict[str, str]) – Manual input paths (logical_name -> s3_uri)
pipeline_name (str | None) – Optional pipeline name
validate_inputs (bool) – Whether to validate inputs (default: True)
config_map (Dict | None) – Optional pre-loaded config map (auto-loaded if None)
**assembler_kwargs (Any) – Additional arguments for PipelineAssembler
- Returns:
Single-node Pipeline ready for execution
- Raises:
ValueError – If validation fails or compilation errors occur
FileNotFoundError – If config file not found (when auto-loading)
- Return type:
- compile_single_node_to_pipeline(dag, config_path, target_node, manual_inputs, sagemaker_session=None, role=None, pipeline_name=None, validate_inputs=True, config_map=None, pipeline_parameters=None, **kwargs)[source]¶
Compile a single-node pipeline with manual input overrides.
IMPROVED API: config_map is now optional and will be automatically loaded from config_path if not provided, matching the API consistency of compile_dag_to_pipeline().
This function creates a SingleNodeCompiler and delegates to its compile method, providing a simple one-line API for single-node execution.
- Parameters:
dag (PipelineDAG | str) – PipelineDAG instance or path to serialized DAG file
config_path (str) – Path to configuration JSON file
target_node (str) – Name of node to execute in isolation
manual_inputs (Dict[str, str]) – Dict mapping logical input names to S3 URIs Example: {“input_path”: “s3://bucket/previous-run/output/”}
sagemaker_session (Any | None) – SageMaker session for pipeline execution
role (str | None) – IAM role ARN for SageMaker permissions
pipeline_name (str | None) – Optional custom pipeline name Default: “{target_node}-isolated”
validate_inputs (bool) – Whether to validate inputs before compilation Checks: S3 URI format, node existence (default: True)
config_map (Dict | None) – Optional pre-loaded config map for advanced use cases If None (default), automatically loaded from config_path
pipeline_parameters (List[str | ParameterString] | None) – Pipeline parameters to pass to compiler. If None, uses default parameters (EXECUTION_S3_PREFIX, KMS_KEY, etc.)
**kwargs (Any) – Additional arguments passed to SingleNodeCompiler
- Returns:
Single-node Pipeline ready for execution via pipeline.start()
- Raises:
ValueError – If validation fails or node not found
FileNotFoundError – If config_path doesn’t exist
- Return type:
- Example (Simple - Config Auto-Loaded):
>>> # After a 5-hour run where preprocess succeeded but train failed >>> manual_inputs = { ... "input_path": "s3://my-bucket/run-123/preprocess/output/" ... } >>> >>> pipeline = compile_single_node_to_pipeline( ... dag=my_dag, ... config_path="configs/pipeline.json", # ✓ Auto-loads config ... target_node="train", ... manual_inputs=manual_inputs, ... sagemaker_session=session, ... role=role ... ) >>> >>> # Execute just the train step - no 5-hour wait! >>> execution = pipeline.start()
- Example (Advanced - Pre-Loaded Config):
>>> # For performance optimization when config already loaded >>> config_map = load_configs("configs/pipeline.json") >>> >>> pipeline = compile_single_node_to_pipeline( ... dag=my_dag, ... config_path="configs/pipeline.json", ... target_node="train", ... manual_inputs={"input_path": "s3://..."}, ... config_map=config_map, # Pass pre-loaded config ... sagemaker_session=session, ... role=role ... )
- Benefits:
28% time savings on debugging failed pipelines
33% cost savings by avoiding redundant computation
3× faster iteration cycles during development
API consistency with compile_dag_to_pipeline()