https://prefect.io logo
Title
k

Kolapo Obajuluwa

02/16/2023, 5:32 PM
Hello awesome people!! So I'm currently using prefect to orchestrate an ETL pipeline for a job take-home task and I was wondering if there's ANY way, I mean ANY way to make prefect work with command line arguments 😭😭
r

redsquare

02/16/2023, 5:36 PM
Define 'make it work' there is a cli for most things https://docs.prefect.io/tutorials/deployments/#deployment-creation-with-the-prefect-cli
:upvote: 1
k

Kolapo Obajuluwa

02/16/2023, 6:16 PM
I mean being able to parse command line arguments with argparse for example, at the
python myFlow.py
call
So python myFlow.py --name fiddleWinks
n

Nate

02/16/2023, 7:09 PM
Hi @Kolapo Obajuluwa if you're wanting to run a flow locally, simplest way would just be to use
sys.argv
like (or you could use argparse similarly)
@flow(log_prints=True)
def my_flow(arg):
   print(arg)

if __name__ == "__main__":
   my_flow(sys.argv[1])
and you could invoke that like
python my_flow_file.py "hello world"
and if you wanted to run a deployment via CLI you could do
prefect deployment run myflow/mydeployment --params '{"arg": "hello world"}'
k

Kolapo Obajuluwa

02/16/2023, 8:42 PM
I just realised the problem was more my OOP than prefect
I shall delete my question and retire to a life of shame and solitude now
Thanks so much @Nate, you're awesome!
n

Nate

02/16/2023, 8:43 PM
ha! no need, all questions are welcome here 🙂 feel free to ask anything else, anytime!