qa4sm-api 0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. qa4sm_api-0.1/.coveragerc +34 -0
  2. qa4sm_api-0.1/.github/workflows/ci.yml +127 -0
  3. qa4sm_api-0.1/.github/workflows/deploy-docs.yml +53 -0
  4. qa4sm_api-0.1/.gitignore +54 -0
  5. qa4sm_api-0.1/AUTHORS.rst +5 -0
  6. qa4sm_api-0.1/CHANGELOG.rst +10 -0
  7. qa4sm_api-0.1/LICENSE.txt +21 -0
  8. qa4sm_api-0.1/PKG-INFO +215 -0
  9. qa4sm_api-0.1/README.rst +186 -0
  10. qa4sm_api-0.1/docs/.nojekyll +0 -0
  11. qa4sm_api-0.1/docs/Makefile +29 -0
  12. qa4sm_api-0.1/docs/_static/.gitignore +1 -0
  13. qa4sm_api-0.1/docs/authors.rst +2 -0
  14. qa4sm_api-0.1/docs/changelog.rst +2 -0
  15. qa4sm_api-0.1/docs/conf.py +287 -0
  16. qa4sm_api-0.1/docs/index.rst +40 -0
  17. qa4sm_api-0.1/docs/license.rst +7 -0
  18. qa4sm_api-0.1/docs/notebooks/.ipynb_checkpoints/tutorial-checkpoint.ipynb +1592 -0
  19. qa4sm_api-0.1/docs/notebooks/tutorial.ipynb +1592 -0
  20. qa4sm_api-0.1/docs/pages/basics.md +268 -0
  21. qa4sm_api-0.1/docs/pages/cli.md +161 -0
  22. qa4sm_api-0.1/docs/readme.rst +2 -0
  23. qa4sm_api-0.1/pyproject.toml +77 -0
  24. qa4sm_api-0.1/setup.cfg +4 -0
  25. qa4sm_api-0.1/setup.py +22 -0
  26. qa4sm_api-0.1/src/qa4sm_api/__init__.py +16 -0
  27. qa4sm_api-0.1/src/qa4sm_api/cli.py +220 -0
  28. qa4sm_api-0.1/src/qa4sm_api/client_api.py +851 -0
  29. qa4sm_api-0.1/src/qa4sm_api/globals.py +130 -0
  30. qa4sm_api-0.1/src/qa4sm_api.egg-info/PKG-INFO +215 -0
  31. qa4sm_api-0.1/src/qa4sm_api.egg-info/SOURCES.txt +38 -0
  32. qa4sm_api-0.1/src/qa4sm_api.egg-info/dependency_links.txt +1 -0
  33. qa4sm_api-0.1/src/qa4sm_api.egg-info/entry_points.txt +2 -0
  34. qa4sm_api-0.1/src/qa4sm_api.egg-info/requires.txt +14 -0
  35. qa4sm_api-0.1/src/qa4sm_api.egg-info/top_level.txt +1 -0
  36. qa4sm_api-0.1/tests/__init__.py +0 -0
  37. qa4sm_api-0.1/tests/conftest.py +10 -0
  38. qa4sm_api-0.1/tests/test_client_api.py +267 -0
  39. qa4sm_api-0.1/tests/test_globals.py +19 -0
  40. qa4sm_api-0.1/tox.ini +93 -0
@@ -0,0 +1,34 @@
1
+ # .coveragerc to control coverage.py
2
+ [run]
3
+ branch = True
4
+ source = qa4sm_api
5
+ data_file = .coverage
6
+ omit =
7
+ */qa4sm_api/cli.py
8
+ qa4sm_api/cli.py
9
+ */tests/*
10
+
11
+ [paths]
12
+ source =
13
+ src/
14
+ */site-packages/
15
+
16
+ [report]
17
+ precision = 2
18
+
19
+ # Regexes for lines to exclude from consideration
20
+ exclude_lines =
21
+ # Have to re-enable the standard pragma
22
+ pragma: no cover
23
+
24
+ # Don't complain about missing debug-only code:
25
+ def __repr__
26
+ if self\.debug
27
+
28
+ # Don't complain if tests don't hit defensive assertion code:
29
+ raise AssertionError
30
+ raise NotImplementedError
31
+
32
+ # Don't complain if non-runnable code isn't run:
33
+ if 0:
34
+ if __name__ == .__main__::
@@ -0,0 +1,127 @@
1
+ # This workflow will install Python dependencies and run tests on
2
+ # windows and linux systems with a variety of Python versions
3
+
4
+ # For more information see:
5
+ # https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
6
+
7
+ name: Automated Tests
8
+
9
+ on:
10
+ push:
11
+ pull_request:
12
+ workflow_dispatch:
13
+ schedule:
14
+ - cron: '0 0 * * *' # daily
15
+
16
+ jobs:
17
+ build:
18
+ name: py${{ matrix.python-version }}@${{ matrix.os }}
19
+ runs-on: ${{ matrix.os }}
20
+ strategy:
21
+ matrix:
22
+ python-version: ['3.8', '3.13']
23
+ os: ["ubuntu-latest", "windows-latest", "macos-latest"]
24
+
25
+ steps:
26
+ - uses: actions/checkout@v4
27
+ with:
28
+ fetch-depth: 0
29
+ - name: Fetch tags
30
+ run: git fetch --tags --force
31
+ - uses: conda-incubator/setup-miniconda@v3
32
+ with:
33
+ auto-update-conda: true
34
+ python-version: ${{ matrix.python-version }}
35
+ channel-priority: flexible
36
+ activate-environment: qa4sm_api
37
+ auto-activate-base: false
38
+ - name: Print environment infos
39
+ shell: bash -l {0}
40
+ run: |
41
+ conda info -a
42
+ conda list
43
+ pip list
44
+ which pip
45
+ which python
46
+ - name: Install dependencies and package
47
+ shell: bash -l {0}
48
+ run: |
49
+ pip install build -e .[testing]
50
+ - name: Run all tests
51
+ shell: bash -l {0}
52
+ run: |
53
+ pytest
54
+ - name: Export Environment
55
+ shell: bash -l {0}
56
+ run: |
57
+ mkdir -p artifacts
58
+ filename=env_py${{ matrix.python-version }}_${{ matrix.os }}.yml
59
+ conda env export --no-builds | grep -v "prefix" > artifacts/$filename
60
+ - name: Create wheel and dist package
61
+ shell: bash -l {0}
62
+ run: |
63
+ if [ "${{ matrix.os }}" == "windows-latest" ]
64
+ then
65
+ # build wheel on windows
66
+ python -m build --wheel --outdir artifacts/dist
67
+ else
68
+ # build both wheel and sdist on linux/mac
69
+ python -m build --wheel --sdist --outdir artifacts/dist
70
+ fi
71
+ ls artifacts/dist
72
+ twine check artifacts/dist/* || true
73
+ - name: Upload Coverage
74
+ shell: bash -l {0}
75
+ continue-on-error: true
76
+ run: |
77
+ pip install coveralls && coveralls --service=github
78
+ env:
79
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
80
+ COVERALLS_FLAG_NAME: ${{ matrix.python-version }}
81
+ COVERALLS_PARALLEL: true
82
+ - name: Upload Artifacts
83
+ uses: actions/upload-artifact@v7
84
+ with:
85
+ name: Artifacts-py${{ matrix.python-version }}-${{ matrix.os }}
86
+ path: artifacts/*
87
+
88
+ publish-coverage:
89
+ name: Submit Coveralls 👚
90
+ needs: build
91
+ runs-on: ubuntu-latest
92
+ container: python:3-slim
93
+ steps:
94
+ - name: Finished
95
+ run: |
96
+ pip3 install --upgrade coveralls && coveralls --service=github --finish
97
+ env:
98
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
99
+
100
+ publish-pypi-package:
101
+ name: Publish PyPI 🚀
102
+ # Trigger on release tags from the awst-austria repository
103
+ if: |
104
+ startsWith(github.ref, 'refs/tags/v') &&
105
+ startsWith(github.repository, 'awst-austria')
106
+ needs: build
107
+ runs-on: ubuntu-latest
108
+ steps:
109
+ - name: Print environment variables
110
+ run: |
111
+ echo "GITHUB_REF = $GITHUB_REF"
112
+ echo "GITHUB_REPOSITORY = $GITHUB_REPOSITORY"
113
+ - name: Download Artifacts
114
+ uses: actions/download-artifact@v4
115
+ with:
116
+ path: dist
117
+ merge-multiple: true
118
+ - name: Display downloaded files
119
+ run: ls -la dist/
120
+ - name: Upload to PyPI
121
+ uses: pypa/gh-action-pypi-publish@release/v1
122
+ with:
123
+ skip_existing: true
124
+ verbose: true
125
+ verify_metadata: true
126
+ packages_dir: dist/
127
+ password: ${{ secrets.PYPI_API_TOKEN }}
@@ -0,0 +1,53 @@
1
+ name: GitHub Pages Deploy
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ workflow_dispatch:
8
+
9
+ permissions:
10
+ contents: read
11
+ pages: write
12
+ id-token: write
13
+
14
+ concurrency:
15
+ group: "pages"
16
+ cancel-in-progress: false
17
+
18
+ jobs:
19
+ build:
20
+ runs-on: ubuntu-latest
21
+ steps:
22
+ - name: Checkout
23
+ uses: actions/checkout@v4
24
+
25
+ - name: Set up Python
26
+ uses: actions/setup-python@v5
27
+ with:
28
+ python-version: "3.12"
29
+
30
+ - name: Install dependencies
31
+ run: |
32
+ pip install -e ".[docs]"
33
+
34
+ - name: Build documentation
35
+ run: |
36
+ cd docs
37
+ sphinx-build -b html . _build/html
38
+
39
+ - name: Upload artifact
40
+ uses: actions/upload-pages-artifact@v3
41
+ with:
42
+ path: docs/_build/html
43
+
44
+ deploy:
45
+ environment:
46
+ name: github-pages
47
+ url: ${{ steps.deployment.outputs.page_url }}
48
+ runs-on: ubuntu-latest
49
+ needs: build
50
+ steps:
51
+ - name: Deploy to GitHub Pages
52
+ id: deployment
53
+ uses: actions/deploy-pages@v4
@@ -0,0 +1,54 @@
1
+ # Temporary and binary files
2
+ *~
3
+ *.py[cod]
4
+ *.so
5
+ *.cfg
6
+ !.isort.cfg
7
+ *.orig
8
+ *.log
9
+ *.pot
10
+ __pycache__/*
11
+ .cache/*
12
+ .*.swp
13
+ */.ipynb_checkpoints/*
14
+ .DS_Store
15
+
16
+ # Project files
17
+ .ropeproject
18
+ .project
19
+ .pydevproject
20
+ .settings
21
+ .idea
22
+ .vscode
23
+ tags
24
+
25
+ # Package files
26
+ *.egg
27
+ *.eggs/
28
+ .installed.cfg
29
+ *.egg-info
30
+
31
+ # Unittest and coverage
32
+ htmlcov/*
33
+ .coverage
34
+ .coverage.*
35
+ .tox
36
+ junit*.xml
37
+ coverage.xml
38
+ .pytest_cache/
39
+
40
+ # Build and docs folder/files
41
+ build/*
42
+ dist/*
43
+ sdist/*
44
+ docs/api/*
45
+ docs/_rst/*
46
+ docs/_build/*
47
+ cover/*
48
+ MANIFEST
49
+
50
+ # Per-project virtualenvs
51
+ .venv*/
52
+ .conda*/
53
+ .python-version
54
+ artifacts
@@ -0,0 +1,5 @@
1
+ ============
2
+ Contributors
3
+ ============
4
+
5
+ * Wolfgang Preimesberger <wolfgang.preimesberger@geo.tuwien.ac.at>
@@ -0,0 +1,10 @@
1
+ =========
2
+ Changelog
3
+ =========
4
+
5
+ Version 0.1
6
+ ===========
7
+
8
+ - First version of Client API package
9
+ - Allows triggering validation runs and downloading results
10
+ - Used for the automated validation reports application
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2025 Wolfgang Preimesberger
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
qa4sm_api-0.1/PKG-INFO ADDED
@@ -0,0 +1,215 @@
1
+ Metadata-Version: 2.4
2
+ Name: qa4sm_api
3
+ Version: 0.1
4
+ Summary: QA4SM webval API access
5
+ Author-email: TU Wien <support@qa4sm.eu>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/awst-austria/qa4sm-api
8
+ Project-URL: Documentation, https://awst-austria.github.io/qa4sm-api
9
+ Classifier: Development Status :: 4 - Beta
10
+ Classifier: Programming Language :: Python
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Requires-Python: >=3.8
13
+ Description-Content-Type: text/x-rst
14
+ License-File: LICENSE.txt
15
+ License-File: AUTHORS.rst
16
+ Requires-Dist: pandas
17
+ Requires-Dist: click
18
+ Requires-Dist: requests
19
+ Requires-Dist: tornado
20
+ Provides-Extra: testing
21
+ Requires-Dist: pytest; extra == "testing"
22
+ Requires-Dist: pytest-cov; extra == "testing"
23
+ Requires-Dist: coverage; extra == "testing"
24
+ Provides-Extra: docs
25
+ Requires-Dist: sphinx>=3.2.1; extra == "docs"
26
+ Requires-Dist: sphinx_rtd_theme; extra == "docs"
27
+ Requires-Dist: myst-parser>=0.18.1; extra == "docs"
28
+ Dynamic: license-file
29
+
30
+ .. coding: utf-8
31
+
32
+ .. image:: https://img.shields.io/badge/CI-GitHub%20Actions-success?logo=github-actions
33
+ :alt: GitHub Actions
34
+ :target: https://github.com/awst-austria/qa4sm-api/actions
35
+ .. image:: https://img.shields.io/coveralls/github/awst-austria/qa4sm-api/main?logo=coveralls
36
+ :alt: Coveralls
37
+ :target: https://coveralls.io/github/awst-austria/qa4sm-api
38
+ .. image:: https://img.shields.io/pypi/v/qa4sm-api?logo=pypi
39
+ :alt: PyPI
40
+ :target: https://pypi.org/project/qa4sm-api/
41
+ .. image:: https://img.shields.io/badge/Docs-Documentation-blue?logo=sphinx
42
+ :alt: Documentation
43
+ :target: https://awst-austria.github.io/qa4sm-api/readme.html
44
+
45
+
46
+ =========
47
+ qa4sm-api
48
+ =========
49
+
50
+ .. image:: https://qa4sm.eu/static/images/logo/qa4sm_logo_long.webp
51
+ :height: 50px
52
+
53
+ Python client library for interacting with the **QA4SM** (Quality Assurance for Soil Moisture) validation service.
54
+ QA4SM is an online platform for validating (satellite) soil moisture datasets.
55
+
56
+ Features
57
+ --------
58
+
59
+ - **API Client**: Python API for QA4SM.eu web service
60
+ - **Command Line Interface**: Convenient CLI for common operations
61
+ - **Result Download**: Download NetCDF, graphics, and summary statistics
62
+ - **Search datasets in the service**, **download validation configurations**, ...
63
+ - **Programmatically trigger validation runs**
64
+
65
+ Coming soon:
66
+
67
+ - Programmatically upload your data for validation
68
+
69
+ Installation
70
+ ============
71
+
72
+ Install from PyPI:
73
+
74
+ .. code-block:: bash
75
+
76
+ pip install qa4sm-api
77
+
78
+ Or from source:
79
+
80
+ .. code-block:: bash
81
+
82
+ git clone https://github.com/awst-austria/qa4sm-api.git
83
+ cd qa4sm-api
84
+ pip install -e .
85
+
86
+ **Verify installation**
87
+
88
+ Run the following commands in your console to verify that the page
89
+ was installed.
90
+
91
+ .. code-block:: bash
92
+
93
+ # Test installation
94
+ qa4sm --version
95
+
96
+ # Check available commands
97
+ qa4sm --help
98
+
99
+
100
+ Authentication
101
+ --------------
102
+ In order to use the full API, you need to authenticate with QA4SM
103
+ via your user token.
104
+
105
+ 1) Go to https://qa4sm.eu/ui/user-profile and request an API token
106
+ 2) Choose one of the following 2 options to add the token to the
107
+ local file ~/.qa4smapirc to use the API
108
+
109
+ **Option 1: Manual setup**
110
+
111
+ Create ``~/.qa4smapirc`` (Linux/MacOs) or ``%USERPROFILE%\.qa4smapirc`` (Windows)
112
+ with your credentials:
113
+
114
+ .. code-block:: ini
115
+
116
+ [qa4sm.eu]
117
+ token: your_api_token_here
118
+ username: your_username
119
+
120
+
121
+ **Option 2: Automated setup**
122
+
123
+ .. code-block:: bash
124
+
125
+ qa4sm api setup
126
+
127
+ This prompts for your username and password and stores your API token in ``~/.qa4smapirc``.
128
+
129
+ Documentation
130
+ -------------
131
+
132
+ Full documentation is available at https://awst-austria.github.io/qa4sm-api/
133
+
134
+ Quick Start
135
+ ===========
136
+
137
+ Here are some example commands on using the API in a python application.
138
+ See the full documentation at https://awst-austria.github.io/qa4sm-api/
139
+ for more examples.
140
+
141
+ .. code-block:: python
142
+
143
+ >> from qa4sm_api.client_api import Connection, ValidationConfiguration
144
+ # Initialize connection
145
+ >> conn = Connection()
146
+ Hi, <username>! You're successfully logged in at https://qa4sm.eu/api/!
147
+
148
+
149
+ .. code-block:: python
150
+
151
+ # Get a list of available datasets
152
+ >> conn.datasets()[['short_name']]
153
+ Out[10]:
154
+ short_name
155
+ id
156
+ 1 C3S_combined
157
+ 2 SMAP_L3
158
+ 3 ASCAT
159
+ 4 ISMN
160
+ 5 GLDAS
161
+ 6 ESA_CCI_SM_combined
162
+ 7 SMOS_IC
163
+ ... ...
164
+ # Get a list of versions for a datasets
165
+
166
+
167
+ .. code-block:: python
168
+
169
+ >> conn.versions("C3S_combined")
170
+ Out[6]:
171
+ short_name pretty_name ... time_range_end geographical_range
172
+ 1 C3S_V201706 v201706 ... 2022-10-10 None
173
+ 10 C3S_V201812 v201812 ... 2018-12-31 None
174
+ 28 C3S_V201912 v201912 ... 2019-12-31 None
175
+ 31 C3S_V202012 v202012 ... 2020-12-31 None
176
+ 45 C3S_V202212 v202212 ... 2025-07-20 None
177
+ 58 C3S_V202312 v202312 ... 2025-07-20 None
178
+ 70 C3S_V202505 v202505 ... 2024-12-31 None
179
+
180
+
181
+ .. code-block:: python
182
+
183
+ # Download the configuration for a validation run
184
+ >> config = conn.download_configuration("9aeb663b-e24e-4541-8331-6ec3e0318d1f")
185
+ >> print(config.data)
186
+ {'name_tag': 'Test Case QA4SM_VA_metrics - Test scaling_no_scaling_DEFAULT', 'interval_from': '1978-11-01', 'interval_to': '2024-12-31', 'temporal_matching': 12, 'anomalies_method': 'none', 'anomalies_from': None, 'anomalies_to': None, 'min_lat': 34.0, 'min_lon': -11.2, 'max_lat': 71.6, 'max_lon': 48.3, 'scaling_method': 'none', 'metrics': [{'id': 'tcol', 'value': False}, {'id': 'bootstrap_tcol_cis', 'value': False}, {'id': 'stability_metrics', 'value': False}], 'intra_annual_metrics': {'intra_annual_metrics': False, 'intra_annual_type': '', 'intra_annual_overlap': None}, 'dataset_configs': [{'dataset_id': 1, 'version_id': 70, 'variable_id': 1, 'is_spatial_reference': False, 'is_temporal_reference': True, 'is_scaling_reference': False, 'basic_filters': [1], 'parametrised_filters': []}, {'dataset_id': 4, 'version_id': 69, 'variable_id': 4, 'is_spatial_reference': True, 'is_temporal_reference': False, 'is_scaling_reference': False, 'basic_filters': [1, 2], 'parametrised_filters': [{'id': 18, 'parameters': 'AMMA-CATCH,DAHRA,TAHMO,SD_DEM,CHINA,CTP_SMTMN,HiWATER_EHWSN,HSC_SEOLMACHEON,IIT_KANPUR,KHOREZM,MAQU,MONGOLIA,MySMNet,RUSWET-AGRO,RUSWET-GRASS,RUSWET-VALDAI,SKKU,SW-WHU,KIHS_CMC,KIHS_SMC,VDS,NAQU,NGARI,SMN-SDR,SONTE-China,WIT-Network,AACES,OZNET,SASMAS,BIEBRZA_S-1,CALABRIA,CAMPANIA,FMI,FR_Aqui,GROW,GTK,HOBE,HYDROL-NET_PERUGIA,IMA_CAN1,METEROBS,MOL-RAO,ORACLE,REMEDHUS,RSMN,SMOSMANIA,SWEX_POLAND,TERENO,UDC_SMOS,UMBRIA,UMSUOL,VAS,WEGENERNET,WSMN,HOAL,IPE,COSMOS-UK,LABFLUX,NVE,Ru_CFR,STEMS,TWENTE,XMS-CAT,ARM,AWDN,BNZ-LTER,FLUXNET-AMERIFLUX,ICN,IOWA,PBO_H2O,RISMA,SCAN,SNOTEL,SOILSCAPE,USCRN,USDA-ARS,TxSON,LAB-net,PTSMN'}, {'id': 24, 'parameters': '0.00,0.10'}]}], 'settings_changes': {'filters': [], 'anomalies': False, 'scaling': False, 'variables': [], 'versions': []}}
187
+
188
+ .. code-block:: python
189
+
190
+ # Start a new validation using the local validation configuration
191
+ >> r = conn.start_validation(config)
192
+ # The validation run is now triggered under your user account, check https://qa4sm.eu/ui/my-validations
193
+ >> print(r.status)
194
+ 'SCHEDULED'
195
+
196
+ CLI Commands
197
+ ------------
198
+
199
+ - ``qa4sm api setup`` - Configure authentication
200
+ - ``qa4sm api check`` - Verify authentication
201
+ - ``qa4sm validate CONFIG.json`` - Submit a validation run
202
+ - ``qa4sm download config RUN_ID`` - Download configuration
203
+ - ``qa4sm download results RUN_ID`` - Download validation results
204
+
205
+ Use ``qa4sm --help`` for all commands.
206
+
207
+ Testing
208
+ -------
209
+
210
+ Run tests:
211
+
212
+ .. code-block:: bash
213
+
214
+ pip install -e ".[testing]"
215
+ pytest