Exemplo n.º 1
0
def test_get_run(tmpfilestore: FileStorage):
    """Tests the get_run function."""
    run42 = tmpfilestore.get_run(42)

    for key in [
            "info", "resources", "host", "experiment", "result", "artifacts",
            "comment", "start_time", "stop_time", "heartbeat", "captured_out",
            "config"
    ]:
        assert key in run42
Exemplo n.º 2
0
def test_get_runs(tmpfilestore: FileStorage):
    """Tests the get_runs function."""
    runs = tmpfilestore.get_runs()
    runs = list(runs)

    assert 1 == len(runs)

    run = runs[0]
    for key in [
            "info", "resources", "host", "experiment", "result", "artifacts",
            "comment", "start_time", "stop_time", "heartbeat", "captured_out",
            "config"
    ]:
        assert key in run
Exemplo n.º 3
0
def run(debug, no_browser, m, mu, mc, f, port, sub_url):
    """
    Sacredboard.

\b
Sacredboard is a monitoring dashboard for Sacred.
Homepage: http://github.com/chovanecm/sacredboard

Example usage:

\b
sacredboard -m sacred
    Starts Sacredboard on default port (5000) and connects to
    a local MongoDB database called 'sacred'. Opens web browser.
    Note: MongoDB must be listening on localhost.
\b
sacredboard -m sacred --port 9000
    Starts Sacredboard on non- default port 9000 and connects to
    a local MongoDB database called 'sacred'. Opens web browser.
    Note: MongoDB must be listening on localhost.
\b
sacredboard -m 192.168.1.1:27017:sacred
    Starts Sacredboard on default port (5000) and connects to
    a MongoDB database running on 192.168.1.1 on port 27017
    to a database called 'sacred'. Opens web browser.
\b
sacredboard -mu mongodb://user:pwd@host/admin?authMechanism=SCRAM-SHA-1 sacred
    Starts Sacredboard on default port (5000) and connects to
    a MongoDB database running on localhost on port 27017
    to a database called 'sacred'. Opens web browser.

\b
sacredboard -m sacred -mc default.runs
    Starts Sacredboard on default port (5000) and connects to
    a local MongoDB database called 'sacred' and uses the Sacred's 0.6
    default collection 'default.runs' to search the runs in.
    Opens web browser.
    Note: MongoDB must be listening on localhost.

    """
    if m or mu != (None, None):
        add_mongo_config(app, m, mu, mc)
        app.config["data"].connect()
    elif f:
        app.config["data"] = FileStorage(f)
    else:
        print("Must specify either a mongodb instance or " +
              "a path to a file storage.\nRun sacredboard --help "
              "for more information.",
              file=sys.stderr)
        sys.exit(1)

    app.config['DEBUG'] = debug
    app.debug = debug

    version = Sacredboard.get_version()
    print(version)

    app_config = {
        "http.serve_on_endpoint": sub_url,
        "http.port": port,
        "debug": debug
    }
    _initialize_modules(app_config)
    print("Starting sacredboard on port %d" % server_runner.started_on_port)
    if not no_browser:
        click.launch("http://127.0.0.1:%d" % server_runner.started_on_port)

    server_runner.run_server()
Exemplo n.º 4
0
def tmpfilestore() -> FileStorage:
    """Fixture that prepares a file store in /tmp for dependency injection."""
    dir = create_tmp_datastore()
    return FileStorage(dir)
Exemplo n.º 5
0
def run(debug, no_browser, m, mu, mc, f):
    """
    Sacredboard.

\b
Sacredboard is a monitoring dashboard for Sacred.
Homepage: http://github.com/chovanecm/sacredboard

Example usage:

\b
sacredboard -m sacred
    Starts Sacredboard on default port (5000) and connects to
    a local MongoDB database called 'sacred'. Opens web browser.
    Note: MongoDB must be listening on localhost.
\b
sacredboard -m 192.168.1.1:27017:sacred
    Starts Sacredboard on default port (5000) and connects to
    a MongoDB database running on 192.168.1.1 on port 27017
    to a database called 'sacred'. Opens web browser.
\b
sacredboard -mu mongodb://user:pwd@host/admin?authMechanism=SCRAM-SHA-1 sacred
    Starts Sacredboard on default port (5000) and connects to
    a MongoDB database running on localhost on port 27017
    to a database called 'sacred'. Opens web browser.

\b
sacredboard -m sacred -mc default.runs
    Starts Sacredboard on default port (5000) and connects to
    a local MongoDB database called 'sacred' and uses the Sacred's 0.6
    default collection 'default.runs' to search the runs in.
    Opens web browser.
    Note: MongoDB must be listening on localhost.

    """
    if m or mu != (None, None):
        add_mongo_config(app, m, mu, mc)
        app.config["data"].connect()
    elif f:
        app.config["data"] = FileStorage(f)
    else:
        print("Must specify either a mongodb instance or " +
              "a path to a file storage.\nRun sacredboard --help "
              "for more information.",
              file=sys.stderr)
        sys.exit(1)

    app.config['DEBUG'] = debug
    app.debug = debug
    jinja_filters.setup_filters(app)
    routes.setup_routes(app)
    metrics.initialize(app)

    if debug:
        app.run(host="0.0.0.0", debug=True)
    else:
        for port in range(5000, 5050):
            http_server = WSGIServer(('0.0.0.0', port), app)
            try:
                http_server.start()
            except OSError as e:
                # try next port
                continue
            print("Starting sacredboard on port %d" % port)
            if not no_browser:
                click.launch("http://127.0.0.1:%d" % port)
            http_server.serve_forever()
            break