James Phoenix
09/07/2022, 5:49 PMNate
09/07/2022, 6:04 PMJames Phoenix
09/07/2022, 6:06 PMNate
09/07/2022, 6:13 PMasyncio.run(anaylse_youtube_video)
or asyncio.run(anaylse_youtube_video())
?James Phoenix
09/07/2022, 6:24 PM@flow
async def analyse_youtube_video():
# 1. Download the video from YouTube and upload it to GCS
gcs_block = GCS.load("buffalo-raw-video-files")
# Make some fake JSON data:
data = {"name": "John", "age": 30, "city": "New York"}
return await gcs_block.write_path(
"video.mp4", data)
asyncio.run(analyse_youtube_video)
ValueError: a coroutine was expected, got <prefect.flows.Flow object at 0x7f952f49a3a0>
Nate
09/07/2022, 6:25 PMasyncio.run()
a coroutine like asyncio.run(analyse_youtube_video())
James Phoenix
09/07/2022, 6:31 PMasync def analyse_youtube_video():
# 1. Download the video from YouTube and upload it to GCS
gcs_block = await GCS.load("buffalo-raw-video-files")
# Make some fake JSON data:
data = {"name": "John", "age": 30, "city": "New York"}
return await gcs_block.write_path(
"video.mp4", json.dump(data))
asyncio.run(analyse_youtube_video())
TypeError: a bytes-like object is required, not 'str'
Nate
09/07/2022, 6:44 PMGCS.write_path
accepts a string path
argument and a content
argument of type bytes
it looks like you're trying to pass json.dump(data)
as content
, which won't work because json.dump
is for writing to files and doesn't return bytes
. you could replace json.dump(data)
with json.dumps(data).encode('utf-8')
James Phoenix
09/07/2022, 6:49 PMUserWarning: Block document has schema checksum sha256:1daf535b60cf9304103bcb4015280a30fd6bdd9686aa0c059eb9715082b5b3ec which does not match the schema checksum for class 'GCS'.
Nate
09/07/2022, 6:51 PMDominik Wagner
09/09/2022, 10:54 AMwrite_path
call forever with no error:
def test_upload():
gcs_block = GCS.load("gcs-block")
content = "abcd".encode('utf-8')
asyncio.run(gcs_block.write_path("test.txt", content))
test_upload()
Any ideas what could be the cause here, or even ideas on how to debug this?James Phoenix
09/09/2022, 11:15 AMasync def test_upload():
gcs_block.write_path("test.txt", content)
rather than using asyncio.run() inside of itDominik Wagner
09/09/2022, 11:35 AMGCS.load(block).bucket_path
šJames Phoenix
09/09/2022, 11:36 AM