File: app.py

package info (click to toggle)
python-parsl 2025.01.13%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 12,072 kB
  • sloc: python: 23,817; makefile: 349; sh: 276; ansic: 45
file content (36 lines) | stat: -rw-r--r-- 1,425 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import argparse
import os

from flask import Flask

from parsl.monitoring.visualization.models import db


def cli_run():
    """ Instantiates the Monitoring viz server
    """
    parser = argparse.ArgumentParser(description='Parsl visualization tool')
    parser.add_argument('db_path', type=str, default="sqlite:///{cwd}/runinfo/monitoring.db".format(cwd=os.getcwd()),
                        nargs="?", help='Database path in the format sqlite:///<absolute_path_to_db>')
    parser.add_argument('-p', '--port', type=int, default=8080,
                        help='Port at which the monitoring Viz Server is hosted. Default: 8080')
    parser.add_argument("-d", "--debug", action='store_true',
                        help="Enable debug logging")
    parser.add_argument("-l", "--listen", type=str, default="127.0.0.1", metavar="ADDRESS",
                        help="Choose address to listen for connections on. Default: 127.0.0.1. Choose 0.0.0.0 to listen on all addresses.")
    args = parser.parse_args()

    app = Flask(__name__)
    app.config['SQLALCHEMY_DATABASE_URI'] = args.db_path
    app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
    db.init_app(app)

    with app.app_context():
        db.create_all()
        from parsl.monitoring.visualization import views
        views.dummy = False
        app.run(host=args.listen, port=args.port, debug=args.debug)


if __name__ == "__main__":
    cli_run()