Stas Grinberg
10/08/2024, 8:51 AMFile "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/Users/stas/PycharmProjects/data-infra-prefect/auto_scoring/functions/upload_csv_files.py", line 5, in <module>
from functions.correlation_to_snowflake import load_correlation_to_snowflake
File "/Users/stas/PycharmProjects/data-infra-prefect/auto_scoring/functions/correlation_to_snowflake.py", line 5, in <module>
database = JSON.load("auto-scoring").value["database"]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'coroutine' object has no attribute 'value'
An exception occurred.
sys:1: RuntimeWarning: coroutine 'Block.load' was never awaited
Marvin
10/08/2024, 9:05 AMAttributeError: 'coroutine' object has no attribute 'value'
, usually indicates that you're trying to access properties of a coroutine object without awaiting it, which is necessary in asynchronous programming.
Here's a breakdown of the issue and how it might be resolved:
1. Understanding the Error:
- The error suggests that the Block.load("auto-scoring")
function returns a coroutine. In Python, coroutines need to be awaited to execute and get their resolved value.
2. Resolving the Error:
- In Prefect, Block.load()
is typically an asynchronous method in versions where Prefect uses asyncio
for concurrency.
- You should await
the coroutine to get its value. This can be done inside an asynchronous function.
Here is a general way to adjust your code:
python
import asyncio
from functions.correlation_to_snowflake import load_correlation_to_snowflake
async def load_database_config():
# Await the coroutine to get the result
database_block = await JSON.load("auto-scoring")
database = database_block.value["database"]
return database
# If you need to run this asynchronously, do something like:
asyncio.run(load_database_config())
### Key Steps:
- Change to Asynchronous: Wrap your blocking code such that it makes room for await
.
- Use async
and await
: Convert the function into an asynchronous function if it's not yet, and insert await
before the coroutine call.
### Further Assistance:
- Make sure your environment is setup to support running asynchronous functions.
- Ensure you are using compatible Prefect version syntax, as async and sync methods may differ.
If you tell me the specific Prefect version you're using, I can tailor this guidance further for you.Bring your towel and join one of the fastest growing data communities. Welcome to our second-generation open source orchestration platform, a completely rethought approach to dataflow automation.
Powered by