forked from drugis/gemtc-web
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
518 additions
and
192 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,38 @@ | ||
'use strict'; | ||
var modelRepository = require('./modelRepository'); | ||
|
||
module.exports = { | ||
update: update | ||
}; | ||
var _ = require('lodash'); | ||
|
||
function update(oldModel, newModel, callback) { | ||
if (newModel.burnInIterations < oldModel.burnInIterations || | ||
newModel.inferenceIterations < oldModel.inferenceIterations) { | ||
callback({ | ||
statusCode: 500, | ||
message: 'may not update model with lower number of iterations' | ||
}); | ||
var errorMessage = 'Error: may not update model with lower number of iterations'; | ||
callback(errorMessage); | ||
} else { | ||
modelRepository.update(newModel, callback); | ||
} | ||
} | ||
|
||
function partitionModels(models) { | ||
var partition = _.partition(models, function(model) { | ||
return model.taskUrl !== null && model.taskUrl !== undefined; | ||
}); | ||
return { | ||
modelsWithTask: partition[0], | ||
modelsWithoutTask: partition[1] | ||
}; | ||
} | ||
|
||
function decorateWithRunStatus(models, pataviResult) { | ||
var tasks = _.keyBy(pataviResult, 'id'); | ||
return _.map(models, function(model) { | ||
return _.extend(model, { | ||
runStatus: tasks[model.taskUrl].runStatus | ||
}); | ||
}); | ||
} | ||
|
||
module.exports = { | ||
update: update, | ||
partitionModels: partitionModels, | ||
decorateWithRunStatus: decorateWithRunStatus | ||
}; |
Oops, something went wrong.