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

feat: autocommit sample #552

Closed
wants to merge 14 commits into from

Conversation

AlisskaPie
Copy link
Contributor

@AlisskaPie AlisskaPie commented Nov 5, 2020

This is one of the samples that demonstrates the difference between autocommit and !autocommit modes

@product-auto-label product-auto-label bot added the api: spanner Issues related to the googleapis/python-spanner-django API. label Nov 5, 2020
@snippet-bot
Copy link

snippet-bot bot commented Nov 5, 2020

Here is the summary of changes.

You added 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.

@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Nov 5, 2020
@AlisskaPie
Copy link
Contributor Author

AlisskaPie commented Nov 5, 2020

@c24t could you take a look?

Copy link
Contributor

@c24t c24t left a comment

Choose a reason for hiding this comment

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

A few comments, but the sample looks good and the test works after making a small change.

I see this sample describes how to enable autocommit, but doesn't show the difference between auto and non-auto behavior. Ideally this sample would show multiple queries each getting a separate txn in autocommit mode and getting combined in a single txn in non-auto mode. And would show manual commit calls.

Not a problem with this sample, but a problem with the library: we should respect django's autocommit setting. When DBAPI is moved out of this library I wouldn't expect users to set connection.autocommit themselves.

samples/samples/test_autocommit.py Outdated Show resolved Hide resolved
samples/samples/test_autocommit.py Outdated Show resolved Hide resolved
samples/samples/autocommit.py Show resolved Hide resolved
samples/samples/autocommit.py Show resolved Hide resolved
samples/samples/autocommit.py Outdated Show resolved Hide resolved
@c24t c24t marked this pull request as ready for review November 5, 2020 22:36
@c24t c24t requested review from a team as code owners November 5, 2020 22:36
@c24t c24t requested a review from dinagraves November 5, 2020 22:36
Copy link
Contributor Author

@AlisskaPie AlisskaPie left a comment

Choose a reason for hiding this comment

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

Thank you for your detailed review!

I see this sample describes how to enable autocommit, but doesn't show the difference between auto and non-auto behavior. Ideally this sample would show multiple queries each getting a separate txn in autocommit mode and getting combined in a single txn in non-auto mode. And would show manual commit calls.

I'm sorry, I wasn't correct in a comment and the sample doesn't show the difference between those two modes. I wanted to say that it shows only one of the modes. And for other mode there will be another sample. So users will see that way the difference themselves.

Not a problem with this sample, but a problem with the library: we should respect django's autocommit setting. When DBAPI is moved out of this library I wouldn't expect users to set connection.autocommit themselves.

Just to clarify: I need to use set_autocommit function instead?

samples/samples/test_autocommit.py Outdated Show resolved Hide resolved
samples/samples/autocommit.py Show resolved Hide resolved
samples/samples/autocommit.py Show resolved Hide resolved
samples/samples/test_autocommit.py Outdated Show resolved Hide resolved
@c24t
Copy link
Contributor

c24t commented Nov 12, 2020

And for other mode there will be another sample. So users will see that way the difference themselves.

That sounds fine, let's see how these samples appear in the cloud docs.

Just to clarify: I need to use set_autocommit function instead?

Ideally yes, this would just follow django's autocommit setting and the user wouldn't set this at all. But now since googleapis/python-spanner#160 moved the DBAPI package into python-spanner we might need to move these samples over too, and write different django-specific docs for this spanner-django.

Copy link
Contributor

@c24t c24t left a comment

Choose a reason for hiding this comment

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

LGTM, but let's check whether this should move into python-spanner with googleapis/python-spanner#160 before merging here.

@tmatsuo
Copy link

tmatsuo commented Nov 12, 2020

There is a possible violation for not having product prefix.

snippet-bot thinks it's violating a region tag rule where we should have product prefix. If you change the region tag to spanner_enable_autocommit_mode, the bot will be happy.

samples/samples/autocommit.py Outdated Show resolved Hide resolved
samples/samples/autocommit.py Outdated Show resolved Hide resolved
@AlisskaPie
Copy link
Contributor Author

There is a possible violation for not having product prefix.

snippet-bot thinks it's violating a region tag rule where we should have product prefix. If you change the region tag to spanner_enable_autocommit_mode, the bot will be happy.

Thank you! Bot is happy now 🎉

@dinagraves dinagraves added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Nov 17, 2020
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Nov 17, 2020
@dinagraves
Copy link

dinagraves commented Nov 17, 2020

The "Create Database" part of the test suite is failing b/c the database already exists.

From the logs:

E           	status = StatusCode.ALREADY_EXISTS
E           	details = "Database already exists: projects/precise-truck-742/instances/google-cloud-python-systest/databases/db-api-transactions-management"

Looks like it's a pre-existing issue unrelated to this PR here.

Copy link

@dinagraves dinagraves left a comment

Choose a reason for hiding this comment

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

Now that the tests are passing, I only have formatting nits.

samples/samples/autocommit.py Outdated Show resolved Hide resolved
samples/samples/test_autocommit.py Outdated Show resolved Hide resolved
samples/samples/test_autocommit.py Outdated Show resolved Hide resolved
samples/samples/test_autocommit.py Outdated Show resolved Hide resolved
Copy link
Contributor Author

@AlisskaPie AlisskaPie left a comment

Choose a reason for hiding this comment

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

Thanks for your help!

samples/samples/autocommit.py Outdated Show resolved Hide resolved
samples/samples/test_autocommit.py Outdated Show resolved Hide resolved
samples/samples/test_autocommit.py Outdated Show resolved Hide resolved
samples/samples/test_autocommit.py Outdated Show resolved Hide resolved
@c24t
Copy link
Contributor

c24t commented Dec 2, 2020

@AlisskaPie can we close this in favor of googleapis/python-spanner#172?

@AlisskaPie
Copy link
Contributor Author

@AlisskaPie can we close this in favor of googleapis/python-spanner#172?

Yes, sure! Sorry I forgot about it.
Thanks!

@AlisskaPie AlisskaPie closed this Dec 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: spanner Issues related to the googleapis/python-spanner-django API. cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants