Skip to content

Commit

Permalink
Merge pull request #20 from GermanoGuerrini/master
Browse files Browse the repository at this point in the history
Autodoc fixes
  • Loading branch information
ricardo-correa authored Feb 15, 2023
2 parents 0c186e8 + f5dd8ce commit 74472ff
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 82 deletions.
77 changes: 2 additions & 75 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,85 +1,12 @@
# WEkEO HDA API Client

This package provides a fully compliant Python 3 client that can be used to search and download products using the Harmonized Data Access WEkEO API.

HDA is a RESTful interface allowing users to search and download WEkEO datasets.

Documentation about its usage can be found at https://www.wekeo.eu/.

## Requirements
- Python 3
- requests
- tqdm

## Install the WEkEO HDA Key

1) If you don't have a WEkEO account, please self register at the WEkEO registration page https://www.wekeo.eu/web/guest/user-registration and go to the steps below.

2) Copy the code below in the file `$HOME/.hdarc` in your Unix/Linux environment. Adapt the following template with the credentials of your WEkEO account:

url: https://wekeo-broker.apps.mercator.dpi.wekeo.eu/databroker
user: [username]
password: [password]


## Install the WEkEO HDA client

The WEkEO HDA client is a python based library. It provides support for both Python 2.7.x and Python 3.

You can Install the WEkEO HDA client via the package management system pip, by running on Unix/Linux the command shown below.

pip install hda

This will also install the required dependencies.


## Use the WEkEO HDA client for data access

Once the WEkEO HDA API client is installed, it can be used to request data from the datasets listed in the WEkEO catalogue.

On the WEkEO portal, under DATA, each dataset search has a 'Show API request' button, it displays the json request to be used. The request can be formatted using the interactive form. The API call must follow the syntax.

The client can be used directly into another python script as in the following example:

```python
from hda import Client

c = Client(debug=True)

query = {
"datasetId": "EO:CODA:DAT:SENTINEL-3:OL_1_EFR___",
"dateRangeSelectValues": [{
"end": "2019-07-03T14:03:00.000Z",
"name": "dtrange",
"start": "2019-07-03T13:59:00.000Z"
}],
"stringChoiceValues": []
}
matches = c.search(query)
print(matches)
matches.download()
```

Note that the query must be a json valid object. Please refer to the official documentation of the HDA for instructions on how to get the list of the available parameters.

Alternatively, it can be wrapped into a script to be executed from the command line. Please refer to the ``demos/demo.py`` file for a simple demostration.

## Reference
There are a number of options the drives the `Client` instance:
- `url`: The HDA URL. Normally set in the `.hdarc` file, can be overwritten directly by passing a value to the client.
- `user`: The HDA user. Normally set in the `.hdarc` file, can be overwritten directly by passing a value to the client.
- `password`: The HDA password. Normally set in the `.hdarc` file, can be overwritten directly by passing a value to the client.
- `token`: Credentials can be passed directly with a valid JWT Token that will take precedence over user and password. Normally unused, as the client will require a fresh token upon any API call.
- `quiet`: Pass `True` to disable logging. Default: `False`.
- `debug`: Pass `True` to enable debug. Requires `quiet` to be `False`. Default: `False`.
- `verify`: Whether to verify for SSL certificate of the HDA or not. Normally there is no need to modify the default value. Default: `None`.
- `timeout`: The time, in seconds, before the client should stop waiting for a response. Default: `None`.
- `retry_max`: The number of retries before the client should stop trying to get a successful response. Default: 500.
- `sleep_max`: The time, in seconds, to wait between two attempts. Default: 120.
- `info_callback`: A callback function that can be attached to the `info` logging level messages. Will replace the default logging. Default: `None`.
- `warning_callback`: A callback function that can be attached to the `warning` logging level messages. Will replace the default logging. Default: `None`.
- `error_callback`: A callback function that can be attached to the `error` logging level messages. Will replace the default logging. Default: `None`.
- `debug_callback`: A callback function that can be attached to the `debug` logging level messages. Will replace the default logging. Default: `None`.
- `progress`: Whether to show or hide a progress bar. Default: `True`.
The documentation for this package can be found at: https://hda.readthedocs.io/en/latest/

## Contribution
Contribute to the development of this client by creating an account on GitHub. You can follow this guidelines for a general overview of the needed steps: https://github.com/firstcontributions/first-contributions.
Expand Down
2 changes: 1 addition & 1 deletion demos/sentinel.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"datasetId": "EO:CODA:DAT:SENTINEL-3:OL_1_EFR___",
"datasetId": "EO:EUM:DAT:SENTINEL-3:OL_1_EFR___",
"dateRangeSelectValues": [{
"end": "2019-07-03T14:03:00.000Z",
"name": "dtrange",
Expand Down
2 changes: 1 addition & 1 deletion docs/source/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ API

.. automodule:: hda.api

.. autoattribute:: hda.pi.BROKER_URL
.. autoattribute:: hda.api.BROKER_URL

.. autoclass:: RequestRunner
:members:
Expand Down
4 changes: 4 additions & 0 deletions docs/source/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Changelog
=========

Version 1.13
-------------
* Minor documentation fixes

Version 1.12
-------------
* Refactored client configuration
Expand Down
15 changes: 13 additions & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
# Configuration file for the Sphinx documentation builder.

import os
import sys

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
# sys.path.insert(0, os.path.abspath('.'))
sys.path.insert(0, os.path.abspath("../.."))

# -- Project information

project = "WEkEO HDA API Client"
copyright = "2023, ECMWF"
author = "ECMWF"

release = "0.4.0"
version = "0.4.0"
release = "1.13"
version = "1.13"

# -- General configuration

Expand All @@ -33,3 +42,5 @@

# -- Options for EPUB output
epub_show_urls = "footnote"

autodoc_mock_imports = ["tqdm", "requests"]
2 changes: 1 addition & 1 deletion docs/source/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ The client can be used directly into another python script as in the following e
c = Client()
query = {
"datasetId": "EO:CODA:DAT:SENTINEL-3:OL_1_EFR___",
"datasetId": "EO:EUM:DAT:SENTINEL-3:OL_1_EFR___",
"dateRangeSelectValues": [{
"end": "2019-07-03T14:03:00.000Z",
"name": "dtrange",
Expand Down
2 changes: 1 addition & 1 deletion hda/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
Expand Down
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ def read(fname):

version = "1.13"


setuptools.setup(
name="hda",
version=version,
Expand Down

0 comments on commit 74472ff

Please sign in to comment.