r

    Rohit

    2 months ago
    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:
    @task
    def deploy_best_model():
          python deploy.py
    Anna Geller

    Anna Geller

    2 months ago
    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

    2 months ago
    @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:
    @task
    def deploy_best_model():
        import subprocess
        subprocess.run(["python", "deploy.py"])
    Anna Geller

    Anna Geller

    2 months ago
    in that case, it might work, have you tried running it?
    r

    Rohit

    2 months ago
    yes it works! thanks!