Skip to content

Commit

Permalink
chore: cleanup synth.py (#386)
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaozhenliu-gg5 authored and ahrarmonsur committed Nov 17, 2022
1 parent 6c7f7fc commit e1c1c1e
Show file tree
Hide file tree
Showing 24 changed files with 940 additions and 1,015 deletions.
10 changes: 2 additions & 8 deletions automl/test/automlTablesDataset.v1beta1.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,7 @@ describe('Tables DatasetAPI', () => {
`${cmdDataset} list-table-specs` + ` "${datasetId}" "${filter}"`
);
let parsedOut = output.split('\n');
const outputTableId = parsedOut[1]
.split(':')[1]
.trim()
.split('/')[7];
const outputTableId = parsedOut[1].split(':')[1].trim().split('/')[7];
assert.match(output, /Table Id:/);

// Get table
Expand All @@ -101,10 +98,7 @@ describe('Tables DatasetAPI', () => {
`${cmdDataset} list-column-specs` + ` "${datasetId}" "${outputTableId}"`
);
parsedOut = output.split('\n');
const outputColumnId = parsedOut[1]
.split(':')[1]
.trim()
.split('/')[9];
const outputColumnId = parsedOut[1].split(':')[1].trim().split('/')[9];
assert.match(output, /Column Id:/);

// Get column
Expand Down
10 changes: 2 additions & 8 deletions automl/test/automlTablesModel.v1beta1.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,7 @@ describe('Tables ModelAPI', () => {
`${cmdModel} create-model "${datasetId}" "${tableId}" "${columnId}"` +
` "${testModelName}" "${trainBudget}"`
);
const operationName = output
.split('\n')[0]
.split(':')[1]
.trim();
const operationName = output.split('\n')[0].split(':')[1].trim();
assert.match(output, /Training started.../);

output = exec(`${cmdModel} get-operation-status "${operationName}"`);
Expand Down Expand Up @@ -112,10 +109,7 @@ describe('Tables ModelAPI', () => {
it.skip('should list and get operation status', async () => {
// List operations status
let output = exec(`${cmdModel} list-operations-status `);
const operationFullId = output
.split('\n')[3]
.split(':')[1]
.trim();
const operationFullId = output.split('\n')[3].split(':')[1].trim();
assert.match(output, /Operation details:/);

// Get operation status
Expand Down
15 changes: 3 additions & 12 deletions automl/test/automlTranslation.v1beta1.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,7 @@ describe.skip('automl sample tests', () => {

// Create dataset
output = execSync(`${cmdDataset} create-dataset -n "${testDataSetName}"`);
const dataSetId = output
.split('\n')[1]
.split(':')[1]
.trim();
const dataSetId = output.split('\n')[1].split(':')[1].trim();
assert.match(
output,
new RegExp(`Dataset display name: ${testDataSetName}`)
Expand All @@ -60,10 +57,7 @@ describe.skip('automl sample tests', () => {

// Create dataset
output = execSync(`${cmdDataset} create-dataset -n "${dummyDataSet}"`);
const dataSetId = output
.split('\n')[1]
.split(':')[1]
.trim();
const dataSetId = output.split('\n')[1].split(':')[1].trim();
assert.match(output, new RegExp(`Dataset display name: ${dummyDataSet}`));

// Import Data
Expand All @@ -80,10 +74,7 @@ describe.skip('automl sample tests', () => {
output = execSync(
`${cmdModel} create-model -i "${dataSetId}" -m "${testModelName}" -t "2"`
);
const operationName = output
.split('\n')[0]
.split(':')[1]
.trim();
const operationName = output.split('\n')[0].split(':')[1].trim();
assert.match(output, 'Training started...');

// Poll operation status, here confirming that operation is not complete yet
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,7 @@ describe.skip('Video Intelligence ModelAPI', () => {
let output = exec(
`${cmdModel} create-model "${datasetId}" "${testModelName}"`
);
const operationName = output
.split('\n')[0]
.split(':')[1]
.trim();
const operationName = output.split('\n')[0].split(':')[1].trim();
assert.match(output, /Training started.../);

output = exec(`${cmdModel} get-operation-status "${operationName}"`);
Expand Down Expand Up @@ -86,10 +83,7 @@ describe.skip('Video Intelligence ModelAPI', () => {
it('should list and get operation status', async () => {
// List operation status
let output = exec(`${cmdModel} list-operations-status`);
const operationFullId = output
.split('\n')[3]
.split(':')[1]
.trim();
const operationFullId = output.split('\n')[3].split(':')[1].trim();
assert.match(output, /Operation details:/);

// Get operation status
Expand Down
10 changes: 2 additions & 8 deletions automl/test/automlVision.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,7 @@ describe('auto ml vision', () => {

// Create dataset
output = execSync(`${cmdDataset} create-dataset -n "${testDataSetName}"`);
const dataSetId = output
.split('\n')[1]
.split(':')[1]
.trim();
const dataSetId = output.split('\n')[1].split(':')[1].trim();
assert.match(output, new RegExp(testDataSetName));

// Delete dataset
Expand All @@ -59,10 +56,7 @@ describe('auto ml vision', () => {

// Create dataset
output = execSync(`${cmdDataset} create-dataset -n "${dummyDataSet}"`);
const dataSetId = output
.split('\n')[1]
.split(':')[1]
.trim();
const dataSetId = output.split('\n')[1].split(':')[1].trim();
assert.match(output, new RegExp(dummyDataSet));

// Import Data
Expand Down
5 changes: 1 addition & 4 deletions automl/test/delete-dataset.beta.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,7 @@ describe('Automl Translate Delete Dataset Tests', () => {

before('should create a dataset', async () => {
const projectId = await client.getProjectId();
const displayName = `test_${uuid
.v4()
.replace(/-/g, '_')
.substring(0, 26)}`;
const displayName = `test_${uuid.v4().replace(/-/g, '_').substring(0, 26)}`;
const request = {
parent: client.locationPath(projectId, LOCATION),
dataset: {
Expand Down
5 changes: 1 addition & 4 deletions automl/test/delete_dataset.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,7 @@ describe('Automl Translate Delete Dataset Tests', () => {

before('should create a dataset', async () => {
const projectId = await client.getProjectId();
const displayName = `test_${uuid
.v4()
.replace(/-/g, '_')
.substring(0, 26)}`;
const displayName = `test_${uuid.v4().replace(/-/g, '_').substring(0, 26)}`;
const request = {
parent: client.locationPath(projectId, LOCATION),
dataset: {
Expand Down
7 changes: 2 additions & 5 deletions automl/test/export_dataset.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('Automl Translate Dataset Tests', () => {
const client = new AutoMlClient();
const prefix = 'TEST_EXPORT_OUTPUT';

it('should export a datset', async function() {
it('should export a datset', async function () {
this.retries(4);
await delay(this.test);
const projectId = await client.getProjectId();
Expand All @@ -58,10 +58,7 @@ describe('Automl Translate Dataset Tests', () => {
.getFiles(options);

for (const file of files) {
await storageClient
.bucket(`gs://${bucketName}`)
.file(file.name)
.delete();
await storageClient.bucket(`gs://${bucketName}`).file(file.name).delete();
}
});
});
11 changes: 4 additions & 7 deletions automl/test/import_dataset.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,11 @@ describe('Automl Import Dataset Test', () => {
}
}

it('should create a dataset', async function() {
it('should create a dataset', async function () {
this.retries(5);
await delay(this.test);
const projectId = await client.getProjectId();
const displayName = `test_${uuid
.v4()
.replace(/-/g, '_')
.substring(0, 26)}`;
const displayName = `test_${uuid.v4().replace(/-/g, '_').substring(0, 26)}`;
const request = {
parent: client.locationPath(projectId, LOCATION),
dataset: {
Expand All @@ -94,7 +91,7 @@ describe('Automl Import Dataset Test', () => {
[response.name.split('/').length - 1].split('\n')[0];
});

it('should import dataset', async function() {
it('should import dataset', async function () {
this.retries(5);
await delay(this.test);
const projectId = await client.getProjectId();
Expand All @@ -105,7 +102,7 @@ describe('Automl Import Dataset Test', () => {
assert.match(import_output, /Dataset imported/);
});

it('should delete created dataset', async function() {
it('should delete created dataset', async function () {
this.retries(5);
await delay(this.test);
const projectId = await client.getProjectId();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,7 @@ describe('Automl Natural Language Entity Extraction Create Dataset Test', () =>

it('should create a dataset', async () => {
const projectId = await client.getProjectId();
const displayName = `test_${uuid
.v4()
.replace(/-/g, '_')
.substring(0, 26)}`;
const displayName = `test_${uuid.v4().replace(/-/g, '_').substring(0, 26)}`;

// create
const create_output = execSync(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,7 @@ describe('Automl Natural Language Sentiment Analysis Create Dataset Test', () =>

it('should create a dataset', async () => {
const projectId = await client.getProjectId();
const displayName = `test_${uuid
.v4()
.replace(/-/g, '_')
.substring(0, 26)}`;
const displayName = `test_${uuid.v4().replace(/-/g, '_').substring(0, 26)}`;

// create
const create_output = execSync(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,7 @@ describe('Automl Natural Language Text Classification Create Dataset Test', () =

it('should create a dataset', async () => {
const projectId = await client.getProjectId();
const displayName = `test_${uuid
.v4()
.replace(/-/g, '_')
.substring(0, 26)}`;
const displayName = `test_${uuid.v4().replace(/-/g, '_').substring(0, 26)}`;

// create
const create_output = execSync(
Expand Down
5 changes: 1 addition & 4 deletions automl/test/translate_create_dataset.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,7 @@ describe('Automl Translate Create Dataset Test', () => {

it('should create a dataset', async () => {
const projectId = await client.getProjectId();
const displayName = `test_${uuid
.v4()
.replace(/-/g, '_')
.substring(0, 26)}`;
const displayName = `test_${uuid.v4().replace(/-/g, '_').substring(0, 26)}`;

// create
const create_output = execSync(
Expand Down
2 changes: 1 addition & 1 deletion automl/test/translate_create_model.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe('Automl Translate Create Model Tests', () => {
const client = new AutoMlClient();
let operationId;

it('should create a model', async function() {
it('should create a model', async function () {
this.retries(5);
await delay(this.test);

Expand Down
5 changes: 1 addition & 4 deletions automl/test/video-classification-create-dataset.beta.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,7 @@ describe('Automl Video Classification Create Dataset Test', () => {

it('should create a dataset', async () => {
const projectId = await client.getProjectId();
const displayName = `test_${uuid
.v4()
.replace(/-/g, '_')
.substring(0, 26)}`;
const displayName = `test_${uuid.v4().replace(/-/g, '_').substring(0, 26)}`;

// create
const create_output = execSync(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,7 @@ describe('Automl Video Object Tracking Create Dataset Test', () => {

it('should create a dataset', async () => {
const projectId = await client.getProjectId();
const displayName = `test_${uuid
.v4()
.replace(/-/g, '_')
.substring(0, 26)}`;
const displayName = `test_${uuid.v4().replace(/-/g, '_').substring(0, 26)}`;

// create
const create_output = execSync(
Expand Down
5 changes: 1 addition & 4 deletions automl/test/vision_classification_create_dataset.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,7 @@ describe('Automl Vision Classification Create Dataset Test', () => {

it('should create a dataset', async () => {
const projectId = await client.getProjectId();
const displayName = `test_${uuid
.v4()
.replace(/-/g, '_')
.substring(0, 26)}`;
const displayName = `test_${uuid.v4().replace(/-/g, '_').substring(0, 26)}`;

// create
const create_output = execSync(
Expand Down
5 changes: 1 addition & 4 deletions automl/test/vision_object_detection_create_dataset.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,7 @@ describe('Automl Vision Object Detection Create Dataset Test', () => {

it('should create a dataset', async () => {
const projectId = await client.getProjectId();
const displayName = `test_${uuid
.v4()
.replace(/-/g, '_')
.substring(0, 26)}`;
const displayName = `test_${uuid.v4().replace(/-/g, '_').substring(0, 26)}`;

// create
const create_output = await execSync(
Expand Down
2 changes: 1 addition & 1 deletion automl/test/vision_object_detection_predict.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const {delay} = require('./util');
describe('Automl Vision Object Detection Predict Test', () => {
const client = new AutoMlClient();

it('should verify the model is deployed', async function() {
it('should verify the model is deployed', async function () {
this.retries(5);
await delay(this.test);
const projectId = await client.getProjectId();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,7 @@ async function main(
// Display the model evaluations information.
console.log(`\nModel evaluation name: ${response.name}`);
console.log(
`Model evaluation Id: ${response.name
.split('/')
.slice(-1)
.pop()}`
`Model evaluation Id: ${response.name.split('/').slice(-1).pop()}`
);
console.log(
`Model evaluation annotation spec Id: ${response.annotationSpecId}`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,7 @@ async function main(
// Display the model evaluations information.
console.log(`\nModel evaluation name: ${element[i].name}`);
console.log(
`Model evaluation Id: ${element[i].name
.split('/')
.slice(-1)
.pop()}`
`Model evaluation Id: ${element[i].name.split('/').slice(-1).pop()}`
);
console.log(
`Model evaluation annotation spec Id: ${element[i].annotationSpecId}`
Expand Down
Loading

0 comments on commit e1c1c1e

Please sign in to comment.