Skip to content

Commit

Permalink
v0.1.366
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 559778483
  • Loading branch information
Google Earth Engine Authors authored and naschmitz committed Aug 24, 2023
1 parent aed64b3 commit 52c48b9
Show file tree
Hide file tree
Showing 36 changed files with 785 additions and 1,444 deletions.
32 changes: 16 additions & 16 deletions javascript/build/ee_api_js.js

Large diffs are not rendered by default.

120 changes: 83 additions & 37 deletions javascript/build/ee_api_js_debug.js

Large diffs are not rendered by default.

164 changes: 105 additions & 59 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.365",
"version": "0.1.366",
"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.365';
const API_CLIENT_VERSION = '0.1.366';

exports.VERSION = apiVersion.VERSION;
exports.API_CLIENT_VERSION = API_CLIENT_VERSION;
Expand Down
4 changes: 1 addition & 3 deletions javascript/src/computedobject.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@

goog.provide('ee.ComputedObject');

goog.requireType('ee.Function');
goog.require('ee.Encodable');
goog.require('ee.Serializer');
goog.require('ee.api');
goog.require('ee.data');
goog.require('ee.rpc_node');


goog.requireType('ee.Function');

/**
* An object to represent a computed Earth Engine object, a base for most
Expand Down
3 changes: 0 additions & 3 deletions javascript/src/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,6 @@ ee.data.getAlgorithms = function(opt_callback) {
.then(ee.rpc_convert.algorithms));
};


/**
* Get a Map ID for a given asset
* @param {!ee.data.ImageVisualizationParameters} params
Expand Down Expand Up @@ -1417,7 +1416,6 @@ ee.data.startTableIngestion = function(taskId, request, opt_callback) {
return convert(ee.data.ingestTable(taskId, manifest, wrappedCallback));
};


////////////////////////////////////////////////////////////////////////////////
// Asset management. //
////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -2374,7 +2372,6 @@ ee.data.AssetQuotaDetails = class {
}
};


/**
* A description of a FeatureView. The type value is always
* ee.data.AssetType.FEATURE_VIEW.
Expand Down
51 changes: 26 additions & 25 deletions python/ee/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
"""The EE Python library."""

__version__ = '0.1.365'
__version__ = '0.1.366'

# Using lowercase function naming to match the JavaScript names.
# pylint: disable=g-bad-name
Expand All @@ -11,6 +11,7 @@
import inspect
import numbers
import os
from typing import Any, Hashable, Optional, Type

from ee import batch
from ee import data
Expand Down Expand Up @@ -55,7 +56,7 @@
class _AlgorithmsContainer(dict):
"""A lightweight class that is used as a dictionary with dot notation."""

def __getattr__(self, name):
def __getattr__(self, name: Hashable) -> Any:
try:
return self[name]
except KeyError:
Expand Down Expand Up @@ -191,15 +192,15 @@ def _ResetGeneratedClasses():
types._registerClasses(globals()) # pylint: disable=protected-access


def _Promote(arg, klass):
def _Promote(arg: Optional[Any], a_class: str) -> Optional[Any]:
"""Wrap an argument in an object of the specified class.
This is used to e.g.: promote numbers or strings to Images and arrays
to Collections.
Args:
arg: The object to promote.
klass: The expected type.
a_class: The expected type.
Returns:
The argument promoted if the class is recognized, otherwise the
Expand All @@ -208,17 +209,17 @@ def _Promote(arg, klass):
if arg is None:
return arg

if klass == 'Image':
if a_class == 'Image':
return Image(arg)
elif klass == 'Feature':
elif a_class == 'Feature':
if isinstance(arg, Collection):
# TODO(user): Decide whether we want to leave this in. It can be
# quite dangerous on large collections.
return ApiFunction.call_(
'Feature', ApiFunction.call_('Collection.geometry', arg))
else:
return Feature(arg)
elif klass == 'Element':
elif a_class == 'Element':
if isinstance(arg, Element):
# Already an Element.
return arg
Expand All @@ -231,22 +232,22 @@ def _Promote(arg, klass):
else:
# No way to convert.
raise EEException('Cannot convert {0} to Element.'.format(arg))
elif klass == 'Geometry':
elif a_class == 'Geometry':
if isinstance(arg, Collection):
return ApiFunction.call_('Collection.geometry', arg)
else:
return Geometry(arg)
elif klass in ('FeatureCollection', 'Collection'):
elif a_class in ('FeatureCollection', 'Collection'):
# For now Collection is synonymous with FeatureCollection.
if isinstance(arg, Collection):
return arg
else:
return FeatureCollection(arg)
elif klass == 'ImageCollection':
elif a_class == 'ImageCollection':
return ImageCollection(arg)
elif klass == 'Filter':
elif a_class == 'Filter':
return Filter(arg)
elif klass == 'Algorithm':
elif a_class == 'Algorithm':
if isinstance(arg, str):
# An API function name.
return ApiFunction.lookup(arg)
Expand All @@ -260,25 +261,25 @@ def _Promote(arg, klass):
return arg
else:
raise EEException('Argument is not a function: {0}'.format(arg))
elif klass == 'Dictionary':
elif a_class == 'Dictionary':
if isinstance(arg, dict):
return arg
else:
return Dictionary(arg)
elif klass == 'String':
elif a_class == 'String':
if (types.isString(arg) or
isinstance(arg, ComputedObject) or
isinstance(arg, String)):
return String(arg)
else:
return arg
elif klass == 'List':
elif a_class == 'List':
return List(arg)
elif klass in ('Number', 'Float', 'Long', 'Integer', 'Short', 'Byte'):
elif a_class in ('Number', 'Float', 'Long', 'Integer', 'Short', 'Byte'):
return Number(arg)
elif klass in globals():
cls = globals()[klass]
ctor = ApiFunction.lookupInternal(klass)
elif a_class in globals():
cls = globals()[a_class]
ctor = ApiFunction.lookupInternal(a_class)
# Handle dynamically created classes.
if isinstance(arg, cls):
# Return unchanged.
Expand All @@ -288,18 +289,18 @@ def _Promote(arg, klass):
return cls(arg)
elif isinstance(arg, str):
if hasattr(cls, arg):
# arg is the name of a method in klass.
# arg is the name of a method in a_class.
return getattr(cls, arg)()
else:
raise EEException('Unknown algorithm: {0}.{1}'.format(klass, arg))
raise EEException('Unknown algorithm: {0}.{1}'.format(a_class, arg))
else:
# Client-side cast.
return cls(arg)
else:
return arg


def _InitializeUnboundMethods():
def _InitializeUnboundMethods() -> None:
"""Initializes the unbounded functions."""
# Sort the items by length, so parents get created before children.
items = sorted(
Expand Down Expand Up @@ -334,7 +335,7 @@ def GenerateFunction(f):
setattr(target, name_parts[0], bound)


def _InitializeGeneratedClasses():
def _InitializeGeneratedClasses() -> None:
"""Generate classes for extra types that appear in the web API."""
signatures = ApiFunction.allSignatures()
# Collect the first part of all function names.
Expand Down Expand Up @@ -368,10 +369,10 @@ def init(self, *args):
Returns:
The new class.
"""
klass = globals()[name]
a_class = globals()[name]
onlyOneArg = (len(args) == 1)
# Are we trying to cast something that's already of the right class?
if onlyOneArg and isinstance(args[0], klass):
if onlyOneArg and isinstance(args[0], a_class):
result = args[0]
else:
# Decide whether to call a server-side constructor or just do a
Expand Down
47 changes: 27 additions & 20 deletions python/ee/_cloud_api_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import json
import os
import re
from typing import Any, Dict, List, Optional, Sequence, Tuple, Union
from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union
import warnings

import google_auth_httplib2
Expand All @@ -36,7 +36,7 @@
r'[a-z][a-z0-9\-]{4,28}[a-z0-9])/assets/?$')

# The default user project to use when making Cloud API calls.
_cloud_api_user_project = None
_cloud_api_user_project: Optional[str] = None


class _Http:
Expand Down Expand Up @@ -67,7 +67,10 @@ def request( # pylint: disable=invalid-name
return httplib2.Response(headers), content


def _wrap_request(headers_supplier, response_inspector):
def _wrap_request(
headers_supplier: Callable[[], Dict[str, Any]],
response_inspector: Callable[[Any], None],
) -> Callable[..., http.HttpRequest]:
"""Builds a callable that wraps an API request.
Args:
Expand All @@ -85,14 +88,16 @@ def _wrap_request(headers_supplier, response_inspector):
return http.HttpRequest

# pylint: disable=invalid-name
def builder(http_transport,
postproc,
uri,
method='GET',
body=None,
headers=None,
methodId=None,
resumable=None):
def builder(
http_transport: Any,
postproc: Any,
uri: Any,
method: str = 'GET',
body: Optional[Any] = None,
headers: Optional[Any] = None,
methodId: Optional[Any] = None,
resumable: Optional[Any] = None,
) -> http.HttpRequest:
"""Builds an HttpRequest, adding headers and response inspection."""
additional_headers = headers_supplier()
if additional_headers:
Expand All @@ -114,19 +119,21 @@ def builder(http_transport,
return builder


def set_cloud_api_user_project(cloud_api_user_project) -> None:
def set_cloud_api_user_project(cloud_api_user_project: str) -> None:
global _cloud_api_user_project
_cloud_api_user_project = cloud_api_user_project


def build_cloud_resource(api_base_url,
api_key=None,
credentials=None,
timeout=None,
headers_supplier=None,
response_inspector=None,
http_transport=None,
raw=False):
def build_cloud_resource(
api_base_url: str,
api_key: Optional[Any] = None,
credentials: Optional[Any] = None,
timeout: Optional[float] = None,
headers_supplier: Optional[Callable[[], Dict[str, Any]]] = None,
response_inspector: Optional[Callable[[Any], None]] = None,
http_transport: Optional[Any] = None,
raw: Optional[bool] = False,
) -> Any:
"""Builds an Earth Engine Cloud API resource.
Args:
Expand Down
6 changes: 4 additions & 2 deletions python/ee/apifunction.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,12 @@ def apply_(cls, name, named_args):
"""
return cls.lookup(name).apply(named_args)

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

def encode_cloud_invocation(self, unused_encoder):
def encode_cloud_invocation(self, encoder):
del encoder # Unused.
return {'functionName': self._signature['name']}

def getSignature(self):
Expand Down

0 comments on commit 52c48b9

Please sign in to comment.