This message was deleted.
# hamilton-help
s
This message was deleted.
👀 1
e
Will look shortly!
s
@Ricard Borras I would guess that it's checking the input being passed in via
inputs=
and not thinking it matches the annotation for
input_image
.
Which could be a bug in how we're comparing.
Shouldn't be hard to repro. Mind sharing the library version?
r
sf-hamilton==1.23.1
e
@Stefan Krawczyk basic repro here:
Copy code
from PIL import Image

def foo(bar: Image) -> dict:
    return {'a' : 1}

from hamilton.ad_hoc_utils import create_temporary_module

mod = create_temporary_module(foo)

from hamilton.driver import Driver



if __name__ == "__main__":
    img = Image.open("test.png")
    dr = Driver({}, mod)
    print(dr.raw_execute(final_vars=['foo'], inputs={"bar" : img}))
If you replace the type annotation with
ImageFile.ImageFile
(:/) it works!
Copy code
from PIL import Image, ImageFile

def foo(bar: ImageFile.ImageFile) -> dict:
    return {'a' : 1}

from hamilton.ad_hoc_utils import create_temporary_module

mod = create_temporary_module(foo)

from hamilton.driver import Driver



if __name__ == "__main__":
    img = Image.open("test.png")
    dr = Driver({}, mod)
    print(dr.raw_execute(final_vars=['foo'], inputs={"bar" : img}))
Also this is using the newer pillow (I think
.read()
has been deprecated) If I were you, I’d just do in a constants file:
Copy code
ImageType = ImageFile.ImageFile
But I also suggest validating the type for your version of the pillow library or updating it
s
So @Ricard Borras I think the work around is trying change the type annotation as Elijah suggested, otherwise will dig into the discrepancy in behavior - I created https://github.com/DAGWorks-Inc/hamilton/issues/223 to track.
r
ok, thanks for your support!
🫡 2