Skip to content

_python_interpreter

FUNCTION DESCRIPTION
get_python_interpreter_or_422

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

Attributes

Classes

Functions:

get_python_interpreter_or_422(*, python_version, resource)

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

PARAMETER DESCRIPTION

python_version

TYPE: PythonVersion

resource

TYPE: Resource

Source code in fractal_server/app/routes/aux/_python_interpreter.py
def get_python_interpreter_or_422(
    *,
    python_version: PythonVersion,
    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."
            ),
        )