Skip to content

Commit

Permalink
Add earthaccess login test
Browse files Browse the repository at this point in the history
  • Loading branch information
giswqs committed Sep 1, 2024
1 parent b8f719c commit 4ceee57
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 1 deletion.
36 changes: 36 additions & 0 deletions .github/workflows/test-earthdata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: test-earthdata
on:
pull_request:
branches:
- main
- master

jobs:
test-earthdata:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: "3.11"
env:
EARTHDATA_USERNAME: ${{ secrets.EARTHDATA_USERNAME }}
EARTHDATA_PASSWORD: ${{ secrets.EARTHDATA_PASSWORD }}

- name: Install GDAL
run: |
python -m pip install --upgrade pip
pip install --find-links=https://girder.github.io/large_image_wheels --no-cache GDAL pyproj
- name: Test GDAL installation
run: |
python -c "from osgeo import gdal"
gdalinfo --version
- name: Install dependencies
run: |
pip install --no-cache-dir Cython
pip install -r requirements.txt -r requirements_dev.txt
pip install .
- name: Test import
run: python -c "import earthaccess;earthaccess.login(strategy='environment');print('NASA EarthData login successful')"
9 changes: 9 additions & 0 deletions docs/workshops/pace.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,15 @@
"m"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"m.cog_layer_dict"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down
3 changes: 2 additions & 1 deletion hypercoast/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,12 +472,13 @@ def nasa_earth_login(strategy: str = "all", persist: bool = True, **kwargs) -> N
persist (bool, optional): Whether to persist the login. Defaults to True.
"""
from leafmap import get_api_key
import earthaccess

USERNAME = get_api_key("EARTHDATA_USERNAME")
PASSWORD = get_api_key("EARTHDATA_PASSWORD")
if (USERNAME is not None) and (PASSWORD is not None):
strategy = "environment"
leafmap.nasa_data_login(strategy=strategy, persist=persist, **kwargs)
earthaccess.login(strategy=strategy, persist=persist, **kwargs)


def convert_coords(
Expand Down

0 comments on commit 4ceee57

Please sign in to comment.