gee-community / ee-runner

Command-line runner for Google Earth Engine Playground scripts
Apache License 2.0
67 stars 18 forks source link

Cannot find module error in ee-runner #8

Closed suredream closed 7 years ago

suredream commented 7 years ago

Today I clone ee-runner to run some batch task. Got this error:

Juns-MacBook-Air:ee-runner jxiong1$ node ee-runner.js examples/hello.js module.js:471 throw err; ^ Error: Cannot find module './ext/earthengine-api/javascript/src/arguments' at Function.Module._resolveFilename (module.js:469:15) at Function.Module._load (module.js:417:25) at Module.require (module.js:497:17) at require (internal/module.js:20:19) at Object. (/Users/jxiong1/repo/ee-runner/index.js:28:1) at Module._compile (module.js:570:32) at Object.Module._extensions..js (module.js:579:10) at Module.load (module.js:487:32) at tryModuleLoad (module.js:446:12) at Function.Module._load (module.js:438:3) Juns-MacBook-Air:ee-runner jxiong1$

Any idea?

gena commented 7 years ago

Should be fixed, EE API upgrade issue.

suredream commented 7 years ago

Great. Now I have a 1.js (attached) which works very well in playground, to print some ee object.

Now how should I do to run it with ee-runner, get the same outputs in terminal?

I prefer to do it in terminal to find a way to batch the tasks.

1.js.zip

gena commented 7 years ago

You can use pretty much anything from Node.js / JavaScript. But also check examples/

Not everything is 100% the same as in the Playground. It is also a good idea to separate command-line code from the Playground if you want to use it on both sides without changes. The flag was just added. This way the code will not run in the Playground

if(commandLine) {
   ... put you command-line specific code here
}

To get some output, you can try adding getInfo()

print(assessment.accuracy().getInfo())

To make sense of your script, you can try to export error matrix and image, for example as:

save(assessment.getInfo(), './error_matrix.json')

// or

var fs = require('fs')
fs.writeFileSync('./error_matrix.json', assessment.getInfo()); 

I can probably make this work by default in the future if the tool will be used.

Getting preview is possible using

var url = ret.getThumbURL({dimensions:'1024', region: region.getInfo(), format: 'png'});
download(url, 'results.jpg');

And it may timeout, like in the Playground, so you can also use tasks