Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update graph_functions.py #1097

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions hamilton/execution/graph_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion hamilton/lifecycle/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion hamilton/plugins/h_ray.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down