Skip to content
This repository has been archived by the owner on Nov 29, 2023. It is now read-only.

docs: add python quickstart sample #141

Merged
merged 10 commits into from Dec 1, 2021
Merged

docs: add python quickstart sample #141

merged 10 commits into from Dec 1, 2021

Conversation

loferris
Copy link
Contributor

Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • [x ] Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • [x ] Ensure the tests and linter pass
  • [x ] Code coverage does not decrease (if any source code was changed)
  • [ x] Appropriate docs were updated (if necessary)

@loferris loferris requested a review from a team November 23, 2021 00:24
@loferris loferris requested a review from a team as a code owner November 23, 2021 00:24
@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Nov 23, 2021
@product-auto-label product-auto-label bot added the api: bigqueryconnection Issues related to the googleapis/python-bigquery-connection API. label Nov 23, 2021
@snippet-bot
Copy link

snippet-bot bot commented Nov 23, 2021

Here is the summary of changes.

You are about to add 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

@loferris loferris changed the title Feat python quickstart feat: add python quickstart sample Nov 23, 2021
@loferris loferris self-assigned this Nov 23, 2021
@product-auto-label product-auto-label bot added the samples Issues that are directly related to samples. label Nov 23, 2021
Comment on lines 41 to 46
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--project_id", type=str)
parser.add_argument("--location", default="US", type=str)
args = parser.parse_args()
main(project_id=args.project_id, location=args.location)

Choose a reason for hiding this comment

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

nit: Should this be included in the snippet? generally we favor not including CLIs in new samples

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed in latest commit!


def main(project_id: str = "your-project-id", location: str = "US") -> None:
# Constructs client for interacting with the service
client = bq_connection.ConnectionServiceClient()

Choose a reason for hiding this comment

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

Can we push the client initialization down into list_connections?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed in latest commit! I also removed the client fixture from conftest.py though I'm guessing we'll need it with future samples!

Copy link
Contributor

@tswast tswast left a comment

Choose a reason for hiding this comment

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

Looks good. Just one nit.

Comment on lines 41 to 46
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--project_id", type=str)
parser.add_argument("--location", default="US", type=str)
args = parser.parse_args()
main(project_id=args.project_id, location=args.location)
Copy link
Contributor

Choose a reason for hiding this comment

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

This was an old pattern. It's difficult to test the CLI arguments, so we omit them in our samples rubric. go/code-snippets-style#running-from-the-command-line

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Awesome, good to know - removed in latest commit!

@loferris
Copy link
Contributor Author

Comments addressed! @tswast @kurtisvg

samples/snippets/noxfile.py Show resolved Hide resolved
Copy link
Contributor

@tswast tswast left a comment

Choose a reason for hiding this comment

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

Thanks!

samples/snippets/quickstart.py Outdated Show resolved Hide resolved
@tswast tswast changed the title feat: add python quickstart sample docs: add python quickstart sample Dec 1, 2021
@tswast tswast merged commit 8b85fb6 into main Dec 1, 2021
@tswast tswast deleted the feat_python_quickstart branch December 1, 2021 17:23
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api: bigqueryconnection Issues related to the googleapis/python-bigquery-connection API. cla: yes This human has signed the Contributor License Agreement. samples Issues that are directly related to samples.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants