Skip to content
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

Composer: Move 'triggering DAGs' sample to GitHub. #716

Merged
merged 3 commits into from
Aug 29, 2018
Merged

Conversation

tswast
Copy link
Contributor

@tswast tswast commented Aug 22, 2018

Sample was originally hard-coded in HTML at
https://cloud.google.com/composer/docs/how-to/using/triggering-with-gcf

Python code for target DAG is also being moved to GitHub in GoogleCloudPlatform/python-docs-samples#1645

@TrevorEdwards Please review.

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Aug 22, 2018
@tswast
Copy link
Contributor Author

tswast commented Aug 22, 2018

Note: as this is moving code as-is from cloud.google.com, I don't add tests in this PR. The only changes I made were to fix the linter errors.

I have an open bug 111401746 to fix the error handling code and plan to add unit tests at that time.

@codecov
Copy link

codecov bot commented Aug 22, 2018

Codecov Report

Merging #716 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #716   +/-   ##
=======================================
  Coverage   55.17%   55.17%           
=======================================
  Files           1        1           
  Lines          58       58           
=======================================
  Hits           32       32           
  Misses         26       26

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ade02a3...5aac3b2. Read the comment docs.

Copy link
Contributor

@ace-n ace-n left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apply these comments throughout your PR.


'use strict';

// [START composer_trigger]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: functions region tags are (usually) prefixed with functions_.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd be happy to, but are you a samples lead in go/samples-tracker? I don't have permissions to make functions samples there.

exports.triggerDag = function triggerDag (event, callback) {
// Fill in your Composer environment information here.

// The project that holds your function
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit - typically:

  1. we only show the contents of a function within a sample (i.e. we omit the function signature)
  2. we pass in any required values as parameters
  3. we include definitions of those values in the body of the function, but they are commented out

Apply this comment throughout your PR (if you choose to).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even for a cloud functions sample? This sample is intended to be copy-pasted into the cloud functions web UI, so I believe the function signature is necessary.

const DAG_NAME = 'composer_sample_trigger_response_dag';

// Other constants
const WEBSERVER_URL = 'https://' + WEBSERVER_ID +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: use template literals to construct strings?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

// Make the request
authorizeIap(
CLIENT_ID, PROJECT_ID, USER_AGENT,
function iapAuthorizationCallback (err, jwt, idToken) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use promises instead of callbacks here? (Both versions of Node on GCF support promises, though only Node 8 supports async/await.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. I switched to the node-fetch library which does support promises.


const SERVICE_ACCOUNT = [projectId, '@appspot.gserviceaccount.com'].join('');

var options = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use const or let instead of var?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in new node-fetch logic.

Copy link
Contributor

@TrevorEdwards TrevorEdwards left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving the migration as original author of this sample code.

@tswast tswast merged commit ab2d996 into master Aug 29, 2018
@tswast tswast deleted the tswast-composer branch August 29, 2018 22:02
ace-n pushed a commit that referenced this pull request Aug 30, 2018
* Composer: Move 'triggering DAGs' sample to GitHub.

Sample was originally hard-coded in HTML at
https://cloud.google.com/composer/docs/how-to/using/triggering-with-gcf

* Use node-fetch for promises in HTTP requests.
ace-n pushed a commit that referenced this pull request Nov 16, 2022
🤖 I have created a release *beep* *boop*
---


## [4.0.0](googleapis/nodejs-video-intelligence@v3.4.1...v4.0.0) (2022-06-29)


### ⚠ BREAKING CHANGES

* update library to use Node 12 (#714)
* field ObjectTrackingAnnotation.segment moved into oneof, added track_id (#704)

### Features

* field ObjectTrackingAnnotation.segment moved into oneof, added track_id ([#704](googleapis/nodejs-video-intelligence#704)) ([b55757b](googleapis/nodejs-video-intelligence@b55757b))
* support regapic LRO ([#720](googleapis/nodejs-video-intelligence#720)) ([903e5ca](googleapis/nodejs-video-intelligence@903e5ca))


### Bug Fixes

* fixes for dynamic routing and streaming descriptors ([#716](googleapis/nodejs-video-intelligence#716)) ([853d91e](googleapis/nodejs-video-intelligence@853d91e))


### Build System

* update library to use Node 12 ([#714](googleapis/nodejs-video-intelligence#714)) ([a9fbbcd](googleapis/nodejs-video-intelligence@a9fbbcd))

---
This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
ace-n pushed a commit that referenced this pull request Nov 17, 2022
🤖 I have created a release *beep* *boop*
---


## [4.0.0](googleapis/nodejs-video-intelligence@v3.4.1...v4.0.0) (2022-06-29)


### ⚠ BREAKING CHANGES

* update library to use Node 12 (#714)
* field ObjectTrackingAnnotation.segment moved into oneof, added track_id (#704)

### Features

* field ObjectTrackingAnnotation.segment moved into oneof, added track_id ([#704](googleapis/nodejs-video-intelligence#704)) ([b55757b](googleapis/nodejs-video-intelligence@b55757b))
* support regapic LRO ([#720](googleapis/nodejs-video-intelligence#720)) ([903e5ca](googleapis/nodejs-video-intelligence@903e5ca))


### Bug Fixes

* fixes for dynamic routing and streaming descriptors ([#716](googleapis/nodejs-video-intelligence#716)) ([853d91e](googleapis/nodejs-video-intelligence@853d91e))


### Build System

* update library to use Node 12 ([#714](googleapis/nodejs-video-intelligence#714)) ([a9fbbcd](googleapis/nodejs-video-intelligence@a9fbbcd))

---
This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
ahrarmonsur pushed a commit that referenced this pull request Nov 17, 2022
🤖 I have created a release *beep* *boop*
---


## [4.0.0](googleapis/nodejs-video-intelligence@v3.4.1...v4.0.0) (2022-06-29)


### ⚠ BREAKING CHANGES

* update library to use Node 12 (#714)
* field ObjectTrackingAnnotation.segment moved into oneof, added track_id (#704)

### Features

* field ObjectTrackingAnnotation.segment moved into oneof, added track_id ([#704](googleapis/nodejs-video-intelligence#704)) ([b55757b](googleapis/nodejs-video-intelligence@b55757b))
* support regapic LRO ([#720](googleapis/nodejs-video-intelligence#720)) ([903e5ca](googleapis/nodejs-video-intelligence@903e5ca))


### Bug Fixes

* fixes for dynamic routing and streaming descriptors ([#716](googleapis/nodejs-video-intelligence#716)) ([853d91e](googleapis/nodejs-video-intelligence@853d91e))


### Build System

* update library to use Node 12 ([#714](googleapis/nodejs-video-intelligence#714)) ([a9fbbcd](googleapis/nodejs-video-intelligence@a9fbbcd))

---
This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants