Models

pydantic model qgreenland.models.base_model.QgrBaseModel[source]

Bases: BaseModel

Implements ‘faux’ immutability and allows usage of functools.cached_property.

Immutability is not ‘strict’ (e.g., dicts can be mutated) - a determined dev can still mutate model instances.

validator clean_all_string_fields  »  all fields[source]

Clean up all string fields with cleandoc.

This adjusts indentation and removes leading and trailing newlines, enabling cleaner use of triple-quoted strings, just like docstrings.

validator validate_id_fields  »  all fields[source]

Ensure id fields have appropriate content.

Only lowercase alphanumeric characters or underscores are permitted.

Configuration

The configuration determines the final output of the processing pipelines, including the final QGIS project, zip package, and layers that are created.

pydantic model qgreenland.models.config.__init__.Config[source]

Bases: QgrBaseModel

The configuration determines the pipeline outputs.

All fields are populated programmatically. There is no need to specify a Config object anywhere: this is part of the framework.

field datasets: dict[str, qgreenland.models.config.dataset.Dataset] [Required][source]

A lookup of all datasets included in the project.

Validated by:
field layer_tree: Node [Required][source]

A tree of all layers and groups.

Structured as they would be in the QGIS Layers Panel.

Validated by:
field layers: dict[str, qgreenland.models.config.layer.Layer] [Required][source]

A lookup of all layers included in the project.

Validated by:
field project: Project [Required][source]

General project-wide configuration, such as CRS.

Validated by:

Project

pydantic model qgreenland.models.config.project.BoundariesInfo[source]

Bases: QgrBaseModel

field bbox: BoundingBox [Required][source]

Bounding box, automatically populated from the file.

Validated by:
field filepath: EvalFilePath [Required][source]

Path to GeoJSON boundary file.

Validated by:
validator calculate_bbox  »  all fields[source]
Return type:

dict[str, Any]

validator ensure_relative_to_assets  »  filepath[source]
pydantic model qgreenland.models.config.project.BoundingBox[source]

Bases: QgrBaseModel

field max_x: float [Required][source]
Validated by:
field max_y: float [Required][source]
Validated by:
field min_x: float [Required][source]
Validated by:
field min_y: float [Required][source]
Validated by:
pydantic model qgreenland.models.config.project.Project[source]

Bases: QgrBaseModel

General project-wide configuration.

field boundaries: dict[str, qgreenland.models.config.project.BoundariesInfo] [Required][source]

The boundaries available for use (e.g. clipping) during layer steps.

Validated by:
field crs: str [Required][source]

The Coordinate Reference System of the project.

Validated by:

Layer Groups

class qgreenland.models.config.layer_group.LayerGroupIdentifier(seq)[source]

Bases: LayerIdentifierBase

A string corresponding with a single layer group/directory name.

This is not expected to be globally unique, only locally within their parent group. For example, there may be two group _paths_:

  • Foo/January

  • Bar/January

Foo, Bar, January are all LayerGroupIdentifiers, but January is not globally unique, only locally (i.e. there can’t be two January`s in `Foo).

TODO: Update other models to replace string layer group identifiers with lists of this class?

regex: Pattern = re.compile('[A-Z0-9][a-zA-Z0-9() ,._-]*')[source]
pydantic model qgreenland.models.config.layer_group.LayerGroupSettings[source]

Bases: RootGroupSettings

field expand: bool = False[source]

Whether the group is expanded or collapsed in the QGIS Layers Panel.

Validated by:
field show: bool = False[source]

Whether the group is shown or hidden in the QGIS Layers Panel.

Validated by:
class qgreenland.models.config.layer_group.LayerIdentifier(seq)[source]

Bases: LayerIdentifierBase

A string uniquely identifying a layer.

TODO: Update other models to replace string layer identifiers with this class?

regex: Pattern = re.compile('[a-z0-9_]*')[source]
class qgreenland.models.config.layer_group.LayerIdentifierBase(seq)[source]

Bases: UserString

A base class for special strings meant to be distinguished by type.

Based on docs: https://docs.pydantic.dev/1.10/usage/types/#classes-with-__get_validators__

TODO: The doc above specifies a __modify_schema__ method which we’re not using. Should we be?

regex: Pattern[source]
classmethod validate(v)[source]
pydantic model qgreenland.models.config.layer_group.RootGroupSettings[source]

Bases: QgrBaseModel

Settings specific to the root group.

field order: list[qgreenland.models.config.layer_group.LayerIdentifier | qgreenland.models.config.layer_group.LayerGroupIdentifier] | None = None[source]

The order in which this group’s contents will be shown.

Subgroups are referenced by name, e.g. ‘Basemaps’, and layers are referenced by a colon followed by the layer ID, e.g. :background. If ‘order’ is omitted, a default sorting algorithm is applied.

Validated by:

Layers

pydantic model qgreenland.models.config.layer.Layer[source]

Bases: QgrBaseModel

field description: str [Required][source]

Descriptive text shown as hover-text in the QGIS Layer Panel.

Constraints:
  • minLength = 1

Validated by:
field id: str [Required][source]

Unique identifier.

Validated by:
field in_package: bool = True[source]

Is this layer in the final QGreenland zip file?

Validated by:
field input: LayerInput [Required][source]
Validated by:
field show: bool = False[source]

Is this layer initially “checked” or visible in QGIS?

Validated by:
field steps: list[qgreenland.models.config.step.CommandStep] | None = None[source]
Validated by:
field style: str | None = None[source]

Which style (.qml) file to use for this layer?

Omit the file extension.

Constraints:
  • minLength = 1

Validated by:
field tags: list[str] = [][source]

Additional categories that describe this data.

Validated by:
field title: str [Required][source]

The layer name in QGIS Layers Panel.

Validated by:
property style_filepath: Path | None[source]

Full filepath to the QML style file.

pydantic model qgreenland.models.config.layer.LayerInput[source]

Bases: QgrBaseModel

The input(s) to a layer’s processing pipeline.

field asset: CmrAsset | CommandAsset | HttpAsset | ManualAsset | OnlineAsset | RepositoryAsset [Required][source]

The actual input asset (file or files).

Validated by:
field dataset: Dataset [Required][source]

The dataset providing the layer’s input. Important for metadata.

Validated by:

Steps

qgreenland.models.config.step.AnyStep[source]

alias of CommandStep

pydantic model qgreenland.models.config.step.CommandStep[source]

Bases: QgrBaseModel, LayerStep

A step run as a shell command.

field args: list[qgreenland.util.runtime_vars.EvalStr] [Required][source]

The command arguments, e.g. [‘cat’, ‘{input_dir}/foo.txt’].

Validated by:
field id: str | None = None[source]

An identifier for the step. Does not need to be unique.

Validated by:
field type: Literal['command'] = 'command'[source]

The type of the step. Should not be set by the user.

Validated by:
validator set_default_id  »  all fields[source]

Generate an identifier from args if one is not provided.

property provenance: str[source]

Represent what was done in this step.

class qgreenland.models.config.step.LayerStep[source]

Bases: ABC

id: str | None[source]

An identifier for the step. Does not need to be unique.

abstract property provenance: str[source]

Represent what was done in this step.

type: str[source]

The type of the step. Should not be set by the user.

Datasets

pydantic model qgreenland.models.config.dataset.Dataset[source]

Bases: QgrBaseModel

Configuration for a dataset.

field assets: dict[str, Union[qgreenland.models.config.asset.CmrAsset, qgreenland.models.config.asset.CommandAsset, qgreenland.models.config.asset.HttpAsset, qgreenland.models.config.asset.ManualAsset, qgreenland.models.config.asset.OnlineAsset, qgreenland.models.config.asset.RepositoryAsset]] [Required][source]

Actual data associated with the dataset.

Validated by:
field id: str [Required][source]

Dataset unique identifier.

Constraints:
  • minLength = 1

Validated by:
field metadata: DatasetMetadata [Required][source]
Validated by:
validator index_assets_by_id  »  assets[source]

Reindex assets from a list to a dictionary keyed by id.

pydantic model qgreenland.models.config.dataset.DatasetCitation[source]

Bases: QgrBaseModel

Citation for a dataset.

field text: str [Required][source]

The citation text.

Validated by:
field url: str [Required][source]

The citation URL. This is usually a doi.org URL.

Validated by:
validator strip_enclosing_newlines  »  text[source]

Clean up the citation text.

pydantic model qgreenland.models.config.dataset.DatasetMetadata[source]

Bases: QgrBaseModel

Metadata for the dataset.

field abstract: str [Required][source]

The dataset abstract.

Validated by:
field citation: DatasetCitation [Required][source]
Validated by:
field title: str [Required][source]

The dataset’s title. Please use sentence case, not title case.

Validated by:

Assets

pydantic model qgreenland.models.config.asset.CmrAsset[source]

Bases: DatasetAsset

Data fetched based on the location provided by CMR.

field collection_concept_id: str [Required][source]

The CMR unique collection concept identifier.

Constraints:
  • minLength = 1

Validated by:
field granule_ur: str [Required][source]

The CMR unique granule UR identifier.

Constraints:
  • minLength = 1

Validated by:
property provenance: str[source]

How the asset was acquired.

pydantic model qgreenland.models.config.asset.CommandAsset[source]

Bases: DatasetAsset

Data that are fetched via an arbitrary command.

Data is written to ‘{output_dir}’, which _must_ be specified in the command.

field args: list[qgreenland.util.runtime_vars.EvalStr] [Required][source]

Command arguments.

E.g.: [‘echo’, ‘foo’, ‘>’, ‘{output_dir}/foo.txt’].

Validated by:
property provenance: str[source]

How the asset was acquired.

pydantic model qgreenland.models.config.asset.DatasetAsset[source]

Bases: QgrBaseModel, ABC

Actual data associated with the dataset.

Assets determine how this data is accessed.

field id: str [Required][source]

Asset unique identifier. Must be unique within the dataset.

Constraints:
  • minLength = 1

Validated by:
abstract property provenance: str[source]

How the asset was acquired.

pydantic model qgreenland.models.config.asset.HttpAsset[source]

Bases: DatasetAsset

An asset fetched over HyperText Transfer Protocol.

field urls: list[pydantic.networks.AnyUrl] [Required][source]

List of URLs to fetch.

Validated by:
field verify_tls: bool = True[source]

Verify the server’s TLS certificate?

https://2.python-requests.org/en/master/api/#requests.Session.request

Validated by:
property provenance: str[source]

How the asset was acquired.

pydantic model qgreenland.models.config.asset.ManualAsset[source]

Bases: DatasetAsset

Data that must be manually accessed by a human.

For example, data which require an interactive login.

field access_instructions: str [Required][source]

Instructions for accessing the asset.

Constraints:
  • minLength = 1

Validated by:
property provenance: str[source]

How the asset was acquired.

pydantic model qgreenland.models.config.asset.OnlineAsset[source]

Bases: DatasetAsset

A QGIS online layer that is not fetched, but is accessed by QGIS.

field provider: Literal['gdal', 'ogr', 'wms', 'wfs', 'wcs'] [Required][source]

The Layer Provider to use when setting up this layer in QGIS.

Validated by:
field url: AnyUrl | str [Required][source]

The URL to use when setting up this layer in QGIS.

Validated by:
property provenance: str[source]

How the asset was acquired.

pydantic model qgreenland.models.config.asset.RepositoryAsset[source]

Bases: DatasetAsset

Data stored in this repository in ASSETS_DIR.

field filepath: EvalFilePath [Required][source]

The location of the asset, e.g. {assets_dir}/foo.txt.

Validated by:
validator ensure_relative_to_assets  »  filepath[source]

Ensure the asset path is as expected.

property provenance: str[source]

How the asset was acquired.