Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't require USE_ADC_CREDENTIALS=1 to run tests. #220

Merged
merged 3 commits into from
Feb 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 30 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ _An Xarray extension for Google Earth Engine._

[![image](https://img.shields.io/pypi/v/xee.svg)](https://pypi.python.org/pypi/xee)
[![image](https://static.pepy.tech/badge/xee)](https://pepy.tech/project/xee)
[![Conda Recipe](https://img.shields.io/badge/recipe-xee-green.svg)](https://github.com/conda-forge/xee-feedstock)
[![Conda
Recipe](https://img.shields.io/badge/recipe-xee-green.svg)](https://github.com/conda-forge/xee-feedstock)
[![image](https://img.shields.io/conda/vn/conda-forge/xee.svg)](https://anaconda.org/conda-forge/xee)
[![Conda Downloads](https://img.shields.io/conda/dn/conda-forge/xee.svg)](https://anaconda.org/conda-forge/xee)
[![Conda
Downloads](https://img.shields.io/conda/dn/conda-forge/xee.svg)](https://anaconda.org/conda-forge/xee)

## How to use

Expand Down Expand Up @@ -62,14 +64,16 @@ ds = xarray.open_dataset('ee://ECMWF/ERA5_LAND/HOURLY', engine='ee',
Open an ImageCollection (maybe, with EE-side filtering or processing):

```python
ic = ee.ImageCollection('ECMWF/ERA5_LAND/HOURLY').filterDate('1992-10-05', '1993-03-31')
ic = ee.ImageCollection('ECMWF/ERA5_LAND/HOURLY').filterDate(
'1992-10-05', '1993-03-31')
ds = xarray.open_dataset(ic, engine='ee', crs='EPSG:4326', scale=0.25)
```

Open an ImageCollection with a specific EE projection or geometry:

```python
ic = ee.ImageCollection('ECMWF/ERA5_LAND/HOURLY').filterDate('1992-10-05', '1993-03-31')
ic = ee.ImageCollection('ECMWF/ERA5_LAND/HOURLY').filterDate(
'1992-10-05', '1993-03-31')
leg1 = ee.Geometry.Rectangle(113.33, -43.63, 153.56, -10.66)
ds = xarray.open_dataset(
ic,
Expand All @@ -79,17 +83,19 @@ ds = xarray.open_dataset(
)
```

Open multiple ImageCollections into one `xarray.Dataset`, all with the same projection:
Open multiple ImageCollections into one `xarray.Dataset`, all with the same
projection:

```python
ds = xarray.open_mfdataset(['ee://ECMWF/ERA5_LAND/HOURLY', 'ee://NASA/GDDP-CMIP6'],
engine='ee', crs='EPSG:4326', scale=0.25)
ds = xarray.open_mfdataset(
['ee://ECMWF/ERA5_LAND/HOURLY', 'ee://NASA/GDDP-CMIP6'],
engine='ee', crs='EPSG:4326', scale=0.25)
```

Open a single Image by passing it to an ImageCollection:

```python
i = ee.ImageCollection(ee.Image("LANDSAT/LC08/C02/T1_TOA/LC08_044034_20140318"))
i = ee.ImageCollection(ee.Image('LANDSAT/LC08/C02/T1_TOA/LC08_044034_20140318'))
ds = xarray.open_dataset(i, engine='ee')
```

Expand All @@ -107,14 +113,20 @@ ds = xr.open_dataset(
)
```

See [examples](https://github.com/google/Xee/tree/main/examples) or [docs](https://github.com/google/Xee/tree/main/docs) for more uses and integrations.
See [examples](https://github.com/google/Xee/tree/main/examples) or
[docs](https://github.com/google/Xee/tree/main/docs) for more uses and
integrations.

## Getting help

If you encounter issues using Xee, you can:

1. Open a new or add to an existing [Xee discussion topic](https://github.com/google/Xee/discussions)
2. Open an [Xee issue](https://github.com/google/Xee/issues). To increase the likelihood of the issue being resolved, use this [template Colab notebook](https://colab.research.google.com/drive/1vAgfAPhKGJd4G9ZUOzciqZ7MbqJjlMLR) to create a reproducible script.
1. Open a new or add to an existing [Xee discussion
topic](https://github.com/google/Xee/discussions)
2. Open an [Xee issue](https://github.com/google/Xee/issues). To increase the
likelihood of the issue being resolved, use this [template Colab
notebook](https://colab.research.google.com/drive/1vAgfAPhKGJd4G9ZUOzciqZ7MbqJjlMLR)
to create a reproducible script.

## How to run integration tests

Expand All @@ -123,7 +135,13 @@ integration tests locally before sending a PR. To run the tests locally,
authenticate using `earthengine authenticate` and run the following:

```bash
USE_ADC_CREDENTIALS=1 python -m unittest xee/ext_integration_test.py
python -m unittest xee/ext_integration_test.py
```

or

```bash
python -m pytest xee/ext_integration_test.py
```

## License
Expand Down
3 changes: 1 addition & 2 deletions xee/ext_integration_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
'https://www.googleapis.com/auth/cloud-platform',
'https://www.googleapis.com/auth/earthengine',
]
_USE_ADC_CREDENTIALS_KEY = 'USE_ADC_CREDENTIALS'


def _read_identity_pool_creds() -> identity_pool.Credentials:
Expand All @@ -54,7 +53,7 @@ def init_ee_for_tests():
init_params = {
'opt_url': ee.data.HIGH_VOLUME_API_BASE_URL,
}
if not os.environ.get(_USE_ADC_CREDENTIALS_KEY, False):
if _CREDENTIALS_PATH_KEY in os.environ:
credentials = _read_identity_pool_creds()
init_params['credentials'] = credentials
init_params['project'] = credentials.project_number
Expand Down
Loading