Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prediction: allow more time for model training #1031

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 31 additions & 28 deletions system-test/prediction.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,44 +193,47 @@ describe('Prediction', function() {
before(function(done) {
model.create({
data: file
}, done);
}, function(err) {
if (err) {
done(err);
return;
}

function isModelTrained(callback) {
model.getMetadata(function(err, metadata) {
if (err) {
callback(err);
return;
}

if (metadata.trainingStatus === 'RUNNING') {
callback(new Error('Model still training.'));
return;
}

callback();
});
}

async.retry({ times: 5, interval: 10000 }, isModelTrained, done);
});
});

after(function(done) {
model.delete(done);
});

it('should return results', function(done) {
// The model needs to process the new data before it can be queried.
async.retry(
{
times: 5,
interval: 7500
},

function(callback) {
model.query('hello', callback);
},

function(err, results) {
assert.ifError(err);
assert.strictEqual(results.winner, 'English');
assert.strictEqual(results.scores[0].score, 1);
done();
});
model.query('hello', function(err, results) {
assert.ifError(err);
assert.strictEqual(results.winner, 'English');
assert.strictEqual(results.scores[0].score, 1);
done();
});
});

it('should return analysis', function(done) {
var model = prediction.model(generateName());

model.create(function(err, model) {
assert.ifError(err);

model.analyze(function(err) {
assert.ifError(err);
model.delete(done);
});
});
model.analyze(done);
});
});
});
Expand Down