Skip to content

Commit

Permalink
Add argument to generate ee credentials on-demand.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 710437577
  • Loading branch information
Xee authors committed Dec 29, 2024
1 parent 5ce8db6 commit a5e7c33
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions xee/ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@
from __future__ import annotations

import concurrent.futures
import copy
import functools
import importlib
import itertools
import logging
import math
import os
import sys
from typing import Any, Dict, Iterable, List, Literal, Optional, Sequence, Tuple, Union
from typing import Any, Callable, Dict, Iterable, List, Literal, Optional, Sequence, Tuple, Union
from urllib import parse
import warnings

Expand Down Expand Up @@ -803,7 +804,20 @@ def _ee_init_check(self):
'Attempting to initialize using application default credentials.'
)

ee.Initialize(**(self.store.ee_init_kwargs or {}))
ee_init_kwargs = copy.copy(self.store.ee_init_kwargs) or {}
if (
'credentials' in ee_init_kwargs
and 'credentials_function' in ee_init_kwargs
):
raise ValueError(
'Cannot specify both credentials and credentials_function.'
)
if 'credentials_function' in ee_init_kwargs:
credentials_function: Callable[[], Any] = ee_init_kwargs.pop(
'credentials_function'
)
ee_init_kwargs['credentials'] = credentials_function()
ee.Initialize(**ee_init_kwargs)

def __getitem__(self, key: indexing.ExplicitIndexer) -> np.typing.ArrayLike:
return indexing.explicit_indexing_adapter(
Expand Down

0 comments on commit a5e7c33

Please sign in to comment.