PrefectHQ / prefect-aws

Prefect integrations with AWS.
https://PrefectHQ.github.io/prefect-aws/
Apache License 2.0
85 stars 40 forks source link

Error in version 0.4.8: TypeError: unhashable type: 'dict' #372

Closed obendidi closed 10 months ago

obendidi commented 10 months ago

Latest release introduced client caching, and it hashes the credentials parameters for that (see https://github.com/PrefectHQ/prefect-aws/pull/369)

This introduced a bug, when I upgraded to prefect-aws==0.4.8:

  File "/home/user/lib/flows/my_flow.py", line 64, in my_flow
    s3: S3Client = aws_block.get_client("s3")
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/lib/.venv/lib/python3.11/site-packages/prefect/events/instrument.py", line 73, in inner
    raise exc
  File "/home/user/lib/.venv/lib/python3.11/site-packages/prefect/events/instrument.py", line 70, in inner
    return function(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/lib.venv/lib/python3.11/site-packages/prefect_aws/credentials.py", line 170, in get_client
    return _get_client_cached(ctx=self, client_type=client_type)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/lib.venv/lib/python3.11/site-packages/prefect_aws/credentials.py", line 121, in __hash__
    hash(frozenset(self.aws_client_parameters.dict().items())),
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: unhashable type: 'dict'

The usage of hash(frozenset()) seems correct to me, so maybe it's a backward compatibility issue ? I upgraded from a pretty old version ~0.2

Expectation / Proposal

Traceback / Example

zzstoatzz commented 10 months ago

hi @obendidi - thanks for the issue. looking into this now

would you be able to share the shape of what you have stored in your aws_client_parameters?

zzstoatzz commented 10 months ago

reopening until the release is actually cut

zzstoatzz commented 10 months ago

hi @obendidi - prefect-aws v0.4.9 has now been released which should fix the hashing problem you raised here.

See #373 for details on the fix