Set post processing options on restart

pull/162/head
Piero Toffanin 2021-06-22 11:30:43 -04:00
rodzic bb8b7bda5c
commit d25f72a5f5
1 zmienionych plików z 55 dodań i 44 usunięć

Wyświetl plik

@ -63,46 +63,7 @@ module.exports = class Task{
}
initialize(done, additionalSteps = []){
async.series(additionalSteps.concat([
// Handle post-processing options logic
cb => {
// If we need to post process results
// if pc-ept is supported (build entwine point cloud)
// we automatically add the pc-ept option to the task options by default
if (this.skipPostProcessing) cb();
else{
odmInfo.supportsOption("pc-ept", (err, supported) => {
if (err){
console.warn(`Cannot check for supported option pc-ept: ${err}`);
}else if (supported){
if (!this.options.find(opt => opt.name === "pc-ept")){
this.options.push({ name: 'pc-ept', value: true });
}
}
cb();
});
}
},
cb => {
// If we need to post process results
// if cog is supported (build cloud optimized geotiffs)
// we automatically add the cog option to the task options by default
if (this.skipPostProcessing) cb();
else{
odmInfo.supportsOption("cog", (err, supported) => {
if (err){
console.warn(`Cannot check for supported option cog: ${err}`);
}else if (supported){
if (!this.options.find(opt => opt.name === "cog")){
this.options.push({ name: 'cog', value: true });
}
}
cb();
});
}
},
async.series(additionalSteps.concat(this.setPostProcessingOptsSteps(), [
// Read images info
cb => {
fs.readdir(this.getImagesFolderPath(), (err, files) => {
@ -150,6 +111,48 @@ module.exports = class Task{
});
}
setPostProcessingOptsSteps(){
return [
cb => {
// If we need to post process results
// if pc-ept is supported (build entwine point cloud)
// we automatically add the pc-ept option to the task options by default
if (this.skipPostProcessing) cb();
else{
odmInfo.supportsOption("pc-ept", (err, supported) => {
if (err){
console.warn(`Cannot check for supported option pc-ept: ${err}`);
}else if (supported){
if (!this.options.find(opt => opt.name === "pc-ept")){
this.options.push({ name: 'pc-ept', value: true });
}
}
cb();
});
}
},
cb => {
// If we need to post process results
// if cog is supported (build cloud optimized geotiffs)
// we automatically add the cog option to the task options by default
if (this.skipPostProcessing) cb();
else{
odmInfo.supportsOption("cog", (err, supported) => {
if (err){
console.warn(`Cannot check for supported option cog: ${err}`);
}else if (supported){
if (!this.options.find(opt => opt.name === "cog")){
this.options.push({ name: 'cog', value: true });
}
}
cb();
});
}
}
];
}
static CreateFromSerialized(taskJson, done){
const task = new Task(taskJson.uuid,
taskJson.name,
@ -617,8 +620,12 @@ module.exports = class Task{
restart(options, cb){
if (!this.initialized && this.status.code === statusCodes.CANCELED){
this.setStatus(statusCodes.RUNNING);
if (options !== undefined) this.options = options;
cb(null);
if (options !== undefined){
this.options = options;
async.series(this.setPostProcessingOptsSteps(), cb);
}else{
cb();
}
}else if ([statusCodes.CANCELED, statusCodes.FAILED, statusCodes.COMPLETED].indexOf(this.status.code) !== -1){
this.setStatus(statusCodes.QUEUED);
this.dateCreated = new Date().getTime();
@ -626,8 +633,12 @@ module.exports = class Task{
this.output = [];
this.progress = 0;
this.stopTrackingProcessingTime(true);
if (options !== undefined) this.options = options;
cb(null);
if (options !== undefined){
this.options = options;
async.series(this.setPostProcessingOptsSteps(), cb);
}else{
cb();
}
}else{
cb(new Error("Task cannot be restarted"));
}