-
Notifications
You must be signed in to change notification settings - Fork 92
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
docs: samples and tests for auto-generated createDatabase and createInstance APIs. #1065
Conversation
Here is the summary of changes. You are about to add 2 region tags.
This comment is generated by snippet-bot.
|
d9563e5
to
02a48d7
Compare
samples/generated/snippets.py
Outdated
|
||
# [START spanner_create_database_with_default_leader] | ||
def create_database_with_default_leader(instance_id, database_id, default_leader): | ||
"""Creates a database with tables with a default leader.""" |
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.
Do we want to include the function name in the snippet, where folks have to call the function or do we want to have it as a runnable snippet?
For example, see the snippet below which can be run directly
https://github.com/GoogleCloudPlatform/python-docs-samples/blob/main/automl/snippets/batch_predict.py#L21
Instead of
# [START spanner_create_database_with_default_leader]
def create_database_with_default_leader(instance_id, database_id, default_leader):
"""Creates a database with tables with a default leader."""
we could have
def create_database_with_default_leader(instance_id, database_id, default_leader):
"""Creates a database with tables with a default leader."""
# [START spanner_create_database_with_default_leader]
from google.cloud import spanner
# TODO(developer): Uncomment and set the following variables
# instance_id = "<replace with useful text for developer>"
# database_id = "<replace with useful text for developer>"
# default_leader = "<replace with useful text for developer>"
spanner_client = spanner.Client()
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.
Thanks @parthea, I want to have one change at a time for this work, and follow the syntax above in separate PR for all samples in repository.
) | ||
|
||
|
||
# [END spanner_create_database_with_default_leader] |
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.
This python file should be run as main
program since this will get referred in the Getting started with Python guide.
Can we add it similar to existing one in snippets.py?
python-spanner/samples/samples/snippets.py
Line 2799 in f3b23b2
if __name__ == "__main__": # noqa: C901 |
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.
This is planned in another PR when we switch the tags later to new samples.
samples/samples/admin/samples.py
Outdated
"""Creates a database with tables with a default leader.""" | ||
spanner_client = spanner.Client() | ||
operation = spanner_client.database_admin_api.create_database( | ||
request={ |
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: The request
here can be either dict
or spanner_database_admin.CreateDatabaseRequest
.
Can we use spanner_database_admin.CreateDatabaseRequest
instead of dict, since it will help customers understand how to use autogenerated code for building requests.
Notes