:question: I have a Flow with three tasks, but I a...
# ask-community
d
I have a Flow with three tasks, but I also have 10 secrets to retrieve from Prefect Cloud. When I tried to push those retrievals a level of abstraction below the flow like:
Copy code
with Flow(FLOW_NAME, storage=STORAGE, run_config=RUN_CONFIG,) as flow:
     Task_with_secret_pulling()
The task failed with this error message: `Error during execution of task: ValueError("Could not infer an active Flow context while creating edge to <Task: LessThan>. This often means you called a task outside a
with Flow(...)
block. If you're trying to run this task outside of a Flow context, you need to call `LessThan(...).run(...)`")`. Then I brought all secrets to the flow level which created them as separate tasks, but I am curious: is it the Prefect intention to have each "get" of a Secret be a separate task?
k
Hey @Donny Flynn, a
Secret
is a special task that so if you use it outside. a Flow block, you need to use
.get()
explicitly to pull the value similar to how you can do
task.run()
inside another task. So yes the intention is for them to be separate tasks. You aren’t charged for tasks that run for below 1 second also. I’d like to say you aren’t charged for Secrets but I can confirm if you want.
👍 1
d
I just wanted to make sure that was intentional! I think it makes sense for that to be the standard, actually. I was just caught off-guard by it because I couldn't find anything in the docs. Thanks for confirming 🙂