Skip to content

job

JobCreateV2

Bases: BaseModel

Source code in fractal_server/app/schemas/v2/job.py
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
76
77
78
79
80
class JobCreateV2(BaseModel, extra=Extra.forbid):

    first_task_index: Optional[int] = None
    last_task_index: Optional[int] = None
    slurm_account: Optional[StrictStr] = None
    worker_init: Optional[str]

    # Validators
    _worker_init = validator("worker_init", allow_reuse=True)(
        valstr("worker_init")
    )

    @validator("first_task_index", always=True)
    def first_task_index_non_negative(cls, v, values):
        """
        Check that `first_task_index` is non-negative.
        """
        if v is not None and v < 0:
            raise ValueError(
                f"first_task_index cannot be negative (given: {v})"
            )
        return v

    @validator("last_task_index", always=True)
    def first_last_task_indices(cls, v, values):
        """
        Check that `last_task_index` is non-negative, and that it is not
        smaller than `first_task_index`.
        """
        if v is not None and v < 0:
            raise ValueError(
                f"last_task_index cannot be negative (given: {v})"
            )

        first_task_index = values.get("first_task_index")
        last_task_index = v
        if first_task_index is not None and last_task_index is not None:
            if first_task_index > last_task_index:
                raise ValueError(
                    f"{first_task_index=} cannot be larger than "
                    f"{last_task_index=}"
                )
        return v

first_last_task_indices(v, values)

Check that last_task_index is non-negative, and that it is not smaller than first_task_index.

Source code in fractal_server/app/schemas/v2/job.py
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
@validator("last_task_index", always=True)
def first_last_task_indices(cls, v, values):
    """
    Check that `last_task_index` is non-negative, and that it is not
    smaller than `first_task_index`.
    """
    if v is not None and v < 0:
        raise ValueError(
            f"last_task_index cannot be negative (given: {v})"
        )

    first_task_index = values.get("first_task_index")
    last_task_index = v
    if first_task_index is not None and last_task_index is not None:
        if first_task_index > last_task_index:
            raise ValueError(
                f"{first_task_index=} cannot be larger than "
                f"{last_task_index=}"
            )
    return v

first_task_index_non_negative(v, values)

Check that first_task_index is non-negative.

Source code in fractal_server/app/schemas/v2/job.py
50
51
52
53
54
55
56
57
58
59
@validator("first_task_index", always=True)
def first_task_index_non_negative(cls, v, values):
    """
    Check that `first_task_index` is non-negative.
    """
    if v is not None and v < 0:
        raise ValueError(
            f"first_task_index cannot be negative (given: {v})"
        )
    return v

JobStatusTypeV2

Bases: str, Enum

Define the available job statuses

Attributes:

Name Type Description
SUBMITTED

The job was created. This does not guarantee that it was also submitted to an executor (e.g. other errors could have prevented this), nor that it is actually running (e.g. SLURM jobs could be still in the queue).

DONE

The job successfully reached its end.

FAILED

The workflow terminated with an error.

Source code in fractal_server/app/schemas/v2/job.py
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
class JobStatusTypeV2(str, Enum):
    """
    Define the available job statuses

    Attributes:
        SUBMITTED:
            The job was created. This does not guarantee that it was also
            submitted to an executor (e.g. other errors could have prevented
            this), nor that it is actually running (e.g. SLURM jobs could be
            still in the queue).
        DONE:
            The job successfully reached its end.
        FAILED:
            The workflow terminated with an error.
    """

    SUBMITTED = "submitted"
    DONE = "done"
    FAILED = "failed"