Skip to content

initialized_project_verification

Client and Project initialization verification.

Functions:

Name Description
initialized_project_verification

Check if a project is initialized. Used as a decorator.

initialized_project_verification(func: Callable[__PT, __RT]) -> Callable[__PT, __RT] #

Check if a project is initialized. Used as a decorator.

Source code in src/xpdeep/utils/initialized_project_verification.py
def initialized_project_verification(func: Callable[__PT, __RT]) -> Callable[__PT, __RT]:
    """Check if a project is initialized. Used as a decorator."""

    @wraps(func)
    def wrapper(*args: __PT.args, **kwargs: __PT.kwargs) -> __RT:
        try:
            Project.CURRENT.get()
        except LookupError as err:
            msg = "Current project is not set"
            raise RuntimeError(msg) from err

        if "model" not in vars(Project.CURRENT.get()):
            msg = "Current project deleted"
            raise RuntimeError(msg)

        return func(*args, **kwargs)

    return wrapper