Skip to content

Commit 1ceb9e7

Browse files
nnegreyAhrar Monsur
authored and
Ahrar Monsur
committed
docs: update batch test (#345)
* docs: update batch test * actually use fake model id
1 parent 96ab62e commit 1ceb9e7

File tree

1 file changed

+8
-44
lines changed

1 file changed

+8
-44
lines changed

automl/test/batch_predict.test.js

+8-44
Original file line numberDiff line numberDiff line change
@@ -25,59 +25,23 @@ const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'});
2525

2626
const BATCH_PREDICT_REGION_TAG = 'batch_predict';
2727
const LOCATION = 'us-central1';
28-
const MODEL_ID = 'TEN2238627664384491520';
28+
const MODEL_ID = 'TEN0000000000000000000';
2929
const PREFIX = 'TEST_BATCH_PREDICT';
3030

3131
describe('Automl Batch Predict Test', () => {
3232
const client = new AutoMlClient();
3333

34-
before('should verify the model is deployed', async () => {
35-
const projectId = await client.getProjectId();
36-
const request = {
37-
name: client.modelPath(projectId, LOCATION, MODEL_ID),
38-
};
39-
40-
const [response] = await client.getModel(request);
41-
if (response.deploymentState === 'UNDEPLOYED') {
42-
const request = {
43-
name: client.modelPath(projectId, LOCATION, MODEL_ID),
44-
};
45-
46-
const [operation] = await client.deployModel(request);
47-
48-
// Wait for operation to complete.
49-
await operation.promise();
50-
}
51-
});
52-
5334
it('should batch predict', async () => {
35+
// As batch prediction can take a long time, instead try to batch predict
36+
// on a nonexistent model and confirm that the model was not found, but
37+
// other elements of the request were valid.
5438
const projectId = await client.getProjectId();
5539
const inputUri = `gs://${projectId}-lcm/entity_extraction/input.jsonl`;
56-
const outputUri = `gs://${projectId}-lcm/${PREFIX}/`;
40+
const outputUri = `gs://${projectId}-lcm/TEST_BATCH_PREDICT/`;
5741

58-
const batchPredictOutput = execSync(
59-
`node ${BATCH_PREDICT_REGION_TAG}.js ${projectId} ${LOCATION} ${MODEL_ID} ${inputUri} ${outputUri}`
60-
);
61-
assert.match(
62-
batchPredictOutput,
63-
/Batch Prediction results saved to Cloud Storage bucket/
64-
);
65-
});
42+
const args = [BATCH_PREDICT_REGION_TAG, projectId, LOCATION, MODEL_ID, inputUri, outputUri];
43+
const output = cp.spawnSync('node', args, {encoding: 'utf8'});
6644

67-
after('delete created files', async () => {
68-
const projectId = await client.getProjectId();
69-
const storageClient = new Storage();
70-
const options = {
71-
prefix: PREFIX,
72-
};
73-
const [files] = await storageClient
74-
.bucket(`gs://${projectId}-lcm`)
75-
.getFiles(options);
76-
files.forEach(file => {
77-
storageClient
78-
.bucket(`gs://${projectId}-lcm`)
79-
.file(file.name)
80-
.delete();
81-
});
45+
assert.match(output.stderr, /does not exist/);
8246
});
8347
});

0 commit comments

Comments
 (0)