Skip to main content

Python library to streamline interaction with the ENVRI-Hub APIs, providing a pythonic facade to data and service access.

Project description

ENVRI Hub's VRE Library

This is the official ENVRI-Hub Python library, its purpose is to streamline interaction with the ENVRI-Hub APIs, providing a pythonic facade to data and service access.

Quickstart

After installing the package with a quick

pip install envrihub

You can start using the ENVRI-HUB resorces right away through the Hub object:

from envrihub import Hub

hub = Hub()

You can query it to retrieve resources that match your needs:

for res in hub.search_catalogue('bacon'):
    print(res.title)

You can specify free text queries, time boundaries, geographic boundaries, dara providers and/or variables you expect in your data. Here is an example of geographical search with a WKT polygon:

geography = 'POLYGON((10.70 48.34,
                28.98 48.34
                28.98 36.17,
                10.70 36.17,
                10.70 48.34))'

for i in hub.search_catalogue(geography = geography):
    print(i.title)

Just type help(hub.seach_catalogue) for the full details.

You can also access a resurce directly if you know its unique identifier in the Catalogue of Services:

res = hub.fetch_from_catalogue('b646c445-57b8-4553-bf2f-12448ee16b55')

Retrieved resources have the following properties:

  • title: a human readable title for the resource;
  • id: the resource's identifier in the Catalogue of Services;
  • description: a human readable description of the resource;
  • metadata: the whole EPOS-DCAT-AP metadata of the resource;
  • dao: the data access object that allows you to get the actual data. All DAOs have an access method.

DAO objects are auto-generated according to the resource's metadata and can have additional methods to access data, when in doubt check them out with the help function:

help(res.dao)

If the resource is a Web Service, the DAO object allows to query such a service with all due parameters:

res = hub.fetch_from_catalogue('16c3ae2f-ba39-4239-964d-12e67c378fef')
res.dao.access(id='138228')

Or if the resource is a static file it lets you download it either as a bytes object or directly to your file system.

res = hub.fetch_from_catalogue('b646c445-57b8-4553-bf2f-12448ee16b55')
byte_stream = res.dao.access() # bytes object
res.dao.download('path-to.file') # local file download

Digital kleptomaniacs rejoice! This means that with a handful of lines you can now scrape the whole ENVRI-HUB!

for res in hub.search_catalogue():
    if res.is_downloadable():
        res.dao.download(res.id)

Contributing

To contribute, you have to attend ENVRI-Hub Next's WP13 monthly meetings. For now, if we never saw you, your pull requests will be rejected.

Acknowledgements

This project is funded by the ENVRI-Hub Next project. The project received funding from the European Union’s Horizon Europe research and innovation programme under grant agreement No 101131141.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

envrihub-0.0.3.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

envrihub-0.0.3-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file envrihub-0.0.3.tar.gz.

File metadata

  • Download URL: envrihub-0.0.3.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.13

File hashes

Hashes for envrihub-0.0.3.tar.gz
Algorithm Hash digest
SHA256 62268f5ce10a8cc069e7a381f08848500b7a7e1cfd172d0a3382542f27a2896e
MD5 6bfb1f905dd1ee17ef94a81adc78b22a
BLAKE2b-256 c0bf32c957d2393593a6fdab304ea6981a5ca32e6062059110714a98ce86988f

See more details on using hashes here.

File details

Details for the file envrihub-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: envrihub-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 5.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.13

File hashes

Hashes for envrihub-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 8b97bfaa37cc8538c0da3e1a203b32673d3219af7c37c30d0b31e1f901c2bf9e
MD5 c0ad6e627f61530a8de834d23fec0c60
BLAKE2b-256 a9afe38b3d0d6b5a636c1245075043e7451f90383d8a46c627bfd4d6dad908bc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page