plugins.h_rich.RichProgressBarΒΆ
Provides a progress bar for Hamilton execution. Must have rich installed to use it:
pip install sf-hamilton[rich] (use quotes if using zsh)
- class hamilton.plugins.h_rich.RichProgressBar(run_desc: str = '', collect_desc: str = '', columns: list[str | ProgressColumn] | None = None, **kwargs)ΒΆ
An adapter that uses rich to show simple progress bars for the graph execution.
Note: you need to have rich installed for this to work. If you donβt have it installed, you can install it with pip install rich (or pip install sf-hamilton[rich] β use quotes if youβre using zsh).
from hamilton import driver from hamilton.plugins import h_rich dr = ( driver.Builder() .with_config({}) .with_modules(some_modules) .with_adapters(h_rich.RichProgressBar()) .build() )
and then when you call .execute() or .materialize() youβll get a progress bar!
Additionally, this progress bar will also work with task-based execution, showing the progress of overall execution as well as the tasks within a parallelized group.
from hamilton import driver from hamilton.execution import executors from hamilton.plugins import h_rich dr = ( driver.Builder() .with_modules(__main__) .enable_dynamic_execution(allow_experimental_mode=True) .with_adapters(RichProgressBar()) .with_local_executor(executors.SynchronousLocalTaskExecutor()) .with_remote_executor(executors.SynchronousLocalTaskExecutor()) .build() )
- __init__(run_desc: str = '', collect_desc: str = '', columns: list[str | ProgressColumn] | None = None, **kwargs) None ΒΆ
Create a new Rich Progress Bar adapter.
- Parameters:
run_desc β The description to show for the running phase.
collect_desc β The description to show for the collecting phase (if applicable).
columns β Column configuration for the progress bar. See rich docs for more info.
kwargs β Additional kwargs to pass to rich.progress.Progress. See rich docs for more info.
- post_graph_execute(*, run_id: str, graph: FunctionGraph, success: bool, error: Exception | None, results: Dict[str, Any] | None)ΒΆ
Just delegates to the interface method, passing in the right data.
- post_node_execute(*, run_id: str, node_: Node, kwargs: Dict[str, Any], success: bool, error: Exception | None, result: Any | None, task_id: str | None = None)ΒΆ
Wraps the after_execution method, providing a bridge to an external-facing API. Do not override this!
- post_task_execute(*, run_id: str, task_id: str, nodes: List[Node], results: Dict[str, Any] | None, success: bool, error: Exception, spawning_task_id: str | None, purpose: None)ΒΆ
Hook called immediately after task execution. Note that this is only useful in dynamic execution, although we reserve the right to add this back into the standard hamilton execution pattern.
- Parameters:
run_id β ID of the run, unique in scope of the driver.
task_id β ID of the task
nodes β Nodes that were executed
results β Results of the task
success β Whether or not the task executed successfully
error β The error that was raised, if any
spawning_task_id β ID of the task that spawned this task
purpose β Purpose of the current task group
- post_task_expand(*, run_id: str, task_id: str, parameters: Dict[str, Any])ΒΆ
Hook that is called immediately after a task is expanded into parallelizable tasks. Note that this is only useful in dynamic execution.
- Parameters:
run_id β ID of the run, unique in scope of the driver.
task_id β ID of the task.
parameters β Parameters that are being passed to each of the expanded tasks.
- post_task_group(*, run_id: str, task_ids: List[str])ΒΆ
Hook that is called immediately after a task group is created. Note that this is only useful in dynamic execution, although we reserve the right to add this back into the standard hamilton execution pattern.
- Parameters:
run_id β ID of the run, unique in scope of the driver.
task_ids β IDs of tasks that are in the group.
- pre_graph_execute(*, run_id: str, graph: FunctionGraph, final_vars: List[str], inputs: Dict[str, Any], overrides: Dict[str, Any])ΒΆ
Implementation of the pre_graph_execute hook. This just converts the inputs to the format the user-facing hook is expecting β performing a walk of the DAG to pass in the set of nodes to execute. Delegates to the interface method.
- pre_node_execute(*, run_id: str, node_: Node, kwargs: Dict[str, Any], task_id: str | None = None)ΒΆ
Wraps the before_execution method, providing a bridge to an external-facing API. Do not override this!
- pre_task_execute(*, run_id: str, task_id: str, nodes: List[Node], inputs: Dict[str, Any], overrides: Dict[str, Any], spawning_task_id: str | None, purpose: None)ΒΆ
Hook that is called immediately prior to task execution. Note that this is only useful in dynamic execution, although we reserve the right to add this back into the standard hamilton execution pattern.
- Parameters:
run_id β ID of the run, unique in scope of the driver.
task_id β ID of the task, unique in scope of the driver.
nodes β Nodes that are being executed
inputs β Inputs to the task
overrides β Overrides to task execution
spawning_task_id β ID of the task that spawned this task
purpose β Purpose of the current task group
- run_after_graph_execution(**kwargs: Any)ΒΆ
This is run after graph execution. This allows you to do anything you want after the graph executes, knowing the results of the execution/any errors.
- Parameters:
graph β Graph that is being executed
results β Results of the graph execution
error β Error that occurred, None if no error occurred
success β Whether the graph executed successfully
run_id β Run ID (unique in process scope) of the current run. Use this to track state.
future_kwargs β Additional keyword arguments β this is kept for backwards compatibility
- run_after_node_execution(**kwargs)ΒΆ
Hook that is executed post node execution.
- Parameters:
node_name β Name of the node in question
node_tags β Tags of the node
node_kwargs β Keyword arguments passed to the node
node_return_type β Return type of the node
result β Output of the node, None if an error occurred
error β Error that occurred, None if no error occurred
success β Whether the node executed successfully
task_id β The ID of the task, none if not in a task-based environment
run_id β Run ID (unique in process scope) of the current run. Use this to track state.
future_kwargs β Additional keyword arguments β this is kept for backwards compatibility
- run_after_task_execution(*, purpose: NodeGroupPurpose, **kwargs)ΒΆ
Runs after all of the nodes associated with a task have been executed. By definition this is run inside of the executor and therefore may be run on separate or distributed processes.
- Parameters:
task_id β ID of the task that was just executed
run_id β ID of the run this was under.
nodes β Nodes that were part of this task
results β Results of the task, per-node
success β Whether the task was successful
error β The error the task threw, if any
future_kwargs β Reserved for backwards compatibility.
spawning_task_id β ID of the task that spawned this task
purpose β Purpose of the current task group
- run_after_task_expansion(*, parameters: dict[str, Any], **kwargs)ΒΆ
Runs after task expansion in Parallelize/Collect blocks. This allows you to capture information about the task that was expanded.
- Parameters:
run_id β ID of the run, unique in scope of the driver.
task_id β ID of the task that was expanded.
parameters β Parameters that were passed to the task.
future_kwargs β Additional keyword arguments β this is kept for backwards compatibility.
- run_after_task_grouping(*, task_ids: List[str], **kwargs)ΒΆ
Runs after task grouping. This allows you to capture information about which tasks were created for a given run.
- Parameters:
run_id β ID of the run, unique in scope of the driver.
task_ids β List of tasks that were grouped together.
future_kwargs β Additional keyword arguments β this is kept for backwards compatibility.
- run_before_graph_execution(*, execution_path: Collection[str], **kwargs: Any)ΒΆ
This is run prior to graph execution. This allows you to do anything you want before the graph executes, knowing the basic information that was passed in.
- Parameters:
graph β Graph that is being executed
final_vars β Output variables of the graph
inputs β Input variables passed to the graph
overrides β Overrides passed to the graph
execution_path β Collection of nodes that will be executed β these are just the nodes (not input nodes) that will be run during the course of execution.
run_id β Run ID (unique in process scope) of the current run. Use this to track state.
future_kwargs β Additional keyword arguments β this is kept for backwards compatibility
- run_before_node_execution(**kwargs)ΒΆ
Hook that is executed prior to node execution.
- Parameters:
node_name β Name of the node.
node_tags β Tags of the node
node_kwargs β Keyword arguments to pass to the node
node_return_type β Return type of the node
task_id β The ID of the task, none if not in a task-based environment
run_id β Run ID (unique in process scope) of the current run. Use this to track state.
node_input_types β the input types to the node and what it is expecting
future_kwargs β Additional keyword arguments β this is kept for backwards compatibility
- run_before_task_execution(*, purpose: NodeGroupPurpose, **kwargs)ΒΆ
Runs prior to any of the nodes associated with a task. By definition this is run inside of the executor and therefore may be run on separate or distributed processes.
- Parameters:
task_id β ID of the task weβre launching.
run_id β ID of the run this is under.
nodes β Nodes that are part of this task
inputs β Inputs to the task
overrides β Overrides passed to the task
future_kwargs β Reserved for backwards compatibility.
spawning_task_id β ID of the task that spawned this task
purpose β Purpose of the current task group