edr-pydantic


Nameedr-pydantic JSON
Version 0.5.0 PyPI version JSON
download
home_pageNone
SummaryPydantic models for OGC Environmental Data (EDR) API
upload_time2024-09-09 14:43:30
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseNone
keywords edr pydantic
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # OGC Environmental Data Retrieval (EDR) API Pydantic

<p>
  <a href="https://github.com/knmi/edr-pydantic/actions?query=workflow%3ACI" target="_blank">
      <img src="https://github.com/knmi/edr-pydantic/workflows/CI/badge.svg" alt="Test">
  </a>
  <a href="https://codecov.io/gh/knmi/edr-pydantic" target="_blank">
      <img src="https://codecov.io/gh/knmi/edr-pydantic/branch/master/graph/badge.svg" alt="Coverage">
  </a>
  <a href="https://pypi.org/project/edr-pydantic" target="_blank">
      <img src="https://img.shields.io/pypi/v/edr-pydantic?color=%2334D058&label=pypi%20package" alt="Package version">
  </a>
  <a href="https://pypistats.org/packages/edr-pydantic" target="_blank">
      <img src="https://img.shields.io/pypi/dm/edr-pydantic.svg" alt="Downloads">
  </a>
  <a href="https://github.com/knmi/edr-pydantic/blob/master/LICENSE" target="_blank">
      <img src="https://img.shields.io/github/license/knmi/edr-pydantic.svg" alt="License">
  </a>
</p>


This repository contains the edr-pydantic Python package. It provides [Pydantic](https://pydantic-docs.helpmanual.io/) models
for the [OGC Environmental Data Retrieval (EDR) API](https://ogcapi.ogc.org/edr/).
This can, for example, be used to help develop an EDR API using FastAPI.

## Install
```shell
pip install edr-pydantic
```

Or to install from source:

```shell
pip install git+https://github.com/KNMI/edr-pydantic.git
```

## Usage

```python
from edr_pydantic.collections import Collection
from edr_pydantic.data_queries import EDRQuery, EDRQueryLink, DataQueries
from edr_pydantic.extent import Extent, Spatial
from edr_pydantic.link import Link
from edr_pydantic.observed_property import ObservedProperty
from edr_pydantic.parameter import Parameters, Parameter
from edr_pydantic.unit import Unit
from edr_pydantic.variables import Variables

c = Collection(
    id="hrly_obs",
    title="Hourly Site Specific observations",
    description="Observation data for UK observing sites",
    extent=Extent(
        spatial=Spatial(
            bbox=[
                [-15.0, 48.0, 5.0, 62.0]
            ],
            crs="WGS84"
        )
    ),
    links=[
        Link(
            href="https://example.org/uk-hourly-site-specific-observations",
            rel="service-doc"
        )
    ],
    data_queries=DataQueries(
        position=EDRQuery(
            link=EDRQueryLink(
                href="https://example.org/edr/collections/hrly_obs/position?coords={coords}",
                rel="data",
                variables=Variables(
                    query_type="position",
                    output_formats=[
                        "CoverageJSON"
                    ]
                )
            )
        )
    ),
    parameter_names=Parameters({
        "Wind Direction": Parameter(
            unit=Unit(
                label="degree true"
            ),
            observedProperty=ObservedProperty(
                id="https://codes.wmo.int/common/quantity-kind/_windDirection",
                label="Wind Direction"
            )
        )
    })
)

print(c.model_dump_json(indent=2, exclude_none=True))
```

Will print
```json
{
  "id": "hrly_obs",
  "title": "Hourly Site Specific observations",
  "description": "Observation data for UK observing sites",
  "links": [
    {
      "href": "https://example.org/uk-hourly-site-specific-observations",
      "rel": "service-doc"
    }
  ],
  "extent": {
    "spatial": {
      "bbox": [
        [
          -15.0,
          48.0,
          5.0,
          62.0
        ]
      ],
      "crs": "WGS84"
    }
  },
  "data_queries": {
    "position": {
      "link": {
        "href": "https://example.org/edr/collections/hrly_obs/position?coords={coords}",
        "rel": "data",
        "variables": {
          "query_type": "position",
          "output_formats": [
            "CoverageJSON"
          ]
        }
      }
    }
  },
  "parameter_names": {
    "Wind Direction": {
      "type": "Parameter",
      "unit": {
        "label": "degree true"
      },
      "observedProperty": {
        "id": "https://codes.wmo.int/common/quantity-kind/_windDirection",
        "label": "Wind Direction"
      }
    }
  }
}
```

## Contributing

Make an editable install from within the repository root

```shell
pip install -e '.[test]'
```

### Running tests

```shell
pytest tests/
```

### Linting and typing

Linting and typing (mypy) is done using [pre-commit](https://pre-commit.com) hooks.

```shell
pip install pre-commit
pre-commit install
pre-commit run
```

## Related packages

* [CoverageJSON Pydantic](https://github.com/KNMI/covjson-pydantic)
* [geojson-pydantic](https://github.com/developmentseed/geojson-pydantic)

## Real world usage

This library is used to build an OGC Environmental Data Retrieval (EDR) API, serving automatic weather data station data from The Royal Netherlands Meteorological Institute (KNMI). See the [KNMI Data Platform EDR API](https://developer.dataplatform.knmi.nl/edr-api).

## TODOs
Help is wanted in the following areas to fully implement the EDR spec:
* See TODOs in code listing various small inconsistencies in the spec
* In various places there could be more validation on content

## License

Apache License, Version 2.0

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "edr-pydantic",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "EDR, Pydantic",
    "author": null,
    "author_email": "KNMI Data Platform Team <opendata@knmi.nl>",
    "download_url": "https://files.pythonhosted.org/packages/9b/6a/716610951e927a753b59f0b3602669656675047a758c5e944729d7044e08/edr_pydantic-0.5.0.tar.gz",
    "platform": null,
    "description": "# OGC Environmental Data Retrieval (EDR) API Pydantic\n\n<p>\n  <a href=\"https://github.com/knmi/edr-pydantic/actions?query=workflow%3ACI\" target=\"_blank\">\n      <img src=\"https://github.com/knmi/edr-pydantic/workflows/CI/badge.svg\" alt=\"Test\">\n  </a>\n  <a href=\"https://codecov.io/gh/knmi/edr-pydantic\" target=\"_blank\">\n      <img src=\"https://codecov.io/gh/knmi/edr-pydantic/branch/master/graph/badge.svg\" alt=\"Coverage\">\n  </a>\n  <a href=\"https://pypi.org/project/edr-pydantic\" target=\"_blank\">\n      <img src=\"https://img.shields.io/pypi/v/edr-pydantic?color=%2334D058&label=pypi%20package\" alt=\"Package version\">\n  </a>\n  <a href=\"https://pypistats.org/packages/edr-pydantic\" target=\"_blank\">\n      <img src=\"https://img.shields.io/pypi/dm/edr-pydantic.svg\" alt=\"Downloads\">\n  </a>\n  <a href=\"https://github.com/knmi/edr-pydantic/blob/master/LICENSE\" target=\"_blank\">\n      <img src=\"https://img.shields.io/github/license/knmi/edr-pydantic.svg\" alt=\"License\">\n  </a>\n</p>\n\n\nThis repository contains the edr-pydantic Python package. It provides [Pydantic](https://pydantic-docs.helpmanual.io/) models\nfor the [OGC Environmental Data Retrieval (EDR) API](https://ogcapi.ogc.org/edr/).\nThis can, for example, be used to help develop an EDR API using FastAPI.\n\n## Install\n```shell\npip install edr-pydantic\n```\n\nOr to install from source:\n\n```shell\npip install git+https://github.com/KNMI/edr-pydantic.git\n```\n\n## Usage\n\n```python\nfrom edr_pydantic.collections import Collection\nfrom edr_pydantic.data_queries import EDRQuery, EDRQueryLink, DataQueries\nfrom edr_pydantic.extent import Extent, Spatial\nfrom edr_pydantic.link import Link\nfrom edr_pydantic.observed_property import ObservedProperty\nfrom edr_pydantic.parameter import Parameters, Parameter\nfrom edr_pydantic.unit import Unit\nfrom edr_pydantic.variables import Variables\n\nc = Collection(\n    id=\"hrly_obs\",\n    title=\"Hourly Site Specific observations\",\n    description=\"Observation data for UK observing sites\",\n    extent=Extent(\n        spatial=Spatial(\n            bbox=[\n                [-15.0, 48.0, 5.0, 62.0]\n            ],\n            crs=\"WGS84\"\n        )\n    ),\n    links=[\n        Link(\n            href=\"https://example.org/uk-hourly-site-specific-observations\",\n            rel=\"service-doc\"\n        )\n    ],\n    data_queries=DataQueries(\n        position=EDRQuery(\n            link=EDRQueryLink(\n                href=\"https://example.org/edr/collections/hrly_obs/position?coords={coords}\",\n                rel=\"data\",\n                variables=Variables(\n                    query_type=\"position\",\n                    output_formats=[\n                        \"CoverageJSON\"\n                    ]\n                )\n            )\n        )\n    ),\n    parameter_names=Parameters({\n        \"Wind Direction\": Parameter(\n            unit=Unit(\n                label=\"degree true\"\n            ),\n            observedProperty=ObservedProperty(\n                id=\"https://codes.wmo.int/common/quantity-kind/_windDirection\",\n                label=\"Wind Direction\"\n            )\n        )\n    })\n)\n\nprint(c.model_dump_json(indent=2, exclude_none=True))\n```\n\nWill print\n```json\n{\n  \"id\": \"hrly_obs\",\n  \"title\": \"Hourly Site Specific observations\",\n  \"description\": \"Observation data for UK observing sites\",\n  \"links\": [\n    {\n      \"href\": \"https://example.org/uk-hourly-site-specific-observations\",\n      \"rel\": \"service-doc\"\n    }\n  ],\n  \"extent\": {\n    \"spatial\": {\n      \"bbox\": [\n        [\n          -15.0,\n          48.0,\n          5.0,\n          62.0\n        ]\n      ],\n      \"crs\": \"WGS84\"\n    }\n  },\n  \"data_queries\": {\n    \"position\": {\n      \"link\": {\n        \"href\": \"https://example.org/edr/collections/hrly_obs/position?coords={coords}\",\n        \"rel\": \"data\",\n        \"variables\": {\n          \"query_type\": \"position\",\n          \"output_formats\": [\n            \"CoverageJSON\"\n          ]\n        }\n      }\n    }\n  },\n  \"parameter_names\": {\n    \"Wind Direction\": {\n      \"type\": \"Parameter\",\n      \"unit\": {\n        \"label\": \"degree true\"\n      },\n      \"observedProperty\": {\n        \"id\": \"https://codes.wmo.int/common/quantity-kind/_windDirection\",\n        \"label\": \"Wind Direction\"\n      }\n    }\n  }\n}\n```\n\n## Contributing\n\nMake an editable install from within the repository root\n\n```shell\npip install -e '.[test]'\n```\n\n### Running tests\n\n```shell\npytest tests/\n```\n\n### Linting and typing\n\nLinting and typing (mypy) is done using [pre-commit](https://pre-commit.com) hooks.\n\n```shell\npip install pre-commit\npre-commit install\npre-commit run\n```\n\n## Related packages\n\n* [CoverageJSON Pydantic](https://github.com/KNMI/covjson-pydantic)\n* [geojson-pydantic](https://github.com/developmentseed/geojson-pydantic)\n\n## Real world usage\n\nThis library is used to build an OGC Environmental Data Retrieval (EDR) API, serving automatic weather data station data from The Royal Netherlands Meteorological Institute (KNMI). See the [KNMI Data Platform EDR API](https://developer.dataplatform.knmi.nl/edr-api).\n\n## TODOs\nHelp is wanted in the following areas to fully implement the EDR spec:\n* See TODOs in code listing various small inconsistencies in the spec\n* In various places there could be more validation on content\n\n## License\n\nApache License, Version 2.0\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Pydantic models for OGC Environmental Data (EDR) API",
    "version": "0.5.0",
    "project_urls": {
        "Source": "https://github.com/knmi/edr-pydantic"
    },
    "split_keywords": [
        "edr",
        " pydantic"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "e63416567e73de08fc951e30c844c0a7a4fbb1717caad86ba96f9c211b34adf5",
                "md5": "db1ddf7198c2e9e90ba6776620e71675",
                "sha256": "d9794d7324526999715dbe68200594e315af94d9d03a53bb99a44063fd42cbb0"
            },
            "downloads": -1,
            "filename": "edr_pydantic-0.5.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "db1ddf7198c2e9e90ba6776620e71675",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 12464,
            "upload_time": "2024-09-09T14:43:29",
            "upload_time_iso_8601": "2024-09-09T14:43:29.310190Z",
            "url": "https://files.pythonhosted.org/packages/e6/34/16567e73de08fc951e30c844c0a7a4fbb1717caad86ba96f9c211b34adf5/edr_pydantic-0.5.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "9b6a716610951e927a753b59f0b3602669656675047a758c5e944729d7044e08",
                "md5": "eb22d30687024641e879a9ee065abf30",
                "sha256": "7ae5149dfbb6b3777d38a252b3556729528fac383d5427472d31d9f432ed057f"
            },
            "downloads": -1,
            "filename": "edr_pydantic-0.5.0.tar.gz",
            "has_sig": false,
            "md5_digest": "eb22d30687024641e879a9ee065abf30",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 18445,
            "upload_time": "2024-09-09T14:43:30",
            "upload_time_iso_8601": "2024-09-09T14:43:30.471740Z",
            "url": "https://files.pythonhosted.org/packages/9b/6a/716610951e927a753b59f0b3602669656675047a758c5e944729d7044e08/edr_pydantic-0.5.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-09 14:43:30",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "knmi",
    "github_project": "edr-pydantic",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "edr-pydantic"
}
        
Elapsed time: 0.33374s