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

TypeError: object str can't be used in 'await' expression with S3 storage in 3.1.7 #16428

Closed
zhen0 opened this issue Dec 17, 2024 · 1 comment · Fixed by #16445
Closed

TypeError: object str can't be used in 'await' expression with S3 storage in 3.1.7 #16428

zhen0 opened this issue Dec 17, 2024 · 1 comment · Fixed by #16445
Assignees
Labels
bug Something isn't working integrations Related to integrations with other services

Comments

@zhen0
Copy link
Member

zhen0 commented Dec 17, 2024

Bug summary

I am encountering an error in Prefect 3.1.7 where using S3 storage with tasks/flows results in:
TypeError: object str can't be used in 'await' expression

The same flow code works fine (with no errors) and results are loaded to s3 on Prefect 3.1.6.

It looks as if results are loaded to s3 using 3.1.7 also but I am getting the following error in my logs:

Traceback (most recent call last):
  File "/Users/jennifer/opt/anaconda3/envs/py312/lib/python3.12/site-packages/prefect/transactions.py", line 323, in commit
    self.store.persist_result_record(
  File "/Users/jennifer/opt/anaconda3/envs/py312/lib/python3.12/site-packages/prefect/results.py", line 702, in persist_result_record
    return self._persist_result_record(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jennifer/opt/anaconda3/envs/py312/lib/python3.12/site-packages/prefect/utilities/asyncutils.py", line 349, in coroutine_wrapper
    return run_coro_as_sync(ctx_call())
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jennifer/opt/anaconda3/envs/py312/lib/python3.12/site-packages/prefect/utilities/asyncutils.py", line 209, in run_coro_as_sync
    return call.result()
           ^^^^^^^^^^^^^
  File "/Users/jennifer/opt/anaconda3/envs/py312/lib/python3.12/site-packages/prefect/_internal/concurrency/calls.py", line 330, in result
    return self.future.result(timeout=timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jennifer/opt/anaconda3/envs/py312/lib/python3.12/site-packages/prefect/_internal/concurrency/calls.py", line 193, in result
    return self.__get_result()
           ^^^^^^^^^^^^^^^^^^^
  File "/Users/jennifer/opt/anaconda3/envs/py312/lib/python3.12/concurrent/futures/_base.py", line 401, in __get_result
    raise self._exception
  File "/Users/jennifer/opt/anaconda3/envs/py312/lib/python3.12/site-packages/prefect/_internal/concurrency/calls.py", line 403, in _run_async
    result = await coro
             ^^^^^^^^^^
  File "/Users/jennifer/opt/anaconda3/envs/py312/lib/python3.12/site-packages/prefect/utilities/asyncutils.py", line 190, in coroutine_wrapper
    return await task
           ^^^^^^^^^^
  File "/Users/jennifer/opt/anaconda3/envs/py312/lib/python3.12/site-packages/prefect/utilities/asyncutils.py", line 343, in ctx_call
    result = await async_fn(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jennifer/opt/anaconda3/envs/py312/lib/python3.12/site-packages/prefect/results.py", line 685, in _persist_result_record
    await self.result_storage.write_path(
TypeError: object str can't be used in 'await' expression

Flow code:

from prefect import flow, task
from prefect_aws.s3 import S3Bucket

s3_bucket_block = S3Bucket.load("j-block")

@task(result_storage_key="hello-{parameters[name]}.pickle")
def hello_world(name: str = "world"):
    return f"hello {name}"

@flow(result_storage=s3_bucket_block)
def my_flow():
    hello_world()
    hello_world(name="bar")

if __name__ == "__main__":
    my_flow()

Version info

Version:             3.1.7
API version:         0.8.4
Python version:      3.12.3
Git commit:          c05ffa6d
Built:               Mon, Dec 16, 2024 10:06 AM
OS/Arch:             darwin/x86_64
Profile:             staging
Server type:         cloud
Pydantic version:    2.10.3
Integrations:
  prefect-ray:       0.4.0rc2
  prefect-docker:    0.6.2
  prefect-gcp:       0.6.0rc2
  prefect-aws:       0.5.3
  prefect-github:    0.3.1
  prefect-shell:     0.3.1

Additional context

No response

@zhen0 zhen0 added the bug Something isn't working label Dec 17, 2024
@zzstoatzz zzstoatzz self-assigned this Dec 18, 2024
@zzstoatzz zzstoatzz added the integrations Related to integrations with other services label Dec 18, 2024
@zzstoatzz
Copy link
Collaborator

thanks @zhen0 - taking a look!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working integrations Related to integrations with other services
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants