https://prefect.io logo
#best-practices
Title
# best-practices
r

Rohit

07/23/2022, 1:42 PM
Hello! Let's say I have a python script deploy.py that takes the best model from MLflow model registry and deploys it as a flask application. Is there a simple way I can add this script as a task in a prefect flow? Something like this:
Copy code
@task
def deploy_best_model():
      python deploy.py
1
a

Anna Geller

07/23/2022, 2:23 PM
In theory yes, you could use prefect-shell collection but I worry where would this flask app be deployed then? Prefect won't serve a flask application
r

Rohit

07/23/2022, 2:54 PM
@Anna Geller Hi Anna, I would like the flask application to run independent of Prefect. Just want the deployment to happen as part of the flow. Flask would run at port 9696 and prefect would run at port 4200
@Anna Geller This worked for me:
Copy code
@task
def deploy_best_model():
    import subprocess
    subprocess.run(["python", "deploy.py"])
a

Anna Geller

07/23/2022, 6:14 PM
in that case, it might work, have you tried running it?
r

Rohit

07/24/2022, 1:32 AM
yes it works! thanks!
🙌 1
8 Views