Hey peeps, What am I doing wrong here. I am tryi...
# ask-community
b
Hey peeps, What am I doing wrong here. I am trying to provide multiple clocks into my flow schedule ( trying with one to start off with ) but running into an error on the param. I have followed other examples, but it just isnt working here
Copy code
schedule = Schedule(
    clocks=[
        CronClock(
            cron="*/7 * * * *",
            parameter_defaults=dict(account_identifier="inrun"),
            start_date=datetime.now(tz=timezone("Australia/Brisbane")),
        )
)

with Flow(
    name="betfair_flow",
    storage=Storage().in_a_s3_bucket(),
    run_config=RunConfig().fargate_on_ecs(cpu=512, memory=2048),
    schedule=schedule,
    executor=LocalDaskExecutor(scheduler="threads"),
) as flow:
    betfair_account_identifier = Parameter("account_identifier")
Error in 🧵
Copy code
raise ValueError(
  ValueError: Flow.run did not receive the following required parameters: account_identifier
FYI setting it as
parameter_defaults={"account_identifier": "inrun"},
also does not work
Oh, and I'm trying to run this flow from the cli.
j
Can you show how you’re actually running the flow? or are you waiting for the schedule to run??
b
prefect run flow -p path/to/flow
And yes, I'm waiting for the schedule
k
Parameters are not registered unless they are used in the Flow. Only tasks that are used in the flow are registered and doing
betfair_account_identifier = Parameter("account_identifier")
only calls the
init
but not the
run
. You can either use this somewhere downstream or you might be able to do
Parameter("account_identifier")()
b
I'm a bit confused @Kevin Kho. I actually haven't registered this flow yet. I'm just trying to run it locally to make sure it works.
And the param is used in the flow, I just removed the logic to show a shorter post.
k
Do you use
betfair_account_identifier
somewhere in the flow?
b
Yes
It is vital, hence why I'm using it as a parameter
k
How do you call
flow.run()
? Do you pass it in or you’re relying on the default?
b
I'm running it from the cli
k
Do you pass
--param key=value
?
b
No, I assumed that it picks up the schedule, like it usually does with the cli?
If I run a flow with the cli it says waiting for scheduled run, why would it not pick up the param then too?
k
Ahh I think this is a bug where default parameters don’t satisfy required parameters. Not 100% sure yet. I think in the mean time you can make that Parameter not required
b
I think when I made it not required it didn't work either. It's the middle of the night here. Will test in the morning. As far as I can see it wouldn't pick up the default params dict when running from the cli
k
ok will test.
requiired=False
works for me but I will explore teh issue more
b
Yeah, it ran but the param value is None. Not what you expect in the clock, right?
k
I got the default value actually O.o
Copy code
from prefect import task, Flow, Parameter
from prefect.schedules import Schedule 
from prefect.schedules.clocks import CronClock
from datetime import datetime
import prefect

schedule = Schedule(
    clocks=[
        CronClock(
            cron="* * * * *",
            parameter_defaults=dict(account_identifier="inrun"),
            start_date=datetime.now(),
        )]
)

@task
def abc(x):
    logger = prefect.context.get("logger")
    <http://logger.info|logger.info>(x)
    return x

with Flow(
    name="betfair_flow",
    schedule=schedule,
) as flow:
    betfair_account_identifier = Parameter("account_identifier", required=False)
    abc(betfair_account_identifier)

flow.run()
b
Hmm, but running from the cli is how I'm doing it. Can you please confirm you get that, too?
k
Ok I am the same as you now. My gosh I don’t know if this is two separate bugs
b
Just an idea, is it with the newer version of prefect, I've seen floating around we might have to use that flag
--with-schedule
or something like that
that didnt work
k
You still up? lol I was gonna reply later but yeah I think there is legit at least one bug here. Will write up the issue later
b
I just woke up, it is 8am here lol
you always get my timezone messed up 😆
k
I feel like you just said it was the middle of the night. I guess you barely sleep 😆
b
It was before lol. You can check your slack messages when you have an 8 month old son who never sleeps! 😂
Hey @Kevin Kho, did we end up deciding this is a bug?
I have had to run with cli command providing params. I guess that's kind of expected, but maybe it should be documented
k
What timing. Literally writing the ticket right now
b
😂
Do you ever take a break?
You're a 🤖
And thanks for the help on it!
k
I did…that’s why it’s delayed lol. But I work on other open source stuff on the weekend haha
b
Nice, thanks so much.
There was a response here btw
b
I agree with the comment. Good work @Kevin Kho