Hey - I have a flow that has a few clocks eg ```a...
# prefect-community
b
Hey - I have a flow that has a few clocks eg
Copy code
au_harness_win_place = CronClock(
    cron="33 * * * *",
    parameter_defaults={
        "race_types": ["Harness"],
        "market_type_codes": ["WIN", "PLACE"],
        "event_type_ids": None,
        "market_countries": ["AU"],
        "table_name": "harness_market_catalogue_au"
    },
    start_date=datetime.now(tz=timezone("Australia/Brisbane")),
)
that is called like so
Copy code
with Flow(
    name="betfair_market_catalogues",
    storage=Storage.in_a_s3_bucket(),
    run_config=RunConfig().fargate_on_ecs(),
    schedule=Schedule(clocks=[au_nz_greys_win_place, au_harness_win_place]),
    executor=LocalDaskExecutor(scheduler="threads"),
) as flow:
If I want to call this via the cli it doesnt like the None values and the python objects, do I have to accept stringified versions of this or does prefect handle this on its own? eg, how would I run this locally
prefect run -p flows/market_catalogues/betfair_market_catalogues.py --param table_name="harness_market_catalogue_au" --param race_types=["Harness"] --param market_type_codes=["WIN", "PLACE"] --param event_type_ids=[] --param market_countries=["AU"]
doesnt do the job
k
I think you need to accept stringified versions as the params from CLI just come in JSON so you can’t have native Python types.
b
ah right, so I can just wrap
json.dumps
around them
let me try
k
You mean json.loads?
b
I mean for the
parameter_defaults=
do I need to do this?
Copy code
au_harness_win_place = CronClock(
    cron="33 * * * *",
    parameter_defaults={
        "race_types": json.dumps(["Harness"]),
        "market_type_codes": json.dumps(["WIN", "PLACE"]),
        "event_type_ids": json.dumps(None),
        "market_countries": json.dumps(["AU"]),
        "table_name": "harness_market_catalogue_au"
    },
    start_date=datetime.now(tz=timezone("Australia/Brisbane")),
)
is that what you mean?
k
I don’t think you need to became we handle that you register. Your problem is just an ad-hoc run with the CLI right?
Your registration with the clock should be fine
b
yes - ad hoc run
so I should json.loads everything once to run it?
I cant have a script that handles both?
k
I think you can if you do:
Copy code
with Flow(..) as flow:
    ...

if __name__ == "__main__":
    flow.run(parameters={..})
and then you can call the register using the CLI but use the main section for ad hoc runs?
b
ah ok
interesting
good option
thanks
what is the arg I need to make it not run on the scheudle again?
k
run_on_schedule=False maybe
b
thats the one