Skip to content

_pixi

PixiSLURMConfig

Bases: BaseModel

Parameters that are passed directly to a sbatch command.

See https://slurm.schedmd.com/sbatch.html.

Source code in fractal_server/tasks/config/_pixi.py
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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
69
70
71
72
73
74
75
class PixiSLURMConfig(BaseModel):
    """
    Parameters that are passed directly to a `sbatch` command.

    See https://slurm.schedmd.com/sbatch.html.
    """

    partition: NonEmptyStr
    """
    `-p, --partition=<partition_names>`
    """
    cpus: PositiveInt
    """
    `-c, --cpus-per-task=<ncpus>
    """
    mem: PixiMemoryStr | None = None
    """
    `--mem=<size>[units]` (examples: `"10M"`, `"10G"`).
    From `sbatch` docs: Specify the real memory required per node. Default
    units are megabytes. Different units can be specified using the suffix
    [K|M|G|T].
    """
    mem_per_cpu: PixiMemoryStr | None = None
    """
    `--mem-per-cpu=<size>[units]` (examples: `"10M"`, `"10G"`).
    From `sbatch` docs: Minimum memory required per usable allocated CPU.
    Default units are megabytes. [..] The --mem, --mem-per-cpu and
    --mem-per-gpu options are mutually exclusive.
    """
    time: NonEmptyStr
    """
    `-t, --time=<time>`.
    From `sbatch` docs: "A time limit of zero requests that no time limit be
    imposed. Acceptable time formats include "minutes", "minutes:seconds",
    "hours:minutes:seconds", "days-hours", "days-hours:minutes" and
    "days-hours:minutes:seconds".
    """
    preamble: list[str] = Field(default_factory=list)
    """
    Lines to be included at the beginning of the SLURM submission script.
    """

    @model_validator(mode="after")
    def _memory_validator(self: Self) -> Self:
        if (self.mem is None and self.mem_per_cpu is None) or (
            self.mem is not None and self.mem_per_cpu is not None
        ):
            raise ValueError("You must set either `mem` or `mem_per_cpu`.")
        return self

cpus instance-attribute

`-c, --cpus-per-task=

mem = None class-attribute instance-attribute

--mem=<size>[units] (examples: "10M", "10G"). From sbatch docs: Specify the real memory required per node. Default units are megabytes. Different units can be specified using the suffix [K|M|G|T].

mem_per_cpu = None class-attribute instance-attribute

--mem-per-cpu=<size>[units] (examples: "10M", "10G"). From sbatch docs: Minimum memory required per usable allocated CPU. Default units are megabytes. [..] The --mem, --mem-per-cpu and --mem-per-gpu options are mutually exclusive.

partition instance-attribute

-p, --partition=<partition_names>

preamble = Field(default_factory=list) class-attribute instance-attribute

Lines to be included at the beginning of the SLURM submission script.

time instance-attribute

-t, --time=<time>. From sbatch docs: "A time limit of zero requests that no time limit be imposed. Acceptable time formats include "minutes", "minutes:seconds", "hours:minutes:seconds", "days-hours", "days-hours:minutes" and "days-hours:minutes:seconds".

TasksPixiSettings

Bases: BaseModel

Configuration for pixi Task collection.

Source code in fractal_server/tasks/config/_pixi.py
 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
class TasksPixiSettings(BaseModel):
    """
    Configuration for `pixi` Task collection.
    """

    versions: DictStrStr
    """
    Dictionary mapping `pixi` versions (e.g. `0.47.0`) to the corresponding
    folders (e.g. `/somewhere/pixi/0.47.0` - if the binary is
    `/somewhere/pixi/0.47.0/bin/pixi`).
    """
    default_version: str
    """
    Default task-collection `pixi` version.
    """
    PIXI_CONCURRENT_SOLVES: int = 4
    """
    Value of
    [`--concurrent-solves`](https://pixi.sh/latest/reference/cli/pixi/install/#arg---concurrent-solves)
    for `pixi install`.
    """
    PIXI_CONCURRENT_DOWNLOADS: int = 4
    """
    Value of
    [`--concurrent-downloads`](https://pixi.sh/latest/reference/cli/pixi/install/#arg---concurrent-downloads)
    for `pixi install`.
    """
    TOKIO_WORKER_THREADS: int = 2
    """
    From
    [Tokio documentation](
    https://docs.rs/tokio/latest/tokio/#cpu-bound-tasks-and-blocking-code
    )
    :

        The core threads are where all asynchronous code runs,
        and Tokio will by default spawn one for each CPU core.
        You can use the environment variable `TOKIO_WORKER_THREADS` to override
        the default value.
    """
    DEFAULT_ENVIRONMENT: str = "default"
    """
    Default pixi environment name.
    """
    DEFAULT_PLATFORM: str = "linux-64"
    """
    Default platform for pixi.
    """
    SLURM_CONFIG: PixiSLURMConfig | None = None
    """
    Required when using `pixi` in a SSH/SLURM deployment.
    """

    @model_validator(mode="after")
    def check_pixi_settings(self):
        if self.default_version not in self.versions:
            raise ValueError(
                f"Default version '{self.default_version}' not in "
                f"available version {list(self.versions.keys())}."
            )

        pixi_base_dir = Path(self.versions[self.default_version]).parent

        for key, value in self.versions.items():
            pixi_path = Path(value)

            if pixi_path.parent != pixi_base_dir:
                raise ValueError(
                    f"{pixi_path=} is not located within the {pixi_base_dir=}."
                )
            if pixi_path.name != key:
                raise ValueError(f"{pixi_path.name=} is not equal to {key=}")

        return self

DEFAULT_ENVIRONMENT = 'default' class-attribute instance-attribute

Default pixi environment name.

DEFAULT_PLATFORM = 'linux-64' class-attribute instance-attribute

Default platform for pixi.

PIXI_CONCURRENT_DOWNLOADS = 4 class-attribute instance-attribute

Value of --concurrent-downloads for pixi install.

PIXI_CONCURRENT_SOLVES = 4 class-attribute instance-attribute

Value of --concurrent-solves for pixi install.

SLURM_CONFIG = None class-attribute instance-attribute

Required when using pixi in a SSH/SLURM deployment.

TOKIO_WORKER_THREADS = 2 class-attribute instance-attribute

From Tokio documentation :

The core threads are where all asynchronous code runs,
and Tokio will by default spawn one for each CPU core.
You can use the environment variable `TOKIO_WORKER_THREADS` to override
the default value.

default_version instance-attribute

Default task-collection pixi version.

versions instance-attribute

Dictionary mapping pixi versions (e.g. 0.47.0) to the corresponding folders (e.g. /somewhere/pixi/0.47.0 - if the binary is /somewhere/pixi/0.47.0/bin/pixi).