Skip to content

Commit

Permalink
v0.1.370
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 565718645
  • Loading branch information
Google Earth Engine Authors authored and naschmitz committed Sep 20, 2023
1 parent 1baca88 commit b98c266
Show file tree
Hide file tree
Showing 41 changed files with 409 additions and 261 deletions.
185 changes: 92 additions & 93 deletions javascript/build/ee_api_js.js

Large diffs are not rendered by default.

63 changes: 35 additions & 28 deletions javascript/build/ee_api_js_debug.js

Large diffs are not rendered by default.

107 changes: 57 additions & 50 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.369",
"version": "0.1.370",
"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 @@ -25,7 +25,7 @@ const {PromiseRequestService} = goog.require('eeapiclient.promise_request_servic
/** @namespace */
const apiclient = {};

const API_CLIENT_VERSION = '0.1.369';
const API_CLIENT_VERSION = '0.1.370';

exports.VERSION = apiVersion.VERSION;
exports.API_CLIENT_VERSION = API_CLIENT_VERSION;
Expand Down
2 changes: 0 additions & 2 deletions javascript/src/apifunction.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
*
* This class manages the algorithm dictionary and creates JavaScript functions
* to apply each EE algorithm.
*
* @author [email protected] (Max Shawabkeh)
*/

goog.provide('ee.ApiFunction');
Expand Down
1 change: 1 addition & 0 deletions javascript/src/batch.js
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ Export.table.toFeatureView = function(
* @param {string|!Array<string>=} opt_selectors
* @param {number=} opt_maxVertices
* @return {!ExportTask}
* @export
*/
Export.table.toBigQuery = function(
collection, opt_description, opt_table, opt_overwrite, opt_append,
Expand Down
1 change: 0 additions & 1 deletion javascript/src/collection.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/**
* @fileoverview Base class for ImageCollection and FeatureCollection.
* This class is never intended to be instantiated by the user.
* @author [email protected] (Noel Gorelick)
*/

goog.provide('ee.Collection');
Expand Down
2 changes: 0 additions & 2 deletions javascript/src/computedobject.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
/**
* @fileoverview A representation of a computed earthengine object.
*
* @author [email protected] (Noel Gorelick)
*/

goog.provide('ee.ComputedObject');
Expand Down
1 change: 0 additions & 1 deletion javascript/src/customfunction.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/**
* @fileoverview An object representing a custom EE Function.
* @author [email protected] (Max Shawabkeh)
*/

goog.provide('ee.CustomFunction');
Expand Down
1 change: 0 additions & 1 deletion javascript/src/data.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/**
* @fileoverview Singleton for all of the library's communication
* with the Earth Engine API.
* @author [email protected] (Noel Gorelick)
* @suppress {missingRequire} TODO(user): this shouldn't be needed
* @suppress {useOfGoogProvide} TODO(user): Convert to goog.module.
*/
Expand Down
2 changes: 0 additions & 2 deletions javascript/src/date.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
*
* We don't autogenerate this class because we want the constructor
* to promote by pushing things through the server-side Date() function.
*
* @author [email protected] (Noel Gorelick)
*/

goog.provide('ee.Date');
Expand Down
2 changes: 0 additions & 2 deletions javascript/src/deserializer.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
/**
* @fileoverview A deserializer that decodes EE object trees from JSON DAGs.
*
* @author [email protected] (Max Shawabkeh)
*/

goog.provide('ee.Deserializer');
Expand Down
1 change: 0 additions & 1 deletion javascript/src/dictionary.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/**
* @fileoverview A wrapper for dicts.
* @author [email protected] (Noel Gorelick)
*/

goog.provide('ee.Dictionary');
Expand Down
1 change: 0 additions & 1 deletion javascript/src/ee.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/**
* @fileoverview Initialization and convenience functions for the EE library.
* @author [email protected] (Noel Gorelick)
*/

goog.provide('ee');
Expand Down
1 change: 0 additions & 1 deletion javascript/src/element.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/**
* @fileoverview Base class for Image, Feature and Collection.
* This class is never intended to be instantiated by the user.
* @author [email protected] (Noel Gorelick)
*/

goog.provide('ee.Element');
Expand Down
1 change: 0 additions & 1 deletion javascript/src/encodable.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/**
* @fileoverview An interface implemented by serializable objects.
* @author [email protected] (Max Shawabkeh)
*/

goog.provide('ee.Encodable');
Expand Down
1 change: 0 additions & 1 deletion javascript/src/feature.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/**
* @fileoverview An object representing EE Features.
* @author [email protected] (Noel Gorelick)
*/

goog.provide('ee.Feature');
Expand Down
5 changes: 2 additions & 3 deletions javascript/src/featurecollection.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/**
* @fileoverview Representation of an Earth Engine FeatureCollection.
* @author [email protected] (Noel Gorelick)
*/

goog.provide('ee.FeatureCollection');
Expand Down Expand Up @@ -70,8 +69,8 @@ ee.FeatureCollection = function(args, opt_column) {
actualArgs['geometryColumn'] = opt_column;
}
ee.FeatureCollection.base(
this,
'constructor',
this,
'constructor',
new ee.ApiFunction('Collection.loadTable'), actualArgs);
} else if (Array.isArray(args)) {
// A list of features.
Expand Down
1 change: 0 additions & 1 deletion javascript/src/filter.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/**
* @fileoverview Collection filters.
* @author [email protected] (Noel Gorelick)
*
* new Filter('time', low, high)
* .bounds(ring)
Expand Down
1 change: 0 additions & 1 deletion javascript/src/function.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/**
* @fileoverview A base class for EE Functions.
* @author [email protected] (Max Shawabkeh)
*/

goog.provide('ee.Function');
Expand Down
1 change: 0 additions & 1 deletion javascript/src/geometry.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/**
* @fileoverview An object representing EE Geometries.
* @author [email protected] (Max Shawabkeh)
*/

goog.provide('ee.Geometry');
Expand Down
4 changes: 2 additions & 2 deletions javascript/src/image.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @fileoverview A representation of an earth engine image.
* See: https://sites.google.com/site/earthengineapidocs for more details.
* @author [email protected] (Noel Gorelick)
* See: https://developers.google.com/earth-engine/apidocs/ee-image for more
* details.
*/

goog.provide('ee.Image');
Expand Down
1 change: 0 additions & 1 deletion javascript/src/imagecollection.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/**
* @fileoverview Javascript representation for an Earth Engine ImageCollection.
* @author [email protected] (Noel Gorelick)
*/

goog.provide('ee.ImageCollection');
Expand Down
1 change: 0 additions & 1 deletion javascript/src/list.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/**
* @fileoverview A wrapper for Lists.
* @author [email protected] (Noel Gorelick)
*/

goog.provide('ee.List');
Expand Down
1 change: 0 additions & 1 deletion javascript/src/number.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/**
* @fileoverview A wrapper for numbers.
* @author [email protected] (Noel Gorelick)
*/

goog.provide('ee.Number');
Expand Down
2 changes: 0 additions & 2 deletions javascript/src/serializer.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
/**
* @fileoverview A serializer that encodes EE object trees as JSON DAGs.
*
* @author [email protected] (Noel Gorelick)
*/

goog.provide('ee.Serializer');
Expand Down
1 change: 0 additions & 1 deletion javascript/src/string.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/**
* @fileoverview A wrapper for strings.
* @author [email protected] (Noel Gorelick)
*/

goog.provide('ee.String');
Expand Down
1 change: 0 additions & 1 deletion javascript/src/terrain.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/**
* @fileoverview A class to generate the ee.Terrain namespace.
*
* @author [email protected] (Noel Gorelick)
* @suppress {useOfGoogProvide}
*/

Expand Down
1 change: 0 additions & 1 deletion javascript/src/types.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/**
* @fileoverview A set of utilities to work with EE types.
* @author [email protected] (Max Shawabkeh)
*/

goog.provide('ee.Types');
Expand Down
31 changes: 19 additions & 12 deletions 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.369'
__version__ = '0.1.370'

# Using lowercase function naming to match the JavaScript names.
# pylint: disable=g-bad-name
Expand Down Expand Up @@ -128,6 +128,7 @@ def Initialize(
"""
if credentials == 'persistent':
credentials = data.get_persistent_credentials()

data.initialize(
credentials=credentials,
api_base_url=(opt_url + '/api' if opt_url else None),
Expand All @@ -136,44 +137,50 @@ def Initialize(
cloud_api_key=cloud_api_key,
project=project,
http_transport=http_transport)

# Initialize the dynamically loaded functions on the objects that want them.
ApiFunction.initialize()
Collection.initialize()
Date.initialize()
Dictionary.initialize()
Element.initialize()
Image.initialize()
Feature.initialize()
Collection.initialize()
ImageCollection.initialize()
FeatureCollection.initialize()
Filter.initialize()
Geometry.initialize()
Image.initialize()
ImageCollection.initialize()
List.initialize()
Number.initialize()
String.initialize()
Date.initialize()
Dictionary.initialize()
Terrain.initialize()

# These must happen last.
_InitializeGeneratedClasses()
_InitializeUnboundMethods()


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

# Must call reset on the base class before any of its derived classes.
ApiFunction.reset()
Element.reset()
Image.reset()
Element.reset() # Must be before Collection.
Collection.reset() # Must be before FeatureCollection and ImageCollection.
Date.reset()
Dictionary.reset()
Feature.reset()
Collection.reset()
ImageCollection.reset()
FeatureCollection.reset()
Filter.reset()
Geometry.reset()
Image.reset()
ImageCollection.reset()
List.reset()
Number.reset()
String.reset()
Date.reset()
Dictionary.reset()
Terrain.reset()

_ResetGeneratedClasses()
global Algorithms
Algorithms = _AlgorithmsContainer()
Expand Down
21 changes: 12 additions & 9 deletions python/ee/apifunction.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@
# Using lowercase function naming to match the JavaScript names.
# pylint: disable=g-bad-name

from __future__ import annotations

import copy
import keyword
import re
from typing import Any, Dict, Optional, Type
from typing import Any, Dict, Optional, Set, Type

from ee import computedobject
from ee import data
Expand All @@ -32,11 +34,11 @@ class ApiFunction(function.Function):
_signature: Dict[str, Any]

# A dictionary of functions defined by the API server.
_api = {}
_api: Dict[str, ApiFunction] = {}

# A set of algorithm names containing all algorithms that have been bound to
# a function so far using importApi().
_bound_signatures = set()
_bound_signatures: Set[str] = set()

def __init__(self, name: str, opt_signature: Optional[Dict[str, Any]] = None):
"""Creates a function defined by the EE API.
Expand All @@ -53,7 +55,7 @@ def __init__(self, name: str, opt_signature: Optional[Dict[str, Any]] = None):
self._signature = copy.deepcopy(opt_signature)
self._signature['name'] = name

def __eq__(self, other):
def __eq__(self, other: Any) -> bool:
return (isinstance(other, ApiFunction) and
self.getSignature() == other.getSignature())

Expand Down Expand Up @@ -94,11 +96,11 @@ def apply_(cls, name: str, named_args: Dict[str, Any]) -> Any:
"""
return cls.lookup(name).apply(named_args)

def encode_invocation(self, encoder):
def encode_invocation(self, encoder: Any) -> Any:
del encoder # Unused.
return self._signature['name']

def encode_cloud_invocation(self, encoder):
def encode_cloud_invocation(self, encoder: Any) -> Dict[str, Any]:
del encoder # Unused.
return {'functionName': self._signature['name']}

Expand All @@ -120,7 +122,7 @@ def unboundFunctions(cls) -> Dict[str, Any]:
return dict([(name, func) for name, func in cls._api.items()
if name not in cls._bound_signatures])

# TODO(user): Any -> 'ApiFunction' for the return type.
# TODO(user): Any -> ApiFunction for the return type.
@classmethod
def lookup(cls, name: str) -> Any:
"""Looks up an API function by name.
Expand All @@ -139,7 +141,7 @@ def lookup(cls, name: str) -> Any:
return result

@classmethod
def lookupInternal(cls, name: str) -> Optional['ApiFunction']:
def lookupInternal(cls, name: str) -> Optional[ApiFunction]:
"""Looks up an API function by name.
Args:
Expand Down Expand Up @@ -212,7 +214,8 @@ def importApi(
# Create a new function so we can attach properties to it.
def MakeBoundFunction(func):
# We need the lambda to capture "func" from the enclosing scope.
return lambda *args, **kwargs: func.call(*args, **kwargs) # pylint: disable=unnecessary-lambda
# pylint: disable-next=unnecessary-lambda
return lambda *args, **kwargs: func.call(*args, **kwargs)
bound_function = MakeBoundFunction(api_func)

# Add docs.
Expand Down
Loading

0 comments on commit b98c266

Please sign in to comment.