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 #172

Merged
merged 16 commits into from Dec 30, 2020
Merged

Conversation

AlisskaPie
Copy link
Contributor

@AlisskaPie AlisskaPie commented Nov 19, 2020

These changes have been moved from python-spanner-django PR.

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

snippet-bot bot commented Nov 19, 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 or use the checkbox below:

  • Refresh this comment

@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Nov 19, 2020
@product-auto-label product-auto-label bot added the samples Issues that are directly related to samples. label Nov 19, 2020
@IlyaFaer
Copy link
Contributor

I see an error ModuleNotFoundError: No module named sqlparse here. We already have two PRs with adding this dependency:
https://github.com/googleapis/python-spanner/pull/171/files
https://github.com/googleapis/python-spanner/pull/168/files

@c24t
Copy link
Contributor

c24t commented Nov 24, 2020

Looks like I gave you some bad info in googleapis/python-spanner-django#552 (comment), making samples a package causes import errors for other sample modules:

________________ ERROR collecting samples/samples/backup_sample_test.py _______________
ImportError while importing test module 'src/python-spanner/samples/samples/backup_sample_test.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
.pyenv/versions/3.8.2/lib/python3.8/importlib/__init__.py:127: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
backup_sample_test.py:21: in <module>
    import backup_sample
E   ModuleNotFoundError: No module named 'backup_sample'
__________________ ERROR collecting samples/samples/quickstart_test.py _______________
ImportError while importing test module 'src/python-spanner/samples/samples/quickstart_test.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
.pyenv/versions/3.8.2/lib/python3.8/importlib/__init__.py:127: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
quickstart_test.py:21: in <module>
    import quickstart
E   ModuleNotFoundError: No module named 'quickstart'
___________________ ERROR collecting samples/samples/snippets_test.py _______________
ImportError while importing test module 'src/python-spanner/samples/samples/snippets_test.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
.pyenv/versions/3.8.2/lib/python3.8/importlib/__init__.py:127: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
snippets_test.py:21: in <module>
    import snippets
E   ModuleNotFoundError: No module named 'snippets'

Should be fixed now.

@AlisskaPie
Copy link
Contributor Author

Looks like I gave you some bad info in googleapis/python-spanner-django#552 (comment), making samples a package causes import errors for other sample modules:
...
Should be fixed now.

Thanks for commiting code! Errors in importing other sample modules have disappeared.

@AlisskaPie AlisskaPie marked this pull request as ready for review November 25, 2020 13:34
@AlisskaPie AlisskaPie requested review from a team as code owners November 25, 2020 13:34
Copy link
Contributor

@larkee larkee left a comment

Choose a reason for hiding this comment

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

Mostly LGTM, just the one concern

print("Autocommit mode is enabled.")

cursor = connection.cursor()
cursor._checksum = ResultsChecksum()
Copy link
Contributor

Choose a reason for hiding this comment

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

Why does the user need to initialise a private variable? Can this not be initialised as part of the cursor factory?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for the review! And sorry for the delayed answer.
I've made an update and placed this part in the test.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is not quite what I meant. The sample now looks as I would expect but I'm unclear as to why you still need to set cursor._checksum in the test. Is there a reason that _checksum defaults to None? Could it be updated to ResultsChecksum() instead?

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.

Re: #172 (comment), it looks like the tests pass without setting cursor._checksum and I see you didn't need this line in googleapis/python-spanner-django#552. Any reason not to remove it here?

The other suggested changes are just formatting and liberating some imports.

As in googleapis/python-spanner-django#552 (review), I think the sample would be more useful if it showed the different behavior with autocommit on/off, but this sample looks fine to me otherwise. LGTM with my suggested changes.

samples/samples/autocommit_test.py Outdated Show resolved Hide resolved
samples/samples/autocommit_test.py Show resolved Hide resolved
samples/samples/autocommit_test.py Outdated Show resolved Hide resolved
samples/samples/autocommit_test.py Outdated Show resolved Hide resolved
c24t and others added 4 commits December 6, 2020 23:18
Co-authored-by: Chris Kleinknecht <libc@google.com>
Co-authored-by: Chris Kleinknecht <libc@google.com>
@google-cla
Copy link

google-cla bot commented Dec 9, 2020

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@google-cla google-cla bot added cla: no This human has *not* signed the Contributor License Agreement. and removed cla: yes This human has signed the Contributor License Agreement. labels Dec 9, 2020
@IlyaFaer
Copy link
Contributor

IlyaFaer commented Dec 9, 2020

@googlebot I consent.

@google-cla google-cla bot added cla: yes This human has signed the Contributor License Agreement. and removed cla: no This human has *not* signed the Contributor License Agreement. labels Dec 9, 2020
@IlyaFaer IlyaFaer added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Dec 9, 2020
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Dec 9, 2020
@IlyaFaer
Copy link
Contributor

One system test create_instance failed with 429 Project 1065521786570 cannot add 1 nodes in region us-central1. Doesn't seem to be related.

@c24t c24t added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Dec 10, 2020
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Dec 10, 2020
@IlyaFaer
Copy link
Contributor

Hm-m, it looks like this ResourceExhausted error became permanent. Maybe it'll be better to move DB API system tests to the original test_system.py file and use one instance for all of the system tests?

@larkee
Copy link
Contributor

larkee commented Dec 11, 2020

Hm-m, it looks like this ResourceExhausted error became permanent. Maybe it'll be better to move DB API system tests to the original test_system.py file and use one instance for all of the system tests?

The issue is test instances failing to be deleted for some runs. Manually deleting instances from the test project can resolve this temporarily. For a more long term solution, see #190

@larkee larkee added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Dec 11, 2020
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Dec 11, 2020
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, let's get a green system test build.

@larkee larkee merged commit 4ef793c into googleapis:master Dec 30, 2020
@IlyaFaer IlyaFaer deleted the autocommit_samples branch January 7, 2021 08:56
gcf-merge-on-green bot pushed a commit that referenced this pull request Jan 15, 2021
🤖 I have created a release \*beep\* \*boop\* 
---
## [3.0.0](https://www.github.com/googleapis/python-spanner/compare/v2.1.0...v3.0.0) (2021-01-15)


### ⚠ BREAKING CHANGES

* convert operations pbs into Operation objects when listing operations (#186)

### Features

* add support for instance labels ([#193](https://www.github.com/googleapis/python-spanner/issues/193)) ([ed462b5](https://www.github.com/googleapis/python-spanner/commit/ed462b567a1a33f9105ffb37ba1218f379603614))
* add support for ssl credentials; add throttled field to UpdateDatabaseDdlMetadata ([#161](https://www.github.com/googleapis/python-spanner/issues/161)) ([2faf01b](https://www.github.com/googleapis/python-spanner/commit/2faf01b135360586ef27c66976646593fd85fd1e))
* adding missing docstrings for functions & classes  ([#188](https://www.github.com/googleapis/python-spanner/issues/188)) ([9788cf8](https://www.github.com/googleapis/python-spanner/commit/9788cf8678d882bd4ccf551f828050cbbb8c8f3a))
* autocommit sample ([#172](https://www.github.com/googleapis/python-spanner/issues/172)) ([4ef793c](https://www.github.com/googleapis/python-spanner/commit/4ef793c9cd5d6dec6e92faf159665e11d63762ad))


### Bug Fixes

* convert operations pbs into Operation objects when listing operations ([#186](https://www.github.com/googleapis/python-spanner/issues/186)) ([ed7152a](https://www.github.com/googleapis/python-spanner/commit/ed7152adc37290c63e59865265f36c593d9b8da3))
* Convert PBs in system test cleanup ([#199](https://www.github.com/googleapis/python-spanner/issues/199)) ([ede4343](https://www.github.com/googleapis/python-spanner/commit/ede4343e518780a4ab13ae83017480d7046464d6))
* **dbapi:** autocommit enabling fails if no transactions begun ([#177](https://www.github.com/googleapis/python-spanner/issues/177)) ([e981adb](https://www.github.com/googleapis/python-spanner/commit/e981adb3157bb06e4cb466ca81d74d85da976754))
* **dbapi:** executemany() hiding all the results except the last ([#181](https://www.github.com/googleapis/python-spanner/issues/181)) ([020dc17](https://www.github.com/googleapis/python-spanner/commit/020dc17c823dfb65bfaacace14d2c9f491c97e11))
* **dbapi:** Spanner protobuf changes causes KeyError's ([#206](https://www.github.com/googleapis/python-spanner/issues/206)) ([f1e21ed](https://www.github.com/googleapis/python-spanner/commit/f1e21edbf37aab93615fd415d61f829d2574916b))
* remove client side gRPC receive limits ([#192](https://www.github.com/googleapis/python-spanner/issues/192)) ([90effc4](https://www.github.com/googleapis/python-spanner/commit/90effc4d0f4780b7a7c466169f9fc1e45dab8e7f))
* Rename to fix "Mismatched region tag" check ([#201](https://www.github.com/googleapis/python-spanner/issues/201)) ([c000ec4](https://www.github.com/googleapis/python-spanner/commit/c000ec4d9b306baa0d5e9ed95f23c0273d9adf32))


### Documentation

* homogenize region tags ([#194](https://www.github.com/googleapis/python-spanner/issues/194)) ([1501022](https://www.github.com/googleapis/python-spanner/commit/1501022239dfa8c20290ca0e0cf6a36e9255732c))
* homogenize region tags pt 2 ([#202](https://www.github.com/googleapis/python-spanner/issues/202)) ([87789c9](https://www.github.com/googleapis/python-spanner/commit/87789c939990794bfd91f5300bedc449fd74bd7e))
* update CHANGELOG breaking change comment ([#180](https://www.github.com/googleapis/python-spanner/issues/180)) ([c7b3b9e](https://www.github.com/googleapis/python-spanner/commit/c7b3b9e4be29a199618be9d9ffa1d63a9d0f8de7))
---


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
api: spanner Issues related to the googleapis/python-spanner 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

6 participants