Skip to content

Commit

Permalink
v0.1.373
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 569348248
  • Loading branch information
Google Earth Engine Authors authored and sufyanAbbasi committed Oct 4, 2023
1 parent d12607b commit 4fd1caf
Show file tree
Hide file tree
Showing 24 changed files with 1,137 additions and 710 deletions.
1,216 changes: 609 additions & 607 deletions javascript/build/ee_api_js.js

Large diffs are not rendered by default.

58 changes: 44 additions & 14 deletions javascript/build/ee_api_js_debug.js

Large diffs are not rendered by default.

58 changes: 44 additions & 14 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.371",
"version": "0.1.373",
"description": "JavaScript client for Google Earth Engine API.",
"author": "Google LLC",
"license": "Apache-2.0",
Expand Down
15 changes: 8 additions & 7 deletions javascript/src/apiclient.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const {PromiseRequestService} = goog.require('eeapiclient.promise_request_servic
/** @namespace */
const apiclient = {};

const API_CLIENT_VERSION = '0.1.371';
const API_CLIENT_VERSION = '0.1.373';

exports.VERSION = apiVersion.VERSION;
exports.API_CLIENT_VERSION = API_CLIENT_VERSION;
Expand Down Expand Up @@ -533,7 +533,7 @@ apiclient.setAuthToken = function(
}
} else {
apiclient.ensureAuthLibLoaded_(function() {
goog.global['gapi']['auth']['setToken'](tokenObject);
goog.global['gapi']['client']['setToken'](tokenObject);
if (callback) {
callback();
}
Expand Down Expand Up @@ -561,7 +561,8 @@ apiclient.refreshAuthToken = function(success, error, onImmediateFailed) {
const authArgs = {
'client_id': String(apiclient.authClientId_),
'immediate': true,
'scope': apiclient.authScopes_.join(' ')
'scope': apiclient.authScopes_.join(' '),
'plugin_name': 'earthengine',
};

// Start the authorization flow, first trying immediate mode, which tries to
Expand All @@ -575,7 +576,7 @@ apiclient.refreshAuthToken = function(success, error, onImmediateFailed) {
// Refresh the library auth token and handle error propagation.
apiclient.ensureAuthLibLoaded_(function() {
try {
goog.global['gapi']['auth']['setToken'](result);
goog.global['gapi']['client']['setToken'](result);
apiclient.handleAuthResult_(success, error, result);
} catch (e) {
error(e.toString());
Expand Down Expand Up @@ -1128,13 +1129,13 @@ apiclient.ensureAuthLibLoaded_ = function(callback) {
// Speed up auth request by using CORS instead of an iframe.
goog.global['gapi']['config']['update']('client/cors', true);
if (!apiclient.authTokenRefresher_) {
apiclient.setAuthTokenRefresher(goog.global['gapi']['auth']['authorize']);
apiclient.setAuthTokenRefresher(goog.global['gapi']['auth2']['authorize']);
}
callback();
};
if (goog.isObject(goog.global['gapi']) &&
goog.isObject(goog.global['gapi']['auth']) &&
typeof goog.global['gapi']['auth']['authorize'] === 'function') {
goog.isObject(goog.global['gapi']['auth2']) &&
typeof goog.global['gapi']['auth2']['authorize'] === 'function') {
done();
} else {
// The library is not loaded; load it now.
Expand Down
2 changes: 1 addition & 1 deletion javascript/src/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ ee.data.authenticate = function(
* @export
*/
ee.data.authenticateViaPopup = function(opt_success, opt_error) {
goog.global['gapi']['auth']['authorize'](
goog.global['gapi']['auth2']['authorize'](
{
'client_id': ee.apiclient.getAuthClientId(),
'immediate': false,
Expand Down
25 changes: 12 additions & 13 deletions javascript/src/imagecollection.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,30 +328,29 @@ ee.ImageCollection.prototype.select = function(selectors, opt_names) {
* Links images in this collection to matching images from `imageCollection`.
*
* For each source image in this collection, any specified bands or metadata
* will be added to the source image from the matching image
* found in `imageCollection` If the bands or metadata are already present
* they will be overwritten. If a matching image is not found, any new or
* updated bands will be fully masked and any new or updated metadata will be
* null. The output footprint will be the same as the source image footprint.
* will be added to the source image from the matching image found in
* `imageCollection`. If bands or metadata are already present, they will be
* overwritten. If matching images are not found, any new or updated bands will
* be fully masked and any new or updated metadata will be null. The output
* footprint will be the same as the source image footprint.
*
* A match is determined if the source image and an image in `imageCollection`
* Matches are determined if a source image and an image in `imageCollection`
* have a specific equivalent metadata property. If more than one collection
* image would match, the collection image selected is arbitrary. By default,
* images are matched on their 'system:index' metadata property.
*
* This linking function is a convenience method for adding bands to a target
* image based on a specified shared metadata property and is intended to
* This linking function is a convenience method for adding bands to target
* images based on a specified shared metadata property and is intended to
* support linking collections that apply different processing/product
* generation to the same source imagery. For more expressive linking known
* as 'joining', see
* https://developers.google.com/earth-engine/guides/joins_intro.
* generation to the same source imagery. For more expressive linking known as
* 'joining', see https://developers.google.com/earth-engine/guides/joins_intro.
*
* @param {!ee.ImageCollection} imageCollection The image collection searched to
* find matches from this collection.
* @param {?Array<string>=} opt_linkedBands Optional list of band names to add
* or update from the matching image.
* or update from matching images.
* @param {?Array<string>=} opt_linkedProperties Optional list of metadata
* properties to add or update from the matching image.
* properties to add or update from matching images.
* @param {string=} opt_matchPropertyName The metadata property name to use as a
* match criteria. Defaults to "system:index".
* @return {!ee.ImageCollection} The linked image collection.
Expand Down
2 changes: 1 addition & 1 deletion python/ee/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python3
"""The EE Python library."""

__version__ = '0.1.371'
__version__ = '0.1.373'

# Using lowercase function naming to match the JavaScript names.
# pylint: disable=g-bad-name
Expand Down
32 changes: 24 additions & 8 deletions python/ee/batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

# pylint: disable=g-bad-name

from __future__ import annotations

import enum
import json
import re
Expand All @@ -29,6 +31,8 @@ class Type(str, enum.Enum):
EXPORT_VIDEO = 'EXPORT_VIDEO'

class State(str, enum.Enum):
"""The state of a Task."""

UNSUBMITTED = 'UNSUBMITTED'
READY = 'READY'
RUNNING = 'RUNNING'
Expand All @@ -37,6 +41,20 @@ class State(str, enum.Enum):
CANCEL_REQUESTED = 'CANCEL_REQUESTED'
CANCELLED = 'CANCELLED'

@classmethod
def active(cls, state: Union[str, Task.State]) -> bool:
"""Returns True if the given state is an active one."""
if isinstance(state, str):
state = cls(state)
return state in (cls.READY, cls.RUNNING, cls.CANCEL_REQUESTED)

@classmethod
def success(cls, state: Union[str, Task.State]) -> bool:
"""Returns True if the given state indicates a completed task."""
if isinstance(state, str):
state = cls(state)
return state == cls.COMPLETED

class ExportDestination(str, enum.Enum):
DRIVE = 'DRIVE'
GCS = 'GOOGLE_CLOUD_STORAGE'
Expand Down Expand Up @@ -142,16 +160,14 @@ def status(self) -> Dict[str, Any]:

def active(self) -> bool:
"""Returns whether the task is still running."""
return self.status()['state'] in (Task.State.READY,
Task.State.RUNNING,
Task.State.CANCEL_REQUESTED)
return Task.State.active(self.status()['state'])

def cancel(self) -> None:
"""Cancels the task."""
data.cancelTask(self.id)

@staticmethod
def list() -> List['Task']:
def list() -> List[Task]:
"""Returns the tasks submitted to EE by the current user.
These include all currently running tasks as well as recently canceled or
Expand Down Expand Up @@ -214,7 +230,7 @@ def __new__(
lists of numbers or a serialized string. Defaults to the image's
region.
- scale: The resolution in meters per pixel.
Defaults to the native resolution of the image assset unless
Defaults to the native resolution of the image asset unless
a crs_transform is specified.
- maxPixels: The maximum allowed number of pixels in the exported
image. The task will fail if the exported region covers
Expand Down Expand Up @@ -292,7 +308,7 @@ def toAsset(
lists of numbers or a serialized string. Defaults to the image's
region.
scale: The resolution in meters per pixel. Defaults to the
native resolution of the image assset unless a crsTransform
native resolution of the image asset unless a crsTransform
is specified.
crs: The coordinate reference system of the exported image's
projection. Defaults to the image's default projection.
Expand Down Expand Up @@ -350,7 +366,7 @@ def toCloudStorage(image,
lists of numbers or a serialized string. Defaults to the image's
region.
scale: The resolution in meters per pixel. Defaults to the
native resolution of the image assset unless a crsTransform
native resolution of the image asset unless a crsTransform
is specified.
crs: The coordinate reference system of the exported image's
projection. Defaults to the image's default projection.
Expand Down Expand Up @@ -421,7 +437,7 @@ def toDrive(image,
lists of numbers or a serialized string. Defaults to the image's
region.
scale: The resolution in meters per pixel. Defaults to the
native resolution of the image assset unless a crsTransform
native resolution of the image asset unless a crsTransform
is specified.
crs: The coordinate reference system of the exported image's
projection. Defaults to the image's default projection.
Expand Down
7 changes: 2 additions & 5 deletions python/ee/cli/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import shutil
import sys
import tempfile
from typing import Any, Dict, Hashable, List, Optional, Sequence, Tuple, Type, Union
from typing import Any, Dict, List, Sequence, Tuple, Type, Union
import urllib.parse

# Prevent TensorFlow from logging anything at the native level.
Expand Down Expand Up @@ -1908,10 +1908,7 @@ class ModelCommand(Dispatcher):

COMMANDS = [PrepareModelCommand]

EXTERNAL_COMMANDS = [
AuthenticateCommand,
AclCommand,
AssetCommand,

CopyCommand,
CreateCommand,
ListCommand,
Expand Down
4 changes: 3 additions & 1 deletion python/ee/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
# Using lowercase function naming to match the JavaScript names.
# pylint: disable=g-bad-name

from __future__ import annotations

import datetime
from typing import Any, Callable, Dict, Optional, Type, Union

Expand Down Expand Up @@ -159,7 +161,7 @@ def limit(
maximum: int,
opt_property: Optional[str] = None,
opt_ascending: Optional[bool] = None,
) -> 'Collection':
) -> Collection:
"""Limit a collection to the specified number of elements.
This limits a collection to the specified number of elements, optionally
Expand Down
7 changes: 5 additions & 2 deletions python/ee/computedobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from __future__ import annotations

from typing import Any, Dict, Optional
from typing import Any, Callable, Dict, Optional

from ee import data
from ee import ee_exception
Expand Down Expand Up @@ -104,14 +104,17 @@ def getInfo(self) -> Optional[Any]:
"""
return data.computeValue(self)

def encode(self, encoder: Any) -> Dict[str, Any]:
def encode(self, encoder: Optional[Callable[..., Any]]) -> Dict[str, Any]:
"""Encodes the object in a format compatible with Serializer."""
if self.isVariable():
return {
'type': 'ArgumentRef',
'value': self.varName
}
else:
if encoder is None:
raise ValueError(
'encoder can only be none when encode is for a variable.')
# Encode the function that we're calling.
func = encoder(self.func)
# Built-in functions are encoded as strings under a different key.
Expand Down
4 changes: 3 additions & 1 deletion python/ee/customfunction.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/usr/bin/env python3
"""An object representing a custom EE Function."""

from __future__ import annotations

from typing import Any, Callable, Dict, Optional

from ee import computedobject
Expand Down Expand Up @@ -96,7 +98,7 @@ def variable(type_name: Optional[str], name: str) -> Any:
@staticmethod
def create(
func: Callable[[Any], Any], return_type: Any, arg_types: Any
) -> 'CustomFunction':
) -> CustomFunction:
"""Creates a CustomFunction.
The result calls a given native function with the specified return type and
Expand Down
Loading

0 comments on commit 4fd1caf

Please sign in to comment.