This repository has been archived by the owner on Jul 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 37
Adds union support check when passing in inputs #173
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This code works import typing as t
import pandas as pd
def foo_union(x: t.Union[int, pd.Series]) -> t.Union[int, pd.Series]:
'''foo union'''
return x + 1
from hamilton.driver import Driver
from hamilton.base import SimplePythonGraphAdapter, DictResult
from hamilton import ad_hoc_utils
lib = ad_hoc_utils.create_temporary_module(foo_union)
initial_columns = {'x': 1}
adapter = SimplePythonGraphAdapter(DictResult)
dr = Driver(initial_columns, lib, adapter=adapter)
print(dr.execute(['foo_union'])) |
OK, I just realized, this is really not the right place to put this. Instead it should live here: Line 30 in 15271fa
|
elijahbenizzy
force-pushed
the
add_union_support
branch
from
August 15, 2022 15:13
2470c3d
to
7798f48
Compare
skrawcz
commented
Aug 15, 2022
We have two places for type stuff -- some lived in graph.py. Now they're both in type_utils. We also made a corresponding test file called test_type_utils.py.
elijahbenizzy
force-pushed
the
add_union_support
branch
from
August 15, 2022 16:07
4d70579
to
ceb6e01
Compare
Note that this does supports the following: Declared: Union[foo, bar], received foo or bar but not: Declared foo or bar, received Union[foo, bar]
elijahbenizzy
force-pushed
the
add_union_support
branch
from
August 15, 2022 16:08
ceb6e01
to
5919eac
Compare
This should fix #170. If an input function was annotated with a union, we would barf. Now it wont. This still means downstream nodes need to have the same type signature -- this doesn't change any behavior there.
LGTM - you need to approve @elijahbenizzy |
elijahbenizzy
approved these changes
Aug 15, 2022
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This should fix #170. If an input function was annotated
with a union, we would barf. Now it wont.
This still means downstream nodes need to have the same
type signature -- this doesn't change any behavior there.
Changes
Testing
Notes
Checklist
Testing checklist
Python - local testing