Skip to content

main

check_settings()

Check and register the settings

Verify the consistency of the settings, in particular that required variables are set.

RAISES DESCRIPTION
ValidationError

If the configuration is invalid.

Source code in fractal_server/main.py
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
def check_settings() -> None:
    """
    Check and register the settings

    Verify the consistency of the settings, in particular that required
    variables are set.

    Raises:
        ValidationError: If the configuration is invalid.
    """
    settings = Inject(get_settings)
    db_settings = Inject(get_db_settings)
    email_settings = Inject(get_email_settings)
    data_settings = Inject(get_data_settings)
    logger = set_logger("fractal_server_settings")
    logger.debug("Fractal Settings:")
    for key, value in chain(
        db_settings.model_dump().items(),
        settings.model_dump().items(),
        email_settings.model_dump().items(),
        data_settings.model_dump().items(),
    ):
        if any(s in key.upper() for s in ["PASSWORD", "SECRET", "KEY"]):
            value = "*****"
        logger.debug(f"  {key}: {value}")
    reset_logger_handlers(logger)

collect_routers(app)

Register the routers to the application

PARAMETER DESCRIPTION
app

The application to register the routers to.

TYPE: FastAPI

Source code in fractal_server/main.py
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
def collect_routers(app: FastAPI) -> None:
    """
    Register the routers to the application

    Args:
        app:
            The application to register the routers to.
    """
    from .app.routes.api import router_api
    from .app.routes.api.v2 import router_api_v2
    from .app.routes.admin.v2 import router_admin_v2
    from .app.routes.auth.router import router_auth

    app.include_router(router_api, prefix="/api")
    app.include_router(router_api_v2, prefix="/api/v2")
    app.include_router(
        router_admin_v2, prefix="/admin/v2", tags=["V2 Admin area"]
    )
    app.include_router(router_auth, prefix="/auth", tags=["Authentication"])

start_application()

Create the application, initialise it and collect all available routers.

RETURNS DESCRIPTION
app

The fully initialised application.

TYPE: FastAPI

Source code in fractal_server/main.py
133
134
135
136
137
138
139
140
141
142
143
def start_application() -> FastAPI:
    """
    Create the application, initialise it and collect all available routers.

    Returns:
        app:
            The fully initialised application.
    """
    app = FastAPI(lifespan=lifespan)
    collect_routers(app)
    return app