Skip to content

Commit

Permalink
Merge branch 'tests' of https://github.com/naschmitz/Xee into tests
Browse files Browse the repository at this point in the history
  • Loading branch information
naschmitz committed Nov 5, 2023
2 parents 681736f + cca41a4 commit ae3200a
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 3 deletions.
16 changes: 14 additions & 2 deletions examples/ee_to_zarr.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@
import xee

import ee

from google.auth import identity_pool
import json
import os
from google import auth

logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
Expand Down Expand Up @@ -64,14 +67,23 @@ def _parse_chunks_str(chunks_str: str) -> dict[str, int]:
return chunks


def _read_creds() -> identity_pool.Credentials:
with open(os.environ['GOOGLE_APPLICATION_CREDENTIALS']) as json_file:
json_config_info = json.loads(json_file.read())
credentials = identity_pool.Credentials.from_info(json_config_info)
return credentials.with_scopes(
['https://www.googleapis.com/auth/cloud-platform', 'https://www.googleapis.com/auth/earthengine'])


def main(argv: list[str]) -> None:
assert _INPUT.value, 'Must specify --input'
assert _OUTPUT.value, 'Must specify --output'

source_chunks = {'time': 24}
target_chunks = dict(source_chunks, **_parse_chunks_str(_TARGET_CHUNKS.value))

ee.Initialize(opt_url='https://earthengine-highvolume.googleapis.com')
credentials, project = auth.default()
ee.Initialize(credentials=_read_creds(), opt_url='https://earthengine-highvolume.googleapis.com')

ds = xr.open_dataset(
_INPUT.value,
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"dask",
"pytest",
"pyink",
"dask",
]

examples_require = [
Expand Down
11 changes: 11 additions & 0 deletions xee/ext_integration_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,17 @@
import xee

import ee
from google.auth import identity_pool
import json
import os
from google import auth

def _read_creds() -> identity_pool.Credentials:
with open(os.environ['GOOGLE_APPLICATION_CREDENTIALS']) as json_file:
json_config_info = json.loads(json_file.read())
credentials = identity_pool.Credentials.from_info(json_config_info)
return credentials.with_scopes(
['https://www.googleapis.com/auth/cloud-platform', 'https://www.googleapis.com/auth/earthengine'])


def init_ee_for_tests():
Expand Down
15 changes: 14 additions & 1 deletion xee/micro_benchmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,28 @@
import xee

import ee
from google.auth import identity_pool
import json
import os
from google import auth


REPEAT = 10
LOOPS = 1
PROFILE = False


def _read_creds() -> identity_pool.Credentials:
with open(os.environ['GOOGLE_APPLICATION_CREDENTIALS']) as json_file:
json_config_info = json.loads(json_file.read())
credentials = identity_pool.Credentials.from_info(json_config_info)
return credentials.with_scopes(
['https://www.googleapis.com/auth/cloud-platform', 'https://www.googleapis.com/auth/earthengine'])


def init_ee_for_tests():
ee.Initialize(opt_url='https://earthengine-highvolume.googleapis.com')
credentials, project = auth.default()
ee.Initialize(credentials=_read_creds(), opt_url='https://earthengine-highvolume.googleapis.com')


def open_dataset() -> None:
Expand Down

0 comments on commit ae3200a

Please sign in to comment.