Skip to content

user_settings

UserSettingsRead

Bases: BaseModel

Schema reserved for superusers

Source code in fractal_server/app/schemas/user_settings.py
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
class UserSettingsRead(BaseModel):
    """
    Schema reserved for superusers
    """

    id: int
    ssh_host: Optional[str] = None
    ssh_username: Optional[str] = None
    ssh_private_key_path: Optional[str] = None
    ssh_tasks_dir: Optional[str] = None
    ssh_jobs_dir: Optional[str] = None
    slurm_user: Optional[str] = None
    slurm_accounts: list[str]
    cache_dir: Optional[str] = None
    project_dir: Optional[str] = None

UserSettingsUpdate

Bases: BaseModel

Schema reserved for superusers

Source code in fractal_server/app/schemas/user_settings.py
 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
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
class UserSettingsUpdate(BaseModel, extra=Extra.forbid):
    """
    Schema reserved for superusers
    """

    ssh_host: Optional[str] = None
    ssh_username: Optional[str] = None
    ssh_private_key_path: Optional[str] = None
    ssh_tasks_dir: Optional[str] = None
    ssh_jobs_dir: Optional[str] = None
    slurm_user: Optional[str] = None
    slurm_accounts: Optional[list[StrictStr]] = None
    cache_dir: Optional[str] = None
    project_dir: Optional[str] = None

    _ssh_host = validator("ssh_host", allow_reuse=True)(
        valstr("ssh_host", accept_none=True)
    )
    _ssh_username = validator("ssh_username", allow_reuse=True)(
        valstr("ssh_username", accept_none=True)
    )
    _ssh_private_key_path = validator(
        "ssh_private_key_path", allow_reuse=True
    )(val_absolute_path("ssh_private_key_path", accept_none=True))

    _ssh_tasks_dir = validator("ssh_tasks_dir", allow_reuse=True)(
        val_absolute_path("ssh_tasks_dir", accept_none=True)
    )
    _ssh_jobs_dir = validator("ssh_jobs_dir", allow_reuse=True)(
        val_absolute_path("ssh_jobs_dir", accept_none=True)
    )

    _slurm_user = validator("slurm_user", allow_reuse=True)(
        valstr("slurm_user", accept_none=True)
    )

    @validator("slurm_accounts")
    def slurm_accounts_validator(cls, value):
        if value is None:
            return value
        for i, item in enumerate(value):
            value[i] = valstr(f"slurm_accounts[{i}]")(item)
        return val_unique_list("slurm_accounts")(value)

    @validator("cache_dir")
    def cache_dir_validator(cls, value):
        if value is None:
            return None
        validate_cmd(value)
        return val_absolute_path("cache_dir")(value)

    @validator("project_dir")
    def project_dir_validator(cls, value):
        if value is None:
            return None
        validate_cmd(value)
        return val_absolute_path("project_dir")(value)