How can I setup my Dash application as a scheduled run in Domino?

zach.ingrahamzach.ingraham Administrator, Moderator, Domino Posts: 34 admin
edited August 1 in How-To Guides


Tagged:

Answers

  • aaron.grubergaaron.gruberg Member, Moderator, Domino Posts: 4 mod

    This is possible by adding the following files app.py and requirements.txt to your project.This is possible using a function in Domino's Python API call app_publish(). 

    There is a written a script which takes advantage of this. To do so, simply:

    • Upload app.py and requirements.txt(described below) into your project files.
    • Create a scheduled job with the following command:
    • Then, schedule this to run whenever you'd like your app to republish.
    • Note, there will be a few minutes between the old instance shutting down and the new instance spinning up. 


    Additionally, if you'd like the app to shut down regularly, you can schedule a job using the command "app.py off"


    Here are the two files you will need.

    app.py

    from domino import Domino
    import os
    import sys
    
    
    action = sys.argv[1]
    
    
    domino = Domino(os.environ['DOMINO_PROJECT_OWNER'] + "/" + os.environ['DOMINO_PROJECT_NAME'],
                    api_key=os.environ['DOMINO_USER_API_KEY'],
                    host=os.environ['DOMINO_API_HOST'])
     
    if action == "on":
        domino.app_publish()
    elif action == "off":
        domino.app_unpublish()
    else:
        raise ValueError('This script uses the format: app.py [on]/[off]')
    

    requirements.txt

    git+https://github.com/dominodatalab/python-domino.git
    


Sign In or Register to comment.