-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Functions: ImageMagick tutorial: Idiomatic & Robustness Improvements #1456
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
Added a few comments that should be addressed before merging.
@@ -71,8 +72,7 @@ const blurImage = async (file, blurredBucketName) => { | |||
|
|||
console.log(`Downloaded ${file.name} to ${tempLocalPath}.`); | |||
} catch (err) { | |||
console.error('File download failed.', err); | |||
return Promise.reject(err); | |||
throw new Error(`File download failed: ${err}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we sure this will stringify correctly? Do we not mean to provide the ${err.message}
?
|
||
const safeFileName = 'bicycle.jpg'; | ||
const offensiveFileName = 'zombie.jpg'; | ||
|
||
const BUCKET_NAME = process.env.FUNCTIONS_BUCKET; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: It would be nice if we just used FUNCTIONS_BUCKET
so that we could destruct process.env
in the same way:
FUNCTIONS_BUCKET
BLURRED_FUNCTIONS_BUCKET
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed that it's a bit confusing. From what I can see, BUCKET_NAME is used in the same because it makes sense as simply the bucket causing the function trigger. FUNCTIONS_BUCKET is defined in .kokoro/build.sh
and has that name so the product testing config is disambiguated.
@@ -98,8 +98,7 @@ const blurImage = async (file, blurredBucketName) => { | |||
await blurredBucket.upload(tempLocalPath, {destination: file.name}); | |||
console.log(`Uploaded blurred image to: ${gcsPath}`); | |||
} catch (err) { | |||
console.error(`Unable to upload blurred image to ${gcsPath}:`, err); | |||
return Promise.reject(err); | |||
throw new Error(`Unable to upload blurred image to ${gcsPath}: ${err}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment about err.message
.
The test failures are:
I am looking into (2). |
We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. ℹ️ Googlers: Go here for more info. |
|
A Googler has manually verified that the CLAs look good. (Googler, please make sure the reason for overriding the CLA status is clearly documented in these comments.) ℹ️ Googlers: Go here for more info. |
Ace, this PR is currently blocked on your intentions for the bicycle.png image. |
describe('functions/imagemagick tests', async () => { | ||
let startFF, stopFF; | ||
// Successfully generated images require cleanup. | ||
let cleanupRequired = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just attempt to delete the file, and swallow the error if (and only if) it doesn't exist?
(IIRC that's more in-line with what our other samples do.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I bullet-proofed what I found instead of removing it. I can take this approach.
We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. ℹ️ Googlers: Go here for more info. |
A Googler has manually verified that the CLAs look good. (Googler, please make sure the reason for overriding the CLA status is clearly documented in these comments.) ℹ️ Googlers: Go here for more info. |
This PR is intended as a spot for some broad improvements to the ImageMagick sample after feedback in the duplicated code in #1445. Once this PR is in, the code in the other can be updated. We can knock some stuff around but let's focus on getting something ready with a ~1 week max turnaround.
Changes
test/index.test.js
index.js
Other Feedback Not Yet Incorporated
Other feedback for discussion