hi guys when i do ```def container(p): return ...
# prefect-community
s
hi guys when i do
Copy code
def container(p):
    return CreateContainer(image_name="image", command=f"--p={p}")

start = StartContainer()

with Flow("flow") as flow:
    p = Parameter('param', required=True)

    c = container(p)
    start_container = start(container_id=c)
i get
<Parameter: p>
interpolated for
p
instead of the actual value for p but if i make
container
a
@task
it also gives weird errors i think because
CreateContainer
is itself already a task?
but with parameters
this seems to require dependent tasks as
CreateContainer
depends on the output of
Parameter
which seems a little overkill given that i simply want to parametrise my flows, not perform any sophisticated dynamic DAG shenanigans
ok it works when i define
start
instead like this
Copy code
@task
def start(i):
     return StartContainer(container_id=i)
and add
@task
to
container
also
works, but feels like i’m jumping hoops or working against the grain of prefect somehow
no actually it doesn’t work
Copy code
Unexpected error: ValueError('Could not infer an active Flow context.')
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/prefect/engine/runner.py", line 48, in inner
    new_state = method(self, state, *args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/prefect/engine/task_runner.py", line 822, in get_task_run_state
    value = timeout_handler(
  File "/usr/local/lib/python3.8/site-packages/prefect/utilities/executors.py", line 188, in timeout_handler
    return fn(*args, **kwargs)
  File "crdf.py", line 65, in start
  File "/usr/local/lib/python3.8/site-packages/prefect/core/task.py", line 475, in __call__
    new.bind(
  File "/usr/local/lib/python3.8/site-packages/prefect/core/task.py", line 528, in bind
    raise ValueError("Could not infer an active Flow context.")
ValueError: Could not infer an active Flow context.
because it should have been
StartContainer()(container_id=i)