Trivial (hello world) Flask app on OML


I am trying to run a trivial app, I added some logging too. Neither is successfull: I am getting error 503 from the app and logging does not show new entry. I am attaching the full notebook.

Any ideas?


P.S.: Somehow the upload of ipynb is blocked...


  • edited November 2020

    I am getting error 503 from the app

    In general a 503 means the app did not start properly. Perhaps an exception is thrown right early in starting up the application.

    and logging does not show new entry.

    You can get log messages from the app by adding the following to your module's create_app function. Note setting the log level to DEBUG should be done for debugging only - change the log level to ERROR after it works.

    def create_app(..., server=None):    
        import logging, traceback, sys
        from import OmegaLoggingHandler
        logger = logging.getLogger(__name__)
        handler = OmegaLoggingHandler.setup(level='DEBUG', logger=logger)
        sys.excepthook = lambda t, v, tb: [logger.error(l) for l in traceback.format_tb(tb)]

    Then in your Jupyter or other omega|ml console

    $ om runtime log -f
    2020-11-17 13:28:50,134 - - INFO - Dash is running on

    Note it doesn't matter whether the app is running locally or on apphub as all log routing is done through om.datasets. The module that does the routing is OmegaLoggingHandler . All the other parts are standard Python logging, see

    There are a few other interesting loggers that you could attach to as follows (this can provide a lot of irrelevant details, use with caution). For details on how Flask logging works, see

    for name in ('werkzeug', '', 'root'):
        logger = logging.getLogger(name) 

    It can help to test the application by running it locally. You can do this by adding the following snippet to your module's :

    from mymodule import create_app
    if __name__ == '__main__':
        # essentially as apphub does 
        server = Flask(__name__)
        create_app(server=server, uri='/apps/username/mymodule')

    Then on your console:

    $ python -m mymodule
    Dash is running on

    Open http://localhost:8050/apps/username/mymodule to see the app's page. Note the URI is created by apphub as the default name.

  • Thanks!

    I am attaching the working app for reference.

    It includes logging and the flask-restx usage.

Sign In or Register to comment.