Skip to content

models

SingleImage

Bases: SingleImageBase

SingleImageBase, with scalar attributes values (None excluded).

Source code in fractal_server/images/models.py
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
class SingleImage(SingleImageBase):
    """
    `SingleImageBase`, with scalar `attributes` values (`None` excluded).
    """

    @validator("attributes")
    def validate_attributes(
        cls, v: dict[str, Any]
    ) -> dict[str, Union[int, float, str, bool]]:
        for key, value in v.items():
            if not isinstance(value, (int, float, str, bool)):
                raise ValueError(
                    f"SingleImage.attributes[{key}] must be a scalar "
                    f"(int, float, str or bool). Given {value} ({type(value)})"
                )
        return v

SingleImageBase

Bases: BaseModel

Base for SingleImage and SingleImageTaskOutput.

Attributes:

Name Type Description
zarr_url str
origin Optional[str]
attributes dict[str, Any]
types dict[str, bool]
Source code in fractal_server/images/models.py
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
class SingleImageBase(BaseModel):
    """
    Base for SingleImage and SingleImageTaskOutput.

    Attributes:
        zarr_url:
        origin:
        attributes:
        types:
    """

    zarr_url: str
    origin: Optional[str] = None

    attributes: dict[str, Any] = Field(default_factory=dict)
    types: dict[str, bool] = Field(default_factory=dict)

    # Validators
    _attributes = validator("attributes", allow_reuse=True)(
        valdictkeys("attributes")
    )
    _types = validator("types", allow_reuse=True)(valdictkeys("types"))

    @validator("zarr_url")
    def normalize_zarr_url(cls, v: str) -> str:
        return normalize_url(v)

    @validator("origin")
    def normalize_orig(cls, v: Optional[str]) -> Optional[str]:
        if v is not None:
            return normalize_url(v)

SingleImageTaskOutput

Bases: SingleImageBase

SingleImageBase, with scalar attributes values (None included).

Source code in fractal_server/images/models.py
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
class SingleImageTaskOutput(SingleImageBase):
    """
    `SingleImageBase`, with scalar `attributes` values (`None` included).
    """

    @validator("attributes")
    def validate_attributes(
        cls, v: dict[str, Any]
    ) -> dict[str, Union[int, float, str, bool, None]]:
        for key, value in v.items():
            if not isinstance(value, (int, float, str, bool, type(None))):
                raise ValueError(
                    f"SingleImageTaskOutput.attributes[{key}] must be a "
                    "scalar (int, float, str or bool). "
                    f"Given {value} ({type(value)})"
                )
        return v