Skip to content

_python_interpreter

get_python_interpreter_or_422(*, python_version, resource)

Verify that the requested Python version is available for this resource.

PARAMETER DESCRIPTION
python_version

TYPE: str

resource

TYPE: Resource

Source code in fractal_server/app/routes/aux/_python_interpreter.py
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
def get_python_interpreter_or_422(
    *,
    python_version: str,
    resource: Resource,
) -> str:
    """
    Verify that the requested Python version is available for this resource.

    Args:
        python_version:
        resource:
    """
    try:
        return get_python_interpreter(
            python_version=python_version,
            resource=resource,
        )
    except ValueError:
        raise HTTPException(
            status_code=status.HTTP_422_UNPROCESSABLE_CONTENT,
            detail=(
                f"Python version {python_version} "
                "is not available for this Fractal resource."
            ),
        )