ancient-wolf-19325
08/02/2024, 11:51 AMin simple_eager_workflow out = await add_one(x=x) File "/usr/local/lib/python3.10/site-packages/flytekit/experimental/eager_function.py", line 164, in __call__ remote_entity = self.remote.fetch_task(name=entity_name) AttributeError: 'NoneType' object has no attribute 'fetch_task'
Can anyone help?
Thanks
# Answer
The error you're encountering indicates that the remote attribute is not properly set in your eager workflow, leading to the NoneType object error when trying to fetch the task. This typically happens when the FlyteRemote object is not correctly configured or passed to the eager workflow.
To resolve this, ensure that you have correctly configured the FlyteRemote object and passed it to the eager workflow. Here's an example of how to set up and use the FlyteRemote object in an eager workflow:
1. Configure FlyteRemote: Ensure you have a proper configuration file (e.g., config.yaml) for your Flyte cluster.
2. Pass FlyteRemote to Eager Workflow: Use the remote parameter in the @eager decorator to pass the FlyteRemote object.
Here's a complete example:
from flytekit import task
from flytekit.experimental import eager
from flytekit.remote import FlyteRemote
from flytekit.configuration import Config
# Define your tasks
@task
def add_one(x: int) -> int:
return x + 1
@task
def double(x: int) -> int:
return x * 2
# Configure FlyteRemote
remote = FlyteRemote(
config=Config.auto(config_file="config.yaml"),
default_project="flytesnacks",
default_domain="development",
)
# Define your eager workflow
@eager(remote=remote)
async def simple_eager_workflow(x: int) -> int:
out = await add_one(x=x)
return await double(x=out)
# Execute the eager workflow locally
if __name__ == "__main__":
import asyncio
result = asyncio.run(simple_eager_workflow(x=5))
print(f"Result: {result}") # "Result: 12"
Make sure your config.yaml is correctly set up to point to your Flyte cluster. If you are using a sandbox cluster, you can use Config.for_sandbox() instead of Config.auto(config_file="config.yaml").
Would you like more detailed steps on setting up the configuration file or any other specific aspect?
Sources:
- flytekit.experimental.eager
Slack Link
https://flyte-org.slack.com/archives/CP2HDHKE1/p1722599457.936039 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.