diff --git a/hamilton/execution/graph_functions.py b/hamilton/execution/graph_functions.py index 3a86d8b60..4cdc1cf13 100644 --- a/hamilton/execution/graph_functions.py +++ b/hamilton/execution/graph_functions.py @@ -205,6 +205,15 @@ def dfs_traverse( result = None success = True pre_node_execute_errored = False + # TODO -- take everything from HERE to THERE + # Put it in a function + # That function should take an adapter as well as a node + other params (run_id, kwargs, etc...) + # And output result + # Then call the lifecycle method you created called do_remote_execute using the recipe below (call_lifecycle_method) + # And delegate to that + # only under if adapter.does_method("do_remote_execute") + # Otherwise just call the function we just defined + ##### HERE ###### try: if adapter.does_hook("pre_node_execute", is_async=False): try: @@ -254,6 +263,7 @@ def dfs_traverse( message = create_error_message(kwargs, node_, "[post-node-execute]") logger.exception(message) raise + ##### THERE ##### computed[node_.name] = result # > pruning the graph diff --git a/hamilton/lifecycle/base.py b/hamilton/lifecycle/base.py index ef9d07387..48c24fee7 100644 --- a/hamilton/lifecycle/base.py +++ b/hamilton/lifecycle/base.py @@ -496,7 +496,10 @@ async def pre_node_execute( """ pass - +# TODO -- copy this + name it `BaseDoRemoteExecute` and `do_remote_execute` (for the string/function) +# Look at the comments in graph_functions.py for what parameters to add +# Add the right parameters +# Add some docstrings @lifecycle.base_method("do_node_execute") class BaseDoNodeExecute(abc.ABC): @abc.abstractmethod diff --git a/hamilton/plugins/h_ray.py b/hamilton/plugins/h_ray.py index 0f0692803..55fbb5c95 100644 --- a/hamilton/plugins/h_ray.py +++ b/hamilton/plugins/h_ray.py @@ -49,7 +49,11 @@ def parse_ray_remote_options_from_tags(tags: typing.Dict[str, str]) -> typing.Di return ray_options - +# TODO -- change the base classes here to be the underlying ones in HamiltonGraphAdapter +# BaseDoRemoteExecute, # Change this one -- add it in +# BaseDoValidateInput, +# BaseDoCheckEdgeTypesMatch, +# Then, implement do_remote_execute, kill do_node_execute class RayGraphAdapter(base.HamiltonGraphAdapter, base.ResultMixin): """Class representing what's required to make Hamilton run on Ray.