Skip to content

fix: add region tag, move code around for docs#9952

Merged
engelke merged 8 commits into
mainfrom
fixit-sigje-281697285-1
May 16, 2023
Merged

fix: add region tag, move code around for docs#9952
engelke merged 8 commits into
mainfrom
fixit-sigje-281697285-1

Conversation

@iennae
Copy link
Copy Markdown
Contributor

@iennae iennae commented May 15, 2023

pair with @nicain; this is not typical usage of if __name__ == .. but
to make sure documentation and intent of the sample for atlas this
should work.

Checklist

    pair with @nicain; this is not typical usage of if __name__ == .. but
    to make sure documentation and intent of the sample for atlas this
    should work.

Co-authored-by: Nick Cain <nicholascain@google.com>
@iennae iennae requested review from a team as code owners May 15, 2023 19:22
@snippet-bot
Copy link
Copy Markdown

snippet-bot Bot commented May 15, 2023

Here is the summary of changes.

You are about to add 1 region tag.
You are about to delete 1 region tag.

This comment is generated by snippet-bot.
If you find problems with this result, please file an issue at:
https://github.com/googleapis/repo-automation-bots/issues.
To update this comment, add snippet-bot:force-run label or use the checkbox below:

  • Refresh this comment

@product-auto-label product-auto-label Bot added samples Issues that are directly related to samples. api: pubsub Issues related to the Pub/Sub API. labels May 15, 2023
I deleted one too many empty lines.
Comment thread run/pubsub/main.py Outdated
Comment thread run/pubsub/main.py Outdated
Comment thread run/pubsub/main.py Outdated
Comment thread run/pubsub/main.py
@@ -14,15 +14,25 @@

# [START cloudrun_pubsub_server_setup]
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is there a difference between cloudrun_pubsub_server_setup and cloudrun_pubsub_server?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

not in python, but if I don't have both region tags then audits will say cloudrun_pubsub_server is missing.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We only need to use one region tag. We don't always have complete 1:1 matches across languages

Comment thread run/pubsub/main.py Outdated
Comment on lines +24 to +31

if __name__ == "__main__":
PORT = int(os.getenv("PORT")) if os.getenv("PORT") else 8080

# This is used when running locally. Gunicorn is used to run the
# application on Cloud Run. See entrypoint in Dockerfile.
app.run(host="127.0.0.1", port=PORT, debug=False)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

A python expert may weigh in but it may be more idiomatic to have this at the bottom of the file and duplicate the region tags around it

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I didn't encompass this in the description but that's what I was pairing with Nick on before. Proposed solution was the second best (first was creating a separate file).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The if name section is not being used in the sample. It's being launched by gunicorn in the Dockerfile and in Cloud Run. It would be better to remove it than move it.

iennae added 3 commits May 15, 2023 15:04
remote region tag server_setup
process for changing the name for a region tag is to add the second one, update docs, then remove the old tag. So this requires both region tags currently. 

Second, remove the if statement. Even if this is not matching the intent of the other samples, this is the preferred method from @engelke
Copy link
Copy Markdown
Contributor

@engelke engelke left a comment

Choose a reason for hiding this comment

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

LGTM

@engelke engelke merged commit 7ebad54 into main May 16, 2023
@engelke engelke deleted the fixit-sigje-281697285-1 branch May 16, 2023 00:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: pubsub Issues related to the Pub/Sub API. samples Issues that are directly related to samples.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants