Skip to content

main

Entry point for MLTE artifact store server.

run(host, port, store_uri, catalog_uris, allowed_origins, jwt_secret)

Run the artifact store application.

Parameters:

Name Type Description Default
host str

The application host

required
port int

The application port

required
store_uri str

The store URI string

required
catalog_uris dict[str, str]

A dict of URIs for catalog stores

required
allowed_origins list[str]

A list of allowed CORS origins

required
jwt_secret str

A secret random string key used to sign tokens

required

Returns:

Type Description
int

Return code

Source code in mlte/backend/main.py
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
def run(
    host: str,
    port: int,
    store_uri: str,
    catalog_uris: dict[str, str],
    allowed_origins: list[str],
    jwt_secret: str,
) -> int:
    """
    Run the artifact store application.
    :param host: The application host
    :param port: The application port
    :param store_uri: The store URI string
    :param catalog_uris: A dict of URIs for catalog stores
    :param allowed_origins: A list of allowed CORS origins
    :param jwt_secret: A secret random string key used to sign tokens
    :return: Return code
    """
    # TODO(Kyle): use log level from arguments.
    logging.basicConfig(level=logging.INFO)

    # Resolve hosts and validate resolved origins.
    allowed_origins = util.resolve_hosts(allowed_origins)
    _ = _validate_origins(allowed_origins)
    logging.info(f"Allowed origins: {allowed_origins}")

    # The global FastAPI application
    app = app_factory.create(allowed_origins)

    # Setup all stores.
    _setup_stores(store_uri, catalog_uris)

    # Set the token signing key.
    state.set_token_key(jwt_secret)

    # Run the server
    uvicorn.run(app, host=host, port=port)
    return EXIT_SUCCESS