How can I programmatically tell if my code is running in a model or not?

zach.ingrahamzach.ingraham Member, Administrator, Moderator, Domino Posts: 42 admin
I want my code to behave differently while I'm developing it in Jupyterlab than it does when live as a model, but I don't want to manually edit a true/false variable every time. Is there a smart way to do this programmatically? 


  • Member, Domino Posts: 4
    edited May 2019
    Here's a sample python snippet you can use to determine if you're in a model:
    import os 
    Domino injects a handful of useful environment variables into your runs - you can use the `HOSTNAME` environment variable to tell if you're inside a model. 

    In a Domino model, it will look like model-<hash>​, for example: 

    In a Domino run, it will look like domino-run-<hash>, for example:
    When running locally, it won't exist unless you've created it on your machine. 
Sign In or Register to comment.