Skip to content

Commit

Permalink
chore: new owl bot post processor docker image (#898)
Browse files Browse the repository at this point in the history
gcr.io/repo-automation-bots/owlbot-nodejs:latest@sha256:f93bb861d6f12574437bb9aee426b71eafd63b419669ff0ed029f4b7e7162e3f
  • Loading branch information
gcf-owl-bot[bot] authored May 10, 2021
1 parent 5ec8a76 commit 61f1d6b
Show file tree
Hide file tree
Showing 19 changed files with 1,104 additions and 1,335 deletions.
14 changes: 7 additions & 7 deletions packages/google-cloud-vision/protos/protos.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 14 additions & 14 deletions packages/google-cloud-vision/protos/protos.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

58 changes: 33 additions & 25 deletions packages/google-cloud-vision/src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,21 +95,21 @@ const _requestToObject = (request: any) => {
// Guess based on what the string looks like, and build the full
// request object in the correct format.
if (request.indexOf('://') === -1 || request.indexOf('file://') === 0) {
request = ({
request = {
image: {source: {filename: request}},
} as unknown) as ImprovedRequest;
} as unknown as ImprovedRequest;
} else {
request = ({
request = {
image: {source: {imageUri: request}},
} as unknown) as ImprovedRequest;
} as unknown as ImprovedRequest;
}
} else if (Buffer.isBuffer(request)) {
// Drop the buffer one level lower; it will get dealt with later
// in the function. This allows sending <Buffer> and {image: <Buffer>} to
// both work identically.
request = ({image: request} as unknown) as ImprovedRequest;
request = {image: request} as unknown as ImprovedRequest;
}
return (request as unknown) as ImprovedRequest;
return request as unknown as ImprovedRequest;
};

const _coerceRequest = (
Expand Down Expand Up @@ -216,7 +216,7 @@ const _createSingleFeatureMethod = (
};

export function call(apiVersion: string) {
const methods: FeaturesMethod = ({} as unknown) as FeaturesMethod;
const methods: FeaturesMethod = {} as unknown as FeaturesMethod;
/**
* Annotate a single image with the requested features.
*
Expand Down Expand Up @@ -314,11 +314,13 @@ export function call(apiVersion: string) {
req: protoTypes.google.cloud.vision.v1.IAnnotateImageRequest | undefined
) => {
if (err) {
return ((callback as unknown) as gax.Callback<
protoTypes.google.cloud.vision.v1.IAnnotateImageResponse,
{},
{}
>)(err);
return (
callback as unknown as gax.Callback<
protoTypes.google.cloud.vision.v1.IAnnotateImageResponse,
{},
{}
>
)(err);
}

// Call the GAPIC batch annotation function.
Expand All @@ -335,23 +337,27 @@ export function call(apiVersion: string) {
) => {
// If there is an error, handle it.
if (err) {
return ((callback as unknown) as gax.Callback<
protoTypes.google.cloud.vision.v1.IAnnotateImageResponse,
{},
{}
>)(err);
return (
callback as unknown as gax.Callback<
protoTypes.google.cloud.vision.v1.IAnnotateImageResponse,
{},
{}
>
)(err);
}

// We are guaranteed to only have one response element, since we
// only sent one image.
const response = r!.responses![0];

// Fire the callback if applicable.
return ((callback as unknown) as gax.Callback<
protoTypes.google.cloud.vision.v1.IAnnotateImageResponse,
{},
{}
>)(undefined, response);
return (
callback as unknown as gax.Callback<
protoTypes.google.cloud.vision.v1.IAnnotateImageResponse,
{},
{}
>
)(undefined, response);
}
);
}
Expand All @@ -362,9 +368,11 @@ export function call(apiVersion: string) {
// eslint-disable-next-line @typescript-eslint/no-var-requires
require('../protos/protos.json')
);
const features = (protoFilesRoot.lookup(
`google.cloud.vision.${apiVersion}.Feature.Type`
) as gax.protobuf.Enum).values;
const features = (
protoFilesRoot.lookup(
`google.cloud.vision.${apiVersion}.Feature.Type`
) as gax.protobuf.Enum
).values;

/**
* Annotate a single image with face detection.
Expand Down
51 changes: 24 additions & 27 deletions packages/google-cloud-vision/src/v1/image_annotator_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,13 +280,14 @@ export class ImageAnnotatorClient {
];
for (const methodName of imageAnnotatorStubMethods) {
const callPromise = this.imageAnnotatorStub.then(
stub => (...args: Array<{}>) => {
if (this._terminated) {
return Promise.reject('The client has already been closed.');
}
const func = stub[methodName];
return func.apply(stub, args);
},
stub =>
(...args: Array<{}>) => {
if (this._terminated) {
return Promise.reject('The client has already been closed.');
}
const func = stub[methodName];
return func.apply(stub, args);
},
(err: Error | null | undefined) => () => {
throw err;
}
Expand Down Expand Up @@ -458,11 +459,10 @@ export class ImageAnnotatorClient {
options = options || {};
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
options.otherArgs.headers[
'x-goog-request-params'
] = gax.routingHeader.fromParams({
parent: request.parent || '',
});
options.otherArgs.headers['x-goog-request-params'] =
gax.routingHeader.fromParams({
parent: request.parent || '',
});
this.initialize();
return this.innerApiCalls.batchAnnotateImages(request, options, callback);
}
Expand Down Expand Up @@ -570,11 +570,10 @@ export class ImageAnnotatorClient {
options = options || {};
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
options.otherArgs.headers[
'x-goog-request-params'
] = gax.routingHeader.fromParams({
parent: request.parent || '',
});
options.otherArgs.headers['x-goog-request-params'] =
gax.routingHeader.fromParams({
parent: request.parent || '',
});
this.initialize();
return this.innerApiCalls.batchAnnotateFiles(request, options, callback);
}
Expand Down Expand Up @@ -699,11 +698,10 @@ export class ImageAnnotatorClient {
options = options || {};
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
options.otherArgs.headers[
'x-goog-request-params'
] = gax.routingHeader.fromParams({
parent: request.parent || '',
});
options.otherArgs.headers['x-goog-request-params'] =
gax.routingHeader.fromParams({
parent: request.parent || '',
});
this.initialize();
return this.innerApiCalls.asyncBatchAnnotateImages(
request,
Expand Down Expand Up @@ -863,11 +861,10 @@ export class ImageAnnotatorClient {
options = options || {};
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
options.otherArgs.headers[
'x-goog-request-params'
] = gax.routingHeader.fromParams({
parent: request.parent || '',
});
options.otherArgs.headers['x-goog-request-params'] =
gax.routingHeader.fromParams({
parent: request.parent || '',
});
this.initialize();
return this.innerApiCalls.asyncBatchAnnotateFiles(
request,
Expand Down
Loading

0 comments on commit 61f1d6b

Please sign in to comment.