Skip to content

Commit 2a34802

Browse files
authored
Merge pull request #670 from dbekaert/dev
v0.5.2
2 parents 223d862 + 2b7190c commit 2a34802

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+125065
-696
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ on:
1212

1313
jobs:
1414
call-version-info-workflow:
15-
uses: ASFHyP3/actions/.github/workflows/reusable-version-info.yml@v0.11.0
15+
uses: ASFHyP3/actions/.github/workflows/reusable-version-info.yml@v0.11.2
1616
with:
1717
python_version: '3.10'
1818

1919
call-docker-ghcr-workflow:
2020
needs: call-version-info-workflow
21-
uses: ASFHyP3/actions/.github/workflows/reusable-docker-ghcr.yml@v0.11.0
21+
uses: ASFHyP3/actions/.github/workflows/reusable-docker-ghcr.yml@v0.11.2
2222
with:
2323
version_tag: ${{ needs.call-version-info-workflow.outputs.version_tag }}
2424
release_branch: main

.github/workflows/changelog.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,4 @@ on:
1313

1414
jobs:
1515
call-changelog-check-workflow:
16-
uses: ASFHyP3/actions/.github/workflows/reusable-changelog-check.yml@v0.11.0
17-
secrets:
18-
USER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
16+
uses: ASFHyP3/actions/.github/workflows/reusable-changelog-check.yml@v0.11.2

.github/workflows/labeled-pr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ on:
1212

1313
jobs:
1414
call-labeled-pr-check-workflow:
15-
uses: ASFHyP3/actions/.github/workflows/reusable-labeled-pr-check.yml@v0.11.0
15+
uses: ASFHyP3/actions/.github/workflows/reusable-labeled-pr-check.yml@v0.11.2

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77

88
jobs:
99
call-release-workflow:
10-
uses: ASFHyP3/actions/.github/workflows/reusable-release.yml@v0.11.0
10+
uses: ASFHyP3/actions/.github/workflows/reusable-release.yml@v0.11.2
1111
with:
1212
release_prefix: RAiDER
1313
develop_branch: dev

.github/workflows/tag.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77

88
jobs:
99
call-bump-version-workflow:
10-
uses: ASFHyP3/actions/.github/workflows/reusable-bump-version.yml@v0.11.0
10+
uses: ASFHyP3/actions/.github/workflows/reusable-bump-version.yml@v0.11.2
1111
with:
1212
user: dbekaert
1313
email: bekaertdavid@gmail.com

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,17 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [PEP 440](https://www.python.org/dev/peps/pep-0440/)
77
and uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
88

9+
## [0.5.2]
10+
### Changed
11+
* [627](https://github.com/dbekaert/RAiDER/pull/627) - Made Python datetimes timezone-aware and added unit tests and bug fixes.
12+
* [651](https://github.com/dbekaert/RAiDER/pull/651) - Removed use of deprecated argument to `pandas.read_csv`.
13+
* [652](https://github.com/dbekaert/RAiDER/pull/652) - Changed the behavior of `RAiDER.models.credentials.check_api` to not overwrite the user's API credential files.
14+
* [656](https://github.com/dbekaert/RAiDER/pull/656) - Example run configuration files available through `raider.py --generate_config <example_name>`.
15+
* [657](https://github.com/dbekaert/RAiDER/pull/657) - Fixed a few typos in `README.md`.
16+
* [658](https://github.com/dbekaert/RAiDER/pull/658) - Fixed opaque error message if a GUNW file is not produced while HyP3 independently against a previous INSAR_ISCE.
17+
* [661](https://github.com/dbekaert/RAiDER/pull/661) - Fixed bug in raiderDownloadGNSS, removed call to scipy.sum, and added unit tests.
18+
* [662](https://github.com/dbekaert/RAiDER/pull/662) - Bumped dem-stitcher to >= v2.5.6, which updates the URL for reading the Geoid EGM 2008.
19+
920
## [0.5.1]
1021
### Changed
1122
* Use hyp3-lib v3* to download orbits to be able to distribute load across ESA and ASF. Can be easily swapped out for `sentineleof` in future release.
@@ -28,6 +39,7 @@ and uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
2839
## [0.4.6]
2940

3041
### Added
42+
* Added check for intermediate grid creation in _get_delays_on_cube
3143
* Adds an `s1_orbits.py` module which includes:
3244
* `get_orbits_from_slc_ids` to download the associated orbit files for a list of Sentinel-1 SLC IDs
3345
* `ensure_orbit_credentials` to ensure ESA CSDE credentials have been provides to download orbit files. This should be called before `sentineleof` is used to download orbits.

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ RAiDER does **not** currently run on arm64 processors on Mac. We will update thi
3636

3737
### Installing With Conda
3838

39-
RAiDER is available on [conda-forge](https://anaconda.org/conda-forge/raider). __[Conda](https://docs.conda.io/en/latest/index.html)__ is a cross-platform way to use Python that allows you to setup and use "virtual environments." These can help to keep dependencies for different sets of code separate. We recommend using [Miniforge](https://github.com/conda-forge/miniforge), a conda environment manager that uses conda-forge as its default code repo. Alternatively,see __[here](https://docs.anaconda.com/anaconda/install/)__ for help installing Anaconda and __[here](https://docs.conda.io/en/latest/miniconda.html)__ for installing Miniconda.
39+
RAiDER is available on [conda-forge](https://anaconda.org/conda-forge/raider). __[Conda](https://docs.conda.io/en/latest/index.html)__ is a cross-platform way to use Python that allows you to setup and use "virtual environments." These can help to keep dependencies for different sets of code separate. We recommend using [Miniforge](https://github.com/conda-forge/miniforge), a conda environment manager that uses conda-forge as its default code repo. Alternatively, see __[here](https://docs.anaconda.com/anaconda/install/)__ for help installing Anaconda and __[here](https://docs.conda.io/en/latest/miniconda.html)__ for installing Miniconda.
4040

4141
Installing RAiDER:
4242
```
@@ -85,8 +85,8 @@ RAiDER has the ability to download weather models from third-parties; some of wh
8585
## 3. Running RAiDER and Documentation
8686

8787
For detailed documentation, examples, and Jupyter notebooks see the [RAiDER-docs repository](https://github.com/dbekaert/RAiDER-docs).
88-
We welcome contributions of other examples on how to leverage the RAiDER (see [here](https://github.com/dbekaert/RAiDER/blob/dev/CONTRIBUTING.md) for instructions).
89-
``` raiderDelay.py -h ``` provides a help menu and list of example commands to get started.
88+
We welcome contributions of other examples on how to leverage the RAiDER (see [here](https://github.com/dbekaert/RAiDER/blob/dev/CONTRIBUTING.md) for instructions).
89+
``` raider.py -h ``` provides a help menu and set of example run configurations to get started.
9090
The RAiDER scripts are highly modularized in Python and allows for building your own processing workflow.
9191

9292
------

environment.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ dependencies:
1717
- cdsapi
1818
- cfgrib
1919
- dask
20-
- dem_stitcher>=2.3.1
20+
- dem_stitcher>=2.5.6
2121
- ecmwf-api-client
2222
- h5netcdf
2323
- h5py
@@ -67,3 +67,5 @@ dependencies:
6767
- jupyter_contrib_nbextensions
6868
- jupyterlab
6969
- wand
70+
# For development
71+
- boto3-stubs

test/__init__.py

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
import pytest
33
import subprocess
44
import shutil
5+
import string
6+
import random
57
from contextlib import contextmanager
68
from pathlib import Path
79

@@ -32,25 +34,30 @@ def pushd(dir):
3234
def update_yaml(dct_cfg:dict, dst:str='temp.yaml'):
3335
""" Write a new yaml file from a dictionary.
3436
35-
Updates parameters in the default 'raider.yaml' file.
37+
Updates parameters in the default 'template.yaml' file.
3638
Each key:value pair will in 'dct_cfg' will overwrite that in the default
3739
"""
3840
import RAiDER, yaml
3941

40-
template_file = os.path.join(
41-
os.path.dirname(RAiDER.__file__), 'cli', 'raider.yaml')
42+
run_config_path = os.path.join(
43+
os.path.dirname(RAiDER.__file__),
44+
'cli',
45+
'examples',
46+
'template',
47+
'template.yaml'
48+
)
4249

43-
with open(template_file, 'r') as f:
50+
with open(run_config_path, 'r') as f:
4451
try:
4552
params = yaml.safe_load(f)
4653
except yaml.YAMLError as exc:
4754
print(exc)
48-
raise ValueError(f'Something is wrong with the yaml file {template_file}')
55+
raise ValueError(f'Something is wrong with the yaml file {run_config_path}')
4956

5057
params = {**params, **dct_cfg}
5158

5259
with open(dst, 'w') as fh:
53-
yaml.safe_dump(params, fh, default_flow_style=False)
60+
yaml.safe_dump(params, fh, default_flow_style=False)
5461

5562
return dst
5663

@@ -77,4 +84,11 @@ def makeLatLonGrid(bbox, reg, out_dir, spacing=0.1):
7784

7885
def make_delay_name(weather_model_name, date, time, kind='ztd'):
7986
assert kind in 'ztd std ray'.split(), 'Incorrect type of delays.'
80-
return f'{weather_model_name}_tropo_{date}T{time.replace(":", "")}_{kind}.nc'
87+
return f'{weather_model_name}_tropo_{date}T{time.replace(":", "")}_{kind}.nc'
88+
89+
90+
def random_string(
91+
length: int = 32,
92+
alphabet: str = string.ascii_letters + string.digits
93+
) -> str:
94+
return ''.join(random.choices(alphabet, k=length))
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
'''
2+
When update_rc_file is either True or False, the relevant API RC file should be
3+
created if it doesn't exist.
4+
'''
5+
from typing import Tuple
6+
7+
import pytest
8+
import os
9+
from pathlib import Path
10+
from platform import system
11+
from RAiDER.models import credentials
12+
from test import random_string
13+
14+
15+
def get_creds_cds(rc_path: Path) -> Tuple[str, str]:
16+
import cdsapi
17+
cds_credentials = cdsapi.api.read_config(rc_path)
18+
uid, key = cds_credentials['key'].split(':')
19+
return uid, key
20+
21+
22+
def get_creds_ecmwf(rc_path: Path) -> Tuple[str, str]:
23+
import ecmwfapi
24+
# Get current ECMWF API RC file path
25+
old_rc_path = os.getenv("ECMWF_API_RC_FILE", ecmwfapi.api.DEFAULT_RCFILE_PATH)
26+
27+
# Point ecmwfapi to current dir to avoid overwriting ~/.ecmwfapirc
28+
os.environ["ECMWF_API_RC_FILE"] = str(rc_path)
29+
key, _, uid = ecmwfapi.api.get_apikey_values()
30+
31+
# Point ecmwfapi back to previous value and remove local API file
32+
os.environ["ECMWF_API_RC_FILE"] = old_rc_path
33+
return uid, key
34+
35+
36+
def get_creds_netrc(rc_path: Path) -> Tuple[str, str]:
37+
import netrc
38+
host = 'urs.earthdata.nasa.gov'
39+
netrc_credentials = netrc.netrc(rc_path)
40+
uid, _, key = netrc_credentials.authenticators(host)
41+
return uid, key
42+
43+
44+
@pytest.mark.parametrize(
45+
'model_name,get_creds',
46+
(
47+
('ERA5', get_creds_cds),
48+
('ERA5T', get_creds_cds),
49+
('HRES', get_creds_ecmwf),
50+
('GMAO', get_creds_netrc),
51+
('MERRA2', get_creds_netrc)
52+
)
53+
)
54+
def test_createFile(model_name, get_creds):
55+
# Get the rc file's path
56+
hidden_ext = '_' if system() == "Windows" else '.'
57+
rc_filename = credentials.RC_FILENAMES[model_name]
58+
if rc_filename is None:
59+
return
60+
rc_path = Path('./') / (hidden_ext + rc_filename)
61+
rc_path = rc_path.expanduser()
62+
rc_path.unlink(missing_ok=True)
63+
64+
test_uid = random_string()
65+
test_key = random_string()
66+
67+
# Test creation of the rc file
68+
credentials.check_api(model_name, test_uid, test_key, './', update_rc_file=False)
69+
assert rc_path.exists(), f'{rc_path} does not exist'
70+
71+
# Check if API is written correctly
72+
uid, key = get_creds(rc_path)
73+
rc_path.unlink()
74+
assert uid == test_uid, f'{rc_path}: UID was not written correctly'
75+
assert key == test_key, f'{rc_path}: KEY was not written correctly'

0 commit comments

Comments
 (0)