Skip to content

Commit

Permalink
feat!: drop node8, remove eslint, update gax, fix generated protos, r…
Browse files Browse the repository at this point in the history
…un the generator (#423)
  • Loading branch information
alexander-fenster authored and ahrarmonsur committed Nov 17, 2022
1 parent 125e563 commit eb9c042
Show file tree
Hide file tree
Showing 19 changed files with 57 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ async function main(path = 'YOUR_LOCAL_FILE', outputUri = 'PATH_TO_OUTPUT') {
};
chunks.push(request);
})
.on('close', function() {
.on('close', () => {
// configRequest should be the first in the stream of requests
stream.write(configRequest);
for (let i = 0; i < chunks.length; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ async function main(
};
chunks.push(request);
})
.on('close', function() {
.on('close', () => {
// configRequest should be the first in the stream of requests
stream.write(configRequest);
for (let i = 0; i < chunks.length; i++) {
Expand Down
2 changes: 1 addition & 1 deletion video-intelligence/analyze-streaming-labels.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ async function main(path = 'YOUR_LOCAL_FILE') {
};
chunks.push(request);
})
.on('close', function() {
.on('close', () => {
// configRequest should be the first in the stream of requests
stream.write(configRequest);
for (let i = 0; i < chunks.length; i++) {
Expand Down
4 changes: 2 additions & 2 deletions video-intelligence/analyze-streaming-object.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ async function main(path = 'YOUR_LOCAL_FILE') {
};
chunks.push(request);
})
.on('close', function() {
.on('close', () => {
// configRequest should be the first in the stream of requests
stream.write(configRequest);
for (let i = 0; i < chunks.length; i++) {
Expand All @@ -70,7 +70,7 @@ async function main(path = 'YOUR_LOCAL_FILE') {
);
//Every annotation has only one frame.
const box = object.frames[0].normalizedBoundingBox;
console.log(`Bounding box position:`);
console.log('Bounding box position:');
console.log(` left :${box.left}`);
console.log(` top :${box.top}`);
console.log(` right :${box.right}`);
Expand Down
2 changes: 1 addition & 1 deletion video-intelligence/analyze-streaming-safe-search.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ async function main(path = 'YOUR_LOCAL_FILE') {
};
chunks.push(request);
})
.on('close', function() {
.on('close', () => {
// configRequest should be the first in the stream of requests
stream.write(configRequest);
for (let i = 0; i < chunks.length; i++) {
Expand Down
4 changes: 2 additions & 2 deletions video-intelligence/analyze-streaming-shot-change.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ async function main(path = 'YOUR_LOCAL_FILE') {
};
chunks.push(request);
})
.on('close', function() {
.on('close', () => {
// configRequest should be the first in the stream of requests
stream.write(configRequest);
for (let i = 0; i < chunks.length; i++) {
Expand All @@ -61,7 +61,7 @@ async function main(path = 'YOUR_LOCAL_FILE') {
const shotChanges = annotations.shotAnnotations;
console.log(JSON.stringify(shotChanges));
if (shotChanges.length === 1) {
console.log(`The entire video is one shot.`);
console.log('The entire video is one shot.');
}
shotChanges.forEach(shot => {
console.log(
Expand Down
70 changes: 36 additions & 34 deletions video-intelligence/analyze.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ async function analyzeShots(gcsUri) {
console.log('Shot changes:');

if (shotChanges.length === 1) {
console.log(`The entire video is one shot.`);
console.log('The entire video is one shot.');
} else {
shotChanges.forEach((shot, shotIdx) => {
console.log(`Scene ${shotIdx} occurs from:`);
Expand Down Expand Up @@ -344,7 +344,7 @@ async function analyzeTextGCS(gcsUri) {
`Time offset for the frame: ${timeOffset.seconds || 0}` +
`.${(timeOffset.nanos / 1e6).toFixed(0)}s`
);
console.log(`Rotated Bounding Box Vertices:`);
console.log('Rotated Bounding Box Vertices:');
frame.rotatedBoundingBox.vertices.forEach(vertex => {
console.log(`Vertex.x:${vertex.x}, Vertex.y:${vertex.y}`);
});
Expand Down Expand Up @@ -399,7 +399,7 @@ async function analyzeObjectTrackingGCS(gcsUri) {
`Time offset for the first frame: ${timeOffset.seconds || 0}` +
`.${(timeOffset.nanos / 1e6).toFixed(0)}s`
);
console.log(`Bounding box position:`);
console.log('Bounding box position:');
console.log(` left :${box.left}`);
console.log(` top :${box.top}`);
console.log(` right :${box.right}`);
Expand Down Expand Up @@ -468,7 +468,7 @@ async function analyzeText(path) {
`Time offset for the frame: ${timeOffset.seconds || 0}` +
`.${(timeOffset.nanos / 1e6).toFixed(0)}s`
);
console.log(`Rotated Bounding Box Vertices:`);
console.log('Rotated Bounding Box Vertices:');
frame.rotatedBoundingBox.vertices.forEach(vertex => {
console.log(`Vertex.x:${vertex.x}, Vertex.y:${vertex.y}`);
});
Expand Down Expand Up @@ -526,7 +526,7 @@ async function analyzeObjectTracking(path) {
`Time offset for the first frame: ${timeOffset.seconds || 0}` +
`.${(timeOffset.nanos / 1e6).toFixed(0)}s`
);
console.log(`Bounding box position:`);
console.log('Bounding box position:');
console.log(` left :${box.left}`);
console.log(` top :${box.top}`);
console.log(` right :${box.right}`);
Expand All @@ -536,77 +536,79 @@ async function analyzeObjectTracking(path) {
}

async function main() {
require(`yargs`)
require('yargs')
.demand(1)
.command(
`shots <gcsUri>`,
`Analyzes shot angles in a video stored in Google Cloud Storage using the Cloud Video Intelligence API.`,
'shots <gcsUri>',
'Analyzes shot angles in a video stored in Google Cloud Storage using the Cloud Video Intelligence API.',
{},
opts => analyzeShots(opts.gcsUri)
)
.command(
`labels-gcs <gcsUri>`,
`Labels objects in a video stored in Google Cloud Storage using the Cloud Video Intelligence API.`,
'labels-gcs <gcsUri>',
'Labels objects in a video stored in Google Cloud Storage using the Cloud Video Intelligence API.',
{},
opts => analyzeLabelsGCS(opts.gcsUri)
)
.command(
`labels-file <filePath>`,
`Labels objects in a video stored locally using the Cloud Video Intelligence API.`,
'labels-file <filePath>',
'Labels objects in a video stored locally using the Cloud Video Intelligence API.',
{},
opts => analyzeLabelsLocal(opts.filePath)
)
.command(
`safe-search <gcsUri>`,
`Detects explicit content in a video stored in Google Cloud Storage.`,
'safe-search <gcsUri>',
'Detects explicit content in a video stored in Google Cloud Storage.',
{},
opts => analyzeSafeSearch(opts.gcsUri)
)
.command(
`transcription <gcsUri>`,
`Extract the video transcription using the Cloud Video Intelligence API.`,
'transcription <gcsUri>',
'Extract the video transcription using the Cloud Video Intelligence API.',
{},
opts => analyzeVideoTranscription(opts.gcsUri)
)
.command(
`video-text-gcs <gcsUri>`,
`Analyzes text in a video stored in Google Cloud Storage using the Cloud Video Intelligence API.`,
'video-text-gcs <gcsUri>',
'Analyzes text in a video stored in Google Cloud Storage using the Cloud Video Intelligence API.',
{},
opts => analyzeTextGCS(opts.gcsUri)
)
.command(
`track-objects-gcs <gcsUri>`,
`Analyzes objects in a video stored in Google Cloud Storage using the Cloud Video Intelligence API.`,
'track-objects-gcs <gcsUri>',
'Analyzes objects in a video stored in Google Cloud Storage using the Cloud Video Intelligence API.',
{},
opts => analyzeObjectTrackingGCS(opts.gcsUri)
)
.command(
`video-text <path>`,
`Analyzes text in a video stored in a local file using the Cloud Video Intelligence API.`,
'video-text <path>',
'Analyzes text in a video stored in a local file using the Cloud Video Intelligence API.',
{},
opts => analyzeText(opts.path)
)
.command(
`track-objects <path>`,
`Analyzes objects in a video stored in a local file using the Cloud Video Intelligence API.`,
'track-objects <path>',
'Analyzes objects in a video stored in a local file using the Cloud Video Intelligence API.',
{},
opts => analyzeObjectTracking(opts.path)
)
.example(`node $0 shots gs://cloud-samples-data/video/googlework_short.mp4`)
.example(`node $0 labels-gcs gs://cloud-samples-data/video/cat.mp4`)
.example(`node $0 labels-file googlework_short.mp4`)
.example(`node $0 safe-search gs://cloud-samples-data/video/googlework_short.mp4`)
.example(`node $0 transcription gs://cloud-samples-data/video/cat.mp4`)
.example(`node $0 video-text ./resources/googlework_short.mp4`)
.example('node $0 shots gs://cloud-samples-data/video/googlework_short.mp4')
.example('node $0 labels-gcs gs://cloud-samples-data/video/cat.mp4')
.example('node $0 labels-file googlework_short.mp4')
.example(
`node $0 video-text-gcs gs://nodejs-docs-samples/video/googlework_short.mp4`
'node $0 safe-search gs://cloud-samples-data/video/googlework_short.mp4'
)
.example(`node $0 track-objects ./resources/googlework_short.mp4`)
.example(`node $0 track-objects-gcs gs://nodejs-docs-samples/video/cat.mp4`)
.example('node $0 transcription gs://cloud-samples-data/video/cat.mp4')
.example('node $0 video-text ./resources/googlework_short.mp4')
.example(
'node $0 video-text-gcs gs://nodejs-docs-samples/video/googlework_short.mp4'
)
.example('node $0 track-objects ./resources/googlework_short.mp4')
.example('node $0 track-objects-gcs gs://nodejs-docs-samples/video/cat.mp4')
.wrap(120)
.recommendCommands()
.epilogue(
`For more information, see https://cloud.google.com/video-intelligence/docs`
'For more information, see https://cloud.google.com/video-intelligence/docs'
)
.help()
.strict().argv;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const {assert} = require('chai');
const {describe, it} = require('mocha');
const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'});

const cmd = `node analyze-streaming-annotation-to-storage.js`;
const cmd = 'node analyze-streaming-annotation-to-storage.js';
const project = process.env.GCLOUD_PROJECT;
const file = 'resources/googlework_short.mp4';
const outputUri = 'gs://' + project + '/VIDEO_STREAMING_OUTPUT';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ const {describe, it} = require('mocha');

const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'});

const cmd = `node analyze-streaming-automl-classification.js`;
const modelId = `VCN3094808572840640512`;
const cmd = 'node analyze-streaming-automl-classification.js';
const modelId = 'VCN3094808572840640512';
const project = process.env.GCLOUD_PROJECT;
const file = 'resources/googlework_short.mp4';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const {describe, it} = require('mocha');

const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'});

const cmd = `node analyze-streaming-labels.js`;
const cmd = 'node analyze-streaming-labels.js';
const file = 'resources/googlework_short.mp4';

describe('streaming label', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const {describe, it} = require('mocha');

const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'});

const cmd = `node analyze-streaming-object.js`;
const cmd = 'node analyze-streaming-object.js';
const file = 'resources/googlework_short.mp4';

describe('streaming object', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const {assert} = require('chai');
const {describe, it} = require('mocha');
const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'});

const cmd = `node analyze-streaming-safe-search.js`;
const cmd = 'node analyze-streaming-safe-search.js';
const file = 'resources/googlework_short.mp4';

describe('streaming safe search', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const {describe, it} = require('mocha');

const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'});

const cmd = `node analyze-streaming-shot-change.js`;
const cmd = 'node analyze-streaming-shot-change.js';
const file = 'resources/googlework_short.mp4';

describe('streaming shot change', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const {describe, it} = require('mocha');

const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'});

const cmd = `node analyze_face_detection.js`;
const cmd = 'node analyze_face_detection.js';
const file = 'resources/googlework_short.mp4';

describe('analyzing faces in video', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const {describe, it} = require('mocha');

const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'});

const cmd = `node analyze_face_detection_gcs.js`;
const cmd = 'node analyze_face_detection_gcs.js';
const gcsUri = 'gs://cloud-samples-data/video/googlework_short.mp4';

describe('analyzing faces in video', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const {describe, it} = require('mocha');

const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'});

const cmd = `node analyze_person_detection.js`;
const cmd = 'node analyze_person_detection.js';
const file = 'resources/googlework_short.mp4';

describe('analyzing people in video', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const {describe, it} = require('mocha');

const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'});

const cmd = `node analyze_person_detection_gcs.js`;
const cmd = 'node analyze_person_detection_gcs.js';
const gcsUri = 'gs://cloud-samples-data/video/googlework_short.mp4';

describe('analyzing people in video', () => {
Expand Down
2 changes: 1 addition & 1 deletion video-intelligence/system-test/detect_logo.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const {describe, it} = require('mocha');

const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'});

const cmd = `node detect_logo.js`;
const cmd = 'node detect_logo.js';
const file = 'resources/googlework_short.mp4';

describe('analyzing logos in video', () => {
Expand Down
2 changes: 1 addition & 1 deletion video-intelligence/system-test/detect_logo_gcs.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const {describe, it} = require('mocha');

const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'});

const cmd = `node detect_logo_gcs.js`;
const cmd = 'node detect_logo_gcs.js';
const file = 'gs://cloud-samples-data/video/googlework_short.mp4';

describe('analyzing logos in video on gcs', () => {
Expand Down

0 comments on commit eb9c042

Please sign in to comment.