Skip to content

description

description

This module contains the description of the processes a process-worker serves. It is shaped along the process description of OGC API - Processes - Part 1: Core (https://schemas.opengis.net/ogcapi/processes/part1/1.0/openapi/schemas/process.yaml), so a consumer can expose its elements as they are and only adds what belongs to the API around (links, job control options, conformance, ...).

Optional values default to None. Serialized with xsdata.formats.dataclass.serializers.dict.DictFactory.FILTER_NONE they are left out, which gives a plain JSON Schema for each Schema.

QSL_LAYER_FORMAT = 'qsl-layer' module-attribute

InputDescription dataclass

Bases: BaseInterface

The description of one input of a process.

OGC API - Processes holds the inputs as map by id. xsdata can't bind a map of dataclasses, therefore the id is part of the description and the inputs are a list.

Attributes:

  • id (str) –

    The identifier of the input, the QGIS parameter name.

  • title (str) –

    Human readable name.

  • description (str | None) –

    Human readable help text.

  • schema (Schema) –

    The schema of one value.

  • min_occurs (int) –

    The minimal number of values.

  • max_occurs (int | str) –

    The maximal number of values, unbounded for any.

Source code in src/qgis_server_light/interface/job/process/description.py
 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
@dataclass(repr=False, kw_only=True)
class InputDescription(BaseInterface):
    """The description of one input of a process.

    OGC API - Processes holds the inputs as map by id. xsdata can't bind a map of
    dataclasses, therefore the id is part of the description and the inputs are a list.

    Attributes:
        id: The identifier of the input, the QGIS parameter name.
        title: Human readable name.
        description: Human readable help text.
        schema: The schema of one value.
        min_occurs: The minimal number of values.
        max_occurs: The maximal number of values, `unbounded` for any.
    """

    id: str = field(metadata={"type": "Element"})
    title: str = field(metadata={"type": "Element"})
    description: str | None = field(default=None, metadata={"type": "Element"})
    schema: Schema = field(metadata={"type": "Element"})
    min_occurs: int = field(default=1, metadata={"type": "Element", "name": "minOccurs"})
    max_occurs: int | str = field(default=1, metadata={"type": "Element", "name": "maxOccurs"})

    @property
    def shortened_fields(self) -> set:
        return {"description"}

description: str | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute

id: str = field(metadata={'type': 'Element'}) class-attribute instance-attribute

max_occurs: int | str = field(default=1, metadata={'type': 'Element', 'name': 'maxOccurs'}) class-attribute instance-attribute

min_occurs: int = field(default=1, metadata={'type': 'Element', 'name': 'minOccurs'}) class-attribute instance-attribute

schema: Schema = field(metadata={'type': 'Element'}) class-attribute instance-attribute

shortened_fields: set property

title: str = field(metadata={'type': 'Element'}) class-attribute instance-attribute

__init__(*, id: str, title: str, description: str | None = None, schema: Schema, min_occurs: int = 1, max_occurs: int | str = 1) -> None

OutputDescription dataclass

Bases: BaseInterface

The description of one output of a process. The id is part of the description, see InputDescription.

Attributes:

  • id (str) –

    The identifier of the output, the QGIS output name.

  • title (str) –

    Human readable name.

  • schema (Schema) –

    The schema of the value.

Source code in src/qgis_server_light/interface/job/process/description.py
112
113
114
115
116
117
118
119
120
121
122
123
124
125
@dataclass(repr=False, kw_only=True)
class OutputDescription(BaseInterface):
    """The description of one output of a process. The id is part of the description,
    see `InputDescription`.

    Attributes:
        id: The identifier of the output, the QGIS output name.
        title: Human readable name.
        schema: The schema of the value.
    """

    id: str = field(metadata={"type": "Element"})
    title: str = field(metadata={"type": "Element"})
    schema: Schema = field(metadata={"type": "Element"})

id: str = field(metadata={'type': 'Element'}) class-attribute instance-attribute

schema: Schema = field(metadata={'type': 'Element'}) class-attribute instance-attribute

title: str = field(metadata={'type': 'Element'}) class-attribute instance-attribute

__init__(*, id: str, title: str, schema: Schema) -> None

ProcessDescription dataclass

Bases: BaseInterface

The description of one process.

Attributes:

  • id (str) –

    The identifier of the process, the QGIS algorithm id.

  • title (str) –

    Human readable name.

  • description (str | None) –

    Human readable help text.

  • inputs (list[InputDescription]) –

    The inputs which are passed by the client. Destinations are not part of it, they are set by the worker.

  • outputs (list[OutputDescription]) –

    The outputs the process produces.

  • internal (bool | None) –

    If the process is for internal use of the consumer only and must not be published. Left out (None) for a publishable process.

Source code in src/qgis_server_light/interface/job/process/description.py
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
@dataclass(repr=False, kw_only=True)
class ProcessDescription(BaseInterface):
    """The description of one process.

    Attributes:
        id: The identifier of the process, the QGIS algorithm id.
        title: Human readable name.
        description: Human readable help text.
        inputs: The inputs which are passed by the client. Destinations are not part of
            it, they are set by the worker.
        outputs: The outputs the process produces.
        internal: If the process is for internal use of the consumer only and must not be
            published. Left out (`None`) for a publishable process.
    """

    id: str = field(metadata={"type": "Element"})
    title: str = field(metadata={"type": "Element"})
    description: str | None = field(default=None, metadata={"type": "Element"})
    inputs: list[InputDescription] = field(default_factory=list, metadata={"type": "Element"})
    outputs: list[OutputDescription] = field(default_factory=list, metadata={"type": "Element"})
    internal: bool | None = field(default=None, metadata={"type": "Element"})

    @property
    def shortened_fields(self) -> set:
        return {"description"}

description: str | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute

id: str = field(metadata={'type': 'Element'}) class-attribute instance-attribute

inputs: list[InputDescription] = field(default_factory=list, metadata={'type': 'Element'}) class-attribute instance-attribute

internal: bool | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute

outputs: list[OutputDescription] = field(default_factory=list, metadata={'type': 'Element'}) class-attribute instance-attribute

shortened_fields: set property

title: str = field(metadata={'type': 'Element'}) class-attribute instance-attribute

__init__(*, id: str, title: str, description: str | None = None, inputs: list[InputDescription] = list(), outputs: list[OutputDescription] = list(), internal: bool | None = None) -> None

ProcessDescriptions dataclass

Bases: BaseInterface

The processes a process-worker serves (see RedisProtocol.worker_processes_key), or all process-workers together as the dispatcher merges them.

Attributes:

Source code in src/qgis_server_light/interface/job/process/description.py
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
@dataclass(repr=False)
class ProcessDescriptions(BaseInterface):
    """The processes a process-worker serves (see `RedisProtocol.worker_processes_key`),
    or all process-workers together as the dispatcher merges them.

    Attributes:
        processes: The description per process.
        warnings: The processes the workers don't agree on, only set by the dispatcher.
    """

    processes: list[ProcessDescription] = field(default_factory=list, metadata={"type": "Element"})
    warnings: list[ProcessWarning] = field(default_factory=list, metadata={"type": "Element"})

    def process_by_id(self, process_id: str) -> ProcessDescription:
        """
        Args:
            process_id: The identifier of the process.

        Raises:
            LookupError: If no process with this id is described.
        """
        for process in self.processes:
            if process.id == process_id:
                return process
        raise LookupError(f"Process `{process_id}` is not described")

processes: list[ProcessDescription] = field(default_factory=list, metadata={'type': 'Element'}) class-attribute instance-attribute

warnings: list[ProcessWarning] = field(default_factory=list, metadata={'type': 'Element'}) class-attribute instance-attribute

__init__(processes: list[ProcessDescription] = list(), warnings: list[ProcessWarning] = list()) -> None

process_by_id(process_id: str) -> ProcessDescription

Parameters:

  • process_id (str) –

    The identifier of the process.

Raises:

  • LookupError –

    If no process with this id is described.

Source code in src/qgis_server_light/interface/job/process/description.py
187
188
189
190
191
192
193
194
195
196
197
198
def process_by_id(self, process_id: str) -> ProcessDescription:
    """
    Args:
        process_id: The identifier of the process.

    Raises:
        LookupError: If no process with this id is described.
    """
    for process in self.processes:
        if process.id == process_id:
            return process
    raise LookupError(f"Process `{process_id}` is not described")

ProcessWarning dataclass

Bases: BaseInterface

Tells that the process-workers serving a process don't agree on it. They run different QGIS versions or describe the process differently, so a job behaves differently depending on the worker which takes it. The deployment needs to be corrected then.

Attributes:

  • process_id (str) –

    The identifier of the process.

  • qgis_versions (list[str]) –

    The QGIS versions of the workers serving the process, the newest first.

  • descriptions_differ (bool) –

    If the workers describe the process differently.

Source code in src/qgis_server_light/interface/job/process/description.py
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
@dataclass(repr=False, kw_only=True)
class ProcessWarning(BaseInterface):
    """Tells that the process-workers serving a process don't agree on it. They run
    different QGIS versions or describe the process differently, so a job behaves
    differently depending on the worker which takes it. The deployment needs to be
    corrected then.

    Attributes:
        process_id: The identifier of the process.
        qgis_versions: The QGIS versions of the workers serving the process, the newest
            first.
        descriptions_differ: If the workers describe the process differently.
    """

    process_id: str = field(metadata={"type": "Element"})
    qgis_versions: list[str] = field(default_factory=list, metadata={"type": "Element"})
    descriptions_differ: bool = field(default=False, metadata={"type": "Element"})

descriptions_differ: bool = field(default=False, metadata={'type': 'Element'}) class-attribute instance-attribute

process_id: str = field(metadata={'type': 'Element'}) class-attribute instance-attribute

qgis_versions: list[str] = field(default_factory=list, metadata={'type': 'Element'}) class-attribute instance-attribute

__init__(*, process_id: str, qgis_versions: list[str] = list(), descriptions_differ: bool = False) -> None

QslLayerKind

Bases: Enum

The kinds of layer QSL can load as value of a process input.

Source code in src/qgis_server_light/interface/job/process/description.py
20
21
22
23
24
class QslLayerKind(Enum):
    """The kinds of layer QSL can load as value of a process input."""

    VECTOR = "vector"
    RASTER = "raster"

RASTER = 'raster' class-attribute instance-attribute

VECTOR = 'vector' class-attribute instance-attribute

QslLayerMarker dataclass

Bases: BaseInterface

Marks a schema whose value is a layer (QslJobLayer) instead of a literal. A consumer replaces the marked schema with the layers it offers which match the marker.

Attributes:

  • kinds (list[QslLayerKind]) –

    The kinds of layer which are accepted.

  • geometry_types (list[str]) –

    The geometry types of a vector layer which are accepted, named as qgis.core.Qgis.GeometryType (Point, Line, Polygon, Null). Matches Vector.geometry_type_simple of the exported project. Applies to vector layers only, empty when no vector layer is accepted.

  • source (str | None) –

    The class name of the QGIS parameter or output the marker was derived from.

Source code in src/qgis_server_light/interface/job/process/description.py
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
@dataclass(repr=False)
class QslLayerMarker(BaseInterface):
    """Marks a schema whose value is a layer (`QslJobLayer`) instead of a literal. A
    consumer replaces the marked schema with the layers it offers which match the marker.

    Attributes:
        kinds: The kinds of layer which are accepted.
        geometry_types: The geometry types of a vector layer which are accepted, named as
            `qgis.core.Qgis.GeometryType` (`Point`, `Line`, `Polygon`, `Null`). Matches
            `Vector.geometry_type_simple` of the exported project. Applies to vector layers
            only, empty when no vector layer is accepted.
        source: The class name of the QGIS parameter or output the marker was derived from.
    """

    kinds: list[QslLayerKind] = field(metadata={"type": "Element"})
    geometry_types: list[str] = field(default_factory=list, metadata={"type": "Element"})
    source: str | None = field(default=None, metadata={"type": "Element"})

geometry_types: list[str] = field(default_factory=list, metadata={'type': 'Element'}) class-attribute instance-attribute

kinds: list[QslLayerKind] = field(metadata={'type': 'Element'}) class-attribute instance-attribute

source: str | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute

__init__(kinds: list[QslLayerKind], geometry_types: list[str] = list(), source: str | None = None) -> None

Schema dataclass

Bases: BaseInterface

The subset of JSON Schema which is used to describe the values of inputs and outputs.

Attributes:

  • type (str | None) –

    The JSON Schema type (string, number, integer, boolean, ...).

  • format (str | None) –

    The format of the value. Layer values carry QSL_LAYER_FORMAT.

  • title (str | None) –

    Human readable name, used on the entries of one_of.

  • minimum (int | float | None) –

    The inclusive minimum of a numeric value.

  • maximum (int | float | None) –

    The inclusive maximum of a numeric value.

  • const (bool | int | float | str | None) –

    The only valid value, used on the entries of one_of.

  • default (bool | int | float | str | None) –

    The value used when none is passed.

  • one_of (list[Schema] | None) –

    The valid values, each as schema with const and title. For a file output the formats it is offered in, each as schema with content_media_type, the first one is the default.

  • content_media_type (str | None) –

    The media type of a value which is a file.

  • x_qsl_layer (QslLayerMarker | None) –

    The marker of a layer value.

Source code in src/qgis_server_light/interface/job/process/description.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
@dataclass(repr=False, kw_only=True)
class Schema(BaseInterface):
    """The subset of JSON Schema which is used to describe the values of inputs and
    outputs.

    Attributes:
        type: The JSON Schema type (`string`, `number`, `integer`, `boolean`, ...).
        format: The format of the value. Layer values carry `QSL_LAYER_FORMAT`.
        title: Human readable name, used on the entries of `one_of`.
        minimum: The inclusive minimum of a numeric value.
        maximum: The inclusive maximum of a numeric value.
        const: The only valid value, used on the entries of `one_of`.
        default: The value used when none is passed.
        one_of: The valid values, each as schema with `const` and `title`. For a file
            output the formats it is offered in, each as schema with
            `content_media_type`, the first one is the default.
        content_media_type: The media type of a value which is a file.
        x_qsl_layer: The marker of a layer value.
    """

    type: str | None = field(default=None, metadata={"type": "Element"})
    format: str | None = field(default=None, metadata={"type": "Element"})
    title: str | None = field(default=None, metadata={"type": "Element"})
    minimum: int | float | None = field(default=None, metadata={"type": "Element"})
    maximum: int | float | None = field(default=None, metadata={"type": "Element"})
    const: bool | int | float | str | None = field(default=None, metadata={"type": "Element"})
    default: bool | int | float | str | None = field(default=None, metadata={"type": "Element"})
    one_of: list["Schema"] | None = field(
        default=None, metadata={"type": "Element", "name": "oneOf"}
    )
    content_media_type: str | None = field(
        default=None, metadata={"type": "Element", "name": "contentMediaType"}
    )
    x_qsl_layer: QslLayerMarker | None = field(
        default=None, metadata={"type": "Element", "name": "x-qsl-layer"}
    )

const: bool | int | float | str | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute

content_media_type: str | None = field(default=None, metadata={'type': 'Element', 'name': 'contentMediaType'}) class-attribute instance-attribute

default: bool | int | float | str | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute

format: str | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute

maximum: int | float | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute

minimum: int | float | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute

one_of: list[Schema] | None = field(default=None, metadata={'type': 'Element', 'name': 'oneOf'}) class-attribute instance-attribute

title: str | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute

type: str | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute

x_qsl_layer: QslLayerMarker | None = field(default=None, metadata={'type': 'Element', 'name': 'x-qsl-layer'}) class-attribute instance-attribute

__init__(*, type: str | None = None, format: str | None = None, title: str | None = None, minimum: int | float | None = None, maximum: int | float | None = None, const: bool | int | float | str | None = None, default: bool | int | float | str | None = None, one_of: list[Schema] | None = None, content_media_type: str | None = None, x_qsl_layer: QslLayerMarker | None = None) -> None