Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
integration test that turns on the ai toggle and checks that something is recommended
- Loading branch information
Showing
6 changed files
with
121 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
/** | ||
* Run and experiment | ||
* | ||
*/ | ||
|
||
import * as labApi from './labApi'; | ||
import * as machineApi from './machineApi'; | ||
import * as dbBuilder from "./util/db"; | ||
import * as util from "./util/testUtils"; | ||
|
||
/* | ||
const db = dbBuilder.openDbConnection(); | ||
afterAll(() => { | ||
db.close(); | ||
}); | ||
*/ | ||
|
||
describe('ai', () => { | ||
it('start ai for banana', async () => { | ||
console.log('start ai') | ||
|
||
jest.setTimeout(util.JEST_TIMEOUT) | ||
|
||
let algoName = 'LogisticRegression' | ||
let datasetName = 'banana' | ||
|
||
let newSuccessExpParms = {'date_start':Date.now(), '_status':'success'} | ||
|
||
//------------------- | ||
// get dataset | ||
var datasets = await labApi.fetchDatasets(); | ||
expect(datasets.length).toBeGreaterThan(1); | ||
var datasetId = datasets.find(function(element) {return element.name == datasetName;})._id; | ||
expect(datasetId).toBeTruthy(); | ||
|
||
// get algorithm | ||
var algorithms = await labApi.fetchAlgorithms(); | ||
expect(algorithms.length).toBeGreaterThanOrEqual(util.MIN_EXPECTED_LAB_ALGO_COUNT); | ||
var algoId = algorithms.find(function(element) {return element.name == algoName;})._id; | ||
expect(algoId).toBeTruthy(); | ||
|
||
// make sure machine is free | ||
var capRes = await machineApi.fetchCapacity(algoId) | ||
expect(capRes.capacity).toEqual(1) | ||
console.log("checked machine") | ||
|
||
// fetch previously run experiments | ||
var prevExperiments = await labApi.fetchExperiments() | ||
|
||
// turn on ai | ||
await labApi.updateAiStatus(datasetId, "requested") | ||
|
||
// wait for ai status to change | ||
var dataset = await labApi.fetchDataset(datasetId) | ||
console.log("dataset[0].ai: ", dataset[0].ai) | ||
|
||
var count = 0 | ||
console.log("starting timeout...") | ||
while (dataset[0].ai === ('requested') && count < 10) { | ||
util.delay(10000) | ||
count = count + 1 | ||
dataset = await labApi.fetchDataset(datasetId) | ||
console.log("dataset[0].ai, count (" + count + "): ", dataset[0].ai) | ||
} | ||
console.log("finished timeout...") | ||
console.log("dataset[0].ai: ", dataset[0].ai) | ||
|
||
// check ai status | ||
expect(dataset[0].ai).toBeTruthy() | ||
expect(dataset[0].ai).toEqual('finished') | ||
|
||
// check for new experiments | ||
var allExperiments = await labApi.fetchExperiments() | ||
expect(allExperiments.length).toEqual(prevExperiments.length + util.NUM_AI_RECS) | ||
console.log("checked new experiment count") | ||
|
||
// wait for experiments to complete | ||
console.log("waiting for experiments to finish") | ||
var experiments = await labApi.fetchExperimentsParms(newSuccessExpParms) | ||
console.log("new success experiments:", experiments) | ||
|
||
var count = 0 | ||
console.log("starting timeout...") | ||
while (!experiments && count < 10) { | ||
util.delay(10000) | ||
count = count + 1 | ||
experiments = await labApi.fetchExperimentsParms(newSuccessExpParms) | ||
console.log("new success experiments, count (" + count + "): ", experiments) | ||
} | ||
console.log("finished timeout...") | ||
|
||
expect(experiments).toBeTruthy() | ||
|
||
/* | ||
// make sure machine is free | ||
var capRes = await machineApi.fetchCapacity(algoId) | ||
expect(capRes.capacity).toEqual(1) | ||
console.log("checked machine") | ||
*/ | ||
}); | ||
}); |
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