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

Follow

Comments

1 comment

  • Permanently deleted user
    Here's a sample python snippet you can use to determine if you're in a model:
    <div>import os&nbsp;</div><div>
    os.environ['HOSTNAME'].startswith('model')</div>
    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: 
    HOSTNAME=model-5cw2d57d36e0fb0107a9c5c2-7b4574f7b9-htv2r 

    In a Domino run, it will look like domino-run-<hash>, for example:
    HOSTNAME=domino-run-5ce2be3d43e0sb0107a9c5a9
    When running locally, it won't exist unless you've created it on your machine. 

    Submitted by: mac.rogers

    0
    Comment actions Permalink

Please sign in to leave a comment.