Skip to content

Commit

Permalink
v0.1.400
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 626030218
  • Loading branch information
Google Earth Engine Authors authored and naschmitz committed Apr 24, 2024
1 parent b191918 commit 67e748b
Show file tree
Hide file tree
Showing 17 changed files with 3,548 additions and 973 deletions.
1,191 changes: 596 additions & 595 deletions javascript/build/ee_api_js.js

Large diffs are not rendered by default.

342 changes: 177 additions & 165 deletions javascript/build/ee_api_js_debug.js

Large diffs are not rendered by default.

386 changes: 199 additions & 187 deletions javascript/build/ee_api_js_npm.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion javascript/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@google/earthengine",
"version": "0.1.399",
"version": "0.1.400",
"description": "JavaScript client for Google Earth Engine API.",
"author": "Google LLC",
"license": "Apache-2.0",
Expand Down
2 changes: 1 addition & 1 deletion javascript/src/apiclient.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const {trustedResourceUrl} = goog.require('safevalues');
/** @namespace */
const apiclient = {};

const API_CLIENT_VERSION = '0.1.399';
const API_CLIENT_VERSION = '0.1.400';

exports.VERSION = apiVersion.VERSION;
exports.API_CLIENT_VERSION = API_CLIENT_VERSION;
Expand Down
9 changes: 8 additions & 1 deletion python/ee/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""The EE Python library."""

__version__ = '0.1.399'
__version__ = '0.1.400'

# Using lowercase function naming to match the JavaScript names.
# pylint: disable=g-bad-name
Expand Down Expand Up @@ -210,11 +210,18 @@ def Initialize(
# These must happen last.
_InitializeGeneratedClasses()
_InitializeUnboundMethods()
_InitializeDeprecatedAssets()


def _InitializeDeprecatedAssets() -> None:
"""Initialize deprecated assets."""
deprecation.InitializeDeprecatedAssets()


def Reset() -> None:
"""Reset the library. Useful for re-initializing to a different server."""
data.reset()
deprecation.Reset()

# Must call reset on the base class before any of its derived classes.
ApiFunction.reset()
Expand Down
9 changes: 9 additions & 0 deletions python/ee/cli/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,15 @@ def run(
'authorization_code', 'quiet', 'code_verifier', 'auth_mode', 'force')}
if args.scopes:
args_auth['scopes'] = args.scopes.split(',')

if ee.oauth.in_colab_shell():
print(
'Authenticate: Limited support in Colab. Use ee.Authenticate()'
' or --auth_mode=notebook instead.'
)
if not args.auth_mode:
args_auth['auth_mode'] = 'notebook'

if ee.Authenticate(**args_auth):
print('Authenticate: Credentials already exist. Use --force to refresh.')

Expand Down
36 changes: 25 additions & 11 deletions python/ee/deprecation.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
_DEPRECATED_ASSETS_URL = f'https://storage.googleapis.com/{_DEPRECATED_OBJECT}'

# Deprecation warnings are per-asset, per-initialization.
deprecated_assets: Dict[str, _DeprecatedAsset] = None
deprecated_assets: Dict[str, DeprecatedAsset] = None


def Deprecated(message: str):
Expand Down Expand Up @@ -63,27 +63,32 @@ def Wrapper(*args, **kwargs):


@dataclasses.dataclass
class _DeprecatedAsset:
class DeprecatedAsset:
"""Class for keeping track of a single deprecated asset."""

id: str
replacement_id: Optional[str]
removal_date: Optional[datetime.datetime]
learn_more_url: str
learn_more_url: Optional[str]

has_warning_been_issued: bool = False

@classmethod
def _ParseDateString(cls, date_str: str) -> datetime.datetime:
return datetime.datetime.fromisoformat(date_str)
def _ParseDateString(cls, date_str: str) -> Optional[datetime.datetime]:
try:
# We can't use `datetime.datetime.fromisoformat` because it's behavior
# changes by Python version.
return datetime.datetime.strptime(date_str, '%Y-%m-%dT%H:%M:%S%z')
except ValueError:
return None

@classmethod
def FromStacLink(cls, stac_link: Dict[str, Any]) -> _DeprecatedAsset:
def FromStacLink(cls, stac_link: Dict[str, Any]) -> DeprecatedAsset:
removal_date = stac_link.get('gee:removal_date')
if removal_date:
if removal_date is not None:
removal_date = cls._ParseDateString(removal_date)
return _DeprecatedAsset(
id=stac_link['title'],
return DeprecatedAsset(
id=stac_link.get('title'),
replacement_id=stac_link.get('gee:replacement_id'),
removal_date=removal_date,
learn_more_url=stac_link.get('gee:learn_more_url'),
Expand Down Expand Up @@ -124,6 +129,15 @@ def Wrapper(*args, **kwargs) -> Callable[..., Any]:


def InitializeDeprecatedAssets() -> None:
# Deprecated asset functionality is not critical. A warning is enough if
# something unexpected happens.
try:
_InitializeDeprecatedAssetsInternal()
except Exception as e: # pylint: disable=broad-except
warnings.warn(f'Unable to initialize deprecated assets: {e}')


def _InitializeDeprecatedAssetsInternal() -> None:
global deprecated_assets
if deprecated_assets is not None:
return
Expand All @@ -133,7 +147,7 @@ def InitializeDeprecatedAssets() -> None:
stac = _FetchDataCatalogStac()
for stac_link in stac.get('links', []):
if stac_link.get('deprecated', False):
asset = _DeprecatedAsset.FromStacLink(stac_link)
asset = DeprecatedAsset.FromStacLink(stac_link)
deprecated_assets[asset.id] = asset


Expand Down Expand Up @@ -163,7 +177,7 @@ def _UnfilterDeprecationWarnings() -> None:
)


def _IssueAssetDeprecationWarning(asset: _DeprecatedAsset) -> None:
def _IssueAssetDeprecationWarning(asset: DeprecatedAsset) -> None:
"""Issues a warning for a deprecated asset if one hasn't already been issued.
Args:
Expand Down
Loading

0 comments on commit 67e748b

Please sign in to comment.