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

Sketches possible fix to help #1124 #1125

Draft
wants to merge 1 commit 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
11 changes: 7 additions & 4 deletions hamilton/function_modifiers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -784,10 +784,13 @@ def _add_original_function_to_nodes(fn: Callable, nodes: List[node.Node]) -> Lis
out = []
for node_ in nodes:
current_originating_functions = node_.originating_functions
new_originating_functions = (
current_originating_functions if current_originating_functions is not None else ()
) + (fn,)
out.append(node_.copy_with(originating_functions=new_originating_functions))
if current_originating_functions and fn not in current_originating_functions:
new_originating_functions = (
current_originating_functions if current_originating_functions is not None else ()
) + (fn,)
out.append(node_.copy_with(originating_functions=new_originating_functions))
else:
out.append(node_)
return out


Expand Down
13 changes: 9 additions & 4 deletions hamilton/function_modifiers/expanders.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,16 +265,21 @@ def replacement_function(
new_input_types[param] = (
val # We just use the standard one, nothing is getting replaced
)
partial_func = functools.partial(
replacement_function,
**{parameter: val.value for parameter, val in literal_dependencies.items()},
)
nodes.append(
node_.copy_with(
name=output_node,
doc_string=docstring, # TODO -- change docstring
callabl=functools.partial(
replacement_function,
**{parameter: val.value for parameter, val in literal_dependencies.items()},
),
callabl=partial_func,
input_types=new_input_types,
include_refs=False, # Include refs is here as this is earlier than compile time
originating_functions=(
fn,
partial_func,
),
# TODO -- figure out why this isn't getting replaced later...
)
)
Expand Down