Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
cdanielw committed Dec 20, 2023
2 parents abdcc2f + 7d936dd commit 2ed8de3
Show file tree
Hide file tree
Showing 72 changed files with 17,088 additions and 15,753 deletions.
10 changes: 0 additions & 10 deletions .github/ISSUE_TEMPLATE/bug_report.md

This file was deleted.

10 changes: 0 additions & 10 deletions .github/ISSUE_TEMPLATE/feature_request.md

This file was deleted.

34 changes: 34 additions & 0 deletions .github/workflows/ci-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# TODO(user): Fix or skip tests that fail on GitHub
name: ci-tests
on: [
push,
pull_request,
]

jobs:
build:
name: "python ${{ matrix.python-version }} tests"
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [
"3.7",
"3.8",
"3.9",
"3.10",
"3.11",
"3.12",
]
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Install EE and dependencies
run: |
pip install ./python[tests]
- name: Test
run: |
python -m unittest discover --pattern="*test.py" --start-directory python/ee/tests
32 changes: 32 additions & 0 deletions .github/workflows/ci-type-verification.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: ci-type-verification
on:
# Triggers the workflow when new code is pushed to the master branch.
push:
branches: [ master ]
# Enables running this workflow manually from the Actions tab.
workflow_dispatch:
jobs:
build:
name: "Type verification"
runs-on: ubuntu-latest
steps:
- name: Cancel previous
uses: styfle/cancel-workflow-action@0.7.0
with:
access_token: ${{ github.token }}
if: ${{github.ref != 'refs/head/master'}}
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.11
- name: Install EE API
run: |
pip install -e ./python
pip install pyright
- name: ee type verification
run: |
pyright --verifytypes ee
- name: ee.cli type verification
run: |
pyright --verifytypes ee.cli
1,353 changes: 679 additions & 674 deletions javascript/build/ee_api_js.js

Large diffs are not rendered by default.

14,581 changes: 7,376 additions & 7,205 deletions javascript/build/ee_api_js_debug.js

Large diffs are not rendered by default.

14,626 changes: 7,399 additions & 7,227 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.374",
"version": "0.1.384",
"description": "JavaScript client for Google Earth Engine API.",
"author": "Google LLC",
"license": "Apache-2.0",
Expand Down
9 changes: 5 additions & 4 deletions javascript/src/apiclient.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ goog.module.declareLegacyNamespace();

const GoogConst = goog.require('goog.string.Const');
const Throttle = goog.require('goog.async.Throttle');
const TrustedResourceUrl = goog.require('goog.html.TrustedResourceUrl');
const Uri = goog.require('goog.Uri');
const XhrIo = goog.require('goog.net.XhrIo');
const XhrLike = goog.requireType('goog.net.XhrLike');
Expand All @@ -21,11 +20,12 @@ const jsloader = goog.require('goog.net.jsloader');
const {MakeRequestParams, processParams} = goog.require('eeapiclient.request_params');
const {NULL_VALUE, Serializable, SerializableCtor, deserialize, serialize} = goog.require('eeapiclient.domain_object');
const {PromiseRequestService} = goog.require('eeapiclient.promise_request_service');
const {trustedResourceUrl} = goog.require('safevalues');

/** @namespace */
const apiclient = {};

const API_CLIENT_VERSION = '0.1.374';
const API_CLIENT_VERSION = '0.1.384';

exports.VERSION = apiVersion.VERSION;
exports.API_CLIENT_VERSION = API_CLIENT_VERSION;
Expand Down Expand Up @@ -1147,8 +1147,9 @@ apiclient.ensureAuthLibLoaded_ = function(callback) {
delete goog.global[callbackName];
done();
};
jsloader.safeLoad(TrustedResourceUrl.format(
apiclient.AUTH_LIBRARY_URL_, {'onload': callbackName}));
jsloader.safeLoad(
trustedResourceUrl`https://apis.google.com/js/client.js?onload=${
callbackName}`);
}
};

Expand Down
19 changes: 19 additions & 0 deletions javascript/src/batch.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ Export.table = {};
/** @const */
Export.video = {};

/** @const */
Export.classifier = {};

/**
* ExportTask
*/
Expand Down Expand Up @@ -393,6 +396,22 @@ Export.video.toDrive = function(
return ExportTask.create(serverConfig);
};

/**
* @param {!ComputedObject} classifier
* @param {string=} opt_description
* @param {string=} opt_assetId
* @return {!ExportTask}
* @export
*/
Export.classifier.toAsset = function(classifier, opt_description, opt_assetId) {
const clientConfig =
eeArguments.extractFromFunction(Export.classifier.toAsset, arguments);
const serverConfig = Export.convertToServerParams(
clientConfig, ExportDestination.ASSET, ExportType.CLASSIFIER);
return ExportTask.create(serverConfig);
};


////////////////////////////////////////////////////////////////////////////////
// Internal validation. //
////////////////////////////////////////////////////////////////////////////////
Expand Down
76 changes: 65 additions & 11 deletions javascript/src/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ goog.provide('ee.data.AuthPrivateKey');
goog.provide('ee.data.Band');
goog.provide('ee.data.BandDescription');
goog.provide('ee.data.BigQueryTaskConfig');
goog.provide('ee.data.ClassifierTaskConfig');
goog.provide('ee.data.DownloadId');
goog.provide('ee.data.ExportDestination');
goog.provide('ee.data.ExportState');
Expand Down Expand Up @@ -1296,6 +1297,11 @@ ee.data.startProcessing = function(taskId, params, opt_callback) {
case ee.data.ExportType.MAP:
const mapRequest = ee.data.prepareExportMapRequest_(params, metadata);
return handle(call.map().export(call.projectsPath(), mapRequest));
case ee.data.ExportType.CLASSIFIER:
const classifierRequest =
ee.data.prepareExportClassifierRequest_(params, metadata);
return handle(
call.classifier().export(call.projectsPath(), classifierRequest));
default:
throw new Error(
`Unable to start processing for task of type ${taskType}`);
Expand Down Expand Up @@ -1379,6 +1385,27 @@ ee.data.prepareExportMapRequest_ = function(taskConfig, metadata) {
return mapRequest;
};


/**
* Creates an ExportClassifierRequest for a given ClassifierTaskConfig.
*
* @param {!Object} taskConfig classifier task configuration params.
* @param {!Object} metadata associated with the export request.
* @return {!ee.api.ExportClassifierRequest}
* @private
*/
ee.data.prepareExportClassifierRequest_ = function(taskConfig, metadata) {
const classifierRequest =
ee.rpc_convert_batch.taskToExportClassifierRequest(taskConfig);
classifierRequest.expression =
ee.data.expressionAugmenter_(classifierRequest.expression, metadata);
if (taskConfig['workloadTag']) {
classifierRequest.workloadTag = taskConfig['workloadTag'];
}
return classifierRequest;
};


/**
* Creates an image asset ingestion task.
*
Expand Down Expand Up @@ -1646,10 +1673,12 @@ ee.data.listImages = function(


/**
* Returns a list of asset roots belonging to the user or Cloud Project. Leave
* the project field blank to use the current project.
* Returns top-level assets and folders for the Cloud Project or user. Leave the
* project field blank to use the current project.
*
* @param {string=} project Project to query. Defaults to current project.
* @param {string=} project Project to query, e.g. "projects/my-project".
* Defaults to current project. Use "projects/earthengine-legacy" for user
* home folders.
* @param {function(?ee.api.ListAssetsResponse, string=)=}
* opt_callback If not supplied, the call is made synchronously.
* @return {?ee.api.ListAssetsResponse}
Expand All @@ -1664,13 +1693,17 @@ ee.data.listBuckets = function(project, opt_callback) {


/**
* Returns the list of the root folders the user owns. The "id" values for roots
* are two levels deep, e.g. "users/johndoe" not "users/johndoe/notaroot".
* Returns a list of top-level assets and folders for the current project.
*
* The "id" values for Cloud Projects are "projects/my-project/assets/my-asset",
* where legacy assets (if the current project is set to "earthengine-legacy")
* are "users/my-username", not "users/my-username/my-asset".
*
* @deprecated Use ee.data.listBuckets() with no "project" parameter.
* @param {function(?Array<!ee.data.FolderDescription>, string=)=} opt_callback
* An optional callback. If not supplied, the call is made synchronously.
* @return {?Array<!ee.data.FolderDescription>} The list of writable folders.
* Null if a callback is specified.
* @return {?Array<!ee.data.FolderDescription>} The list of top-level assets and
* folders. Null if a callback is specified.
* @export
*/
ee.data.getAssetRoots = function(opt_callback) {
Expand All @@ -1683,13 +1716,14 @@ ee.data.getAssetRoots = function(opt_callback) {

/**
* Attempts to create a home root folder (e.g. "users/joe") for the current
* user. This results in an error if the user already has a home root folder or
* the requested ID is unavailable.
* user. This results in an error if the user already has a home root folder
* or the requested ID is unavailable.
*
* @param {string} requestedId The requested ID of the home folder
* (e.g. "users/joe").
* @param {function(?Array<!ee.data.FolderDescription>, string=)=} opt_callback
* An optional callback. If not supplied, the call is made synchronously.
* @param {function(?Array<!ee.data.FolderDescription>, string=)=}
* opt_callback An optional callback. If not supplied, the call is made
* synchronously.
* @export
*/
ee.data.createAssetHome = function(requestedId, opt_callback) {
Expand Down Expand Up @@ -2188,6 +2222,7 @@ ee.data.resetWorkloadTag = function(opt_resetDefault) {
*/
ee.data.AssetType = {
ALGORITHM: 'Algorithm',
CLASSIFIER: 'Classifier',
FEATURE_VIEW: 'FeatureView',
FOLDER: 'Folder',
FEATURE_COLLECTION: 'FeatureCollection',
Expand All @@ -2204,6 +2239,7 @@ ee.data.ExportType = {
MAP: 'EXPORT_TILES',
TABLE: 'EXPORT_FEATURES',
VIDEO: 'EXPORT_VIDEO',
CLASSIFIER: 'EXPORT_CLASSIFIER'
};

/** @enum {string} The status of the export. */
Expand Down Expand Up @@ -3412,6 +3448,24 @@ ee.data.ImageExportFormatConfig;
*/
ee.data.MapTaskConfig;

/**
* An object for specifying configuration of a task to export a classifier
* as an asset.
*
* @typedef {{
* id: string,
* type: string,
* sourceUrl: (undefined|string),
* description: (undefined|string),
* element: (undefined|!ee.ComputedObject),
* assetId: (undefined|string),
* maxWorkers: (undefined|number),
* workloadTag: (undefined|string),
* }}
*/
ee.data.ClassifierTaskConfig;


/**
* An object for specifying configuration of a task to export feature
* collections to a FeatureView.
Expand Down
3 changes: 1 addition & 2 deletions javascript/src/ee.js
Original file line number Diff line number Diff line change
Expand Up @@ -378,8 +378,7 @@ ee.promote_ = function(arg, klass) {
return new ee.Image(/** @type {Object} */ (arg));
case 'Feature':
if (arg instanceof ee.Collection) {
// TODO(user): Decide whether we want to leave this in. It can be
// quite dangerous on large collections.
// This can be quite dangerous on large collections.
return ee.ApiFunction._call(
'Feature', ee.ApiFunction._call('Collection.geometry', arg));
} else {
Expand Down
1 change: 1 addition & 0 deletions javascript/src/eeapiclient/api_client.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// g3-format-clang
import {Serializable, serialize} from './domain_object';
import {GeneratedRequestParams} from './generated_types';
import {MultipartRequest} from './multipart_request';
Expand Down
1 change: 1 addition & 0 deletions javascript/src/eeapiclient/api_request_hook.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// g3-format-clang
import {GeneratedRequestParams} from './generated_types';

export interface ApiClientRequestHook {
Expand Down
1 change: 1 addition & 0 deletions javascript/src/eeapiclient/domain_object.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/**
* g3-format-clang
* Utility map for ClassMetadata to describe how to create instances of child
* properties.
*/
Expand Down
1 change: 1 addition & 0 deletions javascript/src/eeapiclient/generated_types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// g3-format-clang
import {Serializable, SerializableCtor} from './domain_object';
import {MultipartRequest} from './multipart_request';

Expand Down
1 change: 1 addition & 0 deletions javascript/src/eeapiclient/multipart_request.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// g3-format-clang
import {Serializable, serialize} from './domain_object';

export class MultipartRequest {
Expand Down
1 change: 1 addition & 0 deletions javascript/src/eeapiclient/promise_api_client.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// g3-format-clang
import {ApiClient, toMakeRequestParams, toMultipartMakeRequestParams} from './api_client';
import {ApiClientHookFactory, getRequestHook} from './api_request_hook';
import {Serializable} from './domain_object';
Expand Down
1 change: 1 addition & 0 deletions javascript/src/eeapiclient/promise_request_service.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// g3-format-clang
import {deserialize, Serializable, SerializableCtor} from './domain_object';
import {MakeRequestParams, processParams} from './request_params';

Expand Down
1 change: 1 addition & 0 deletions javascript/src/eeapiclient/request_params.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// g3-format-clang
import * as httpCors from 'goog:goog.net.rpc.HttpCors';

import {GeneratedQueryParams} from './generated_types';
Expand Down
1 change: 1 addition & 0 deletions javascript/src/eeapiclient/request_params_test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// g3-format-clang
import 'jasmine';

import {buildQueryParams, bypassCorsPreflight, MakeRequestParams} from './request_params';
Expand Down
Loading

0 comments on commit 2ed8de3

Please sign in to comment.