GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Removal of unnecessary API calls + cleanup by mf2199 · Pull Request #20 · MaxxleLLC/python-spanner-django

Conversation

@mf2199

@mf2199 mf2199 commented Oct 21, 2020 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Collaborator

The connection.connect() method uses two .exists() checks for the instance and database objects, which create a 2-API call overhead. When given some invalid parameters, the errors will be caught down the line anyway, hence no reason to make them up front by default.

Also, a piece of a commented legacy code from parse_utils.py has been removed. The code seems to have contained error and was already replaced by a fixed version in earlier commits.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
mf2199 added 2 commits October 20, 2020 21:10
@mf2199
fix: removed some non-essential API calls
1212f46
@mf2199
chore: cleanup in parse_utils.py
cbcf6e4
@mf2199
mf2199 requested review from AlisskaPie, IlyaFaer and tina80lvl October 21, 2020 01:20
IlyaFaer
IlyaFaer reviewed Oct 21, 2020
View reviewed changes
Comment thread google/cloud/spanner_dbapi/connection.py

database = instance.database(database_id, pool=spanner.pool.BurstyPool())
if not database.exists():
raise ValueError("database '%s' does not exist." % database_id)

@IlyaFaer IlyaFaer Oct 21, 2020

Copy link
Copy Markdown
Collaborator

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.

Can't say I like it. If we'll not check the existence here, a lot of objects (instance, database, session, transaction - with all of their state attributes) will be initialized before something will fail, so we'll still be using resources. And it'll fail with Google-specific error google.api_core.exceptions.NotFound. PEP 249 lists its own exceptions (and the Python default exceptions), which must be raised instead of those project-specific, so this NotFound error gonna be confusing.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@mf2199 mf2199 Oct 21, 2020 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Collaborator Author

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.

@IlyaFaer I recall having similar idea when working on Managed Backups, and the code owners' feedback was in favor of not making "optional" admin API calls unless required by the specification (this may have something to do with the billing and price reduction). I see nothing in PEP-249 that requires those checks, and the expected normal setup implies having both the instance and the database to exist a priori. Therefore the responsibility can be delegated to the user who is free to choose whether to run the checks or not - at their own expense.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@mf2199 mf2199 mentioned this pull request Oct 21, 2020
chore: unit test coverage and additional refactoring for spanner_dbapi googleapis/python-spanner-django#532
Merged
@mf2199
chore: cleanup
0456a32
@mf2199
mf2199 requested a review from c24t October 21, 2020 23:36
@mf2199 mf2199 closed this Nov 12, 2020
@IlyaFaer
IlyaFaer deleted the refactor-cleanup branch November 12, 2020 06:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@IlyaFaer IlyaFaer IlyaFaer left review comments
@AlisskaPie AlisskaPie Awaiting requested review from AlisskaPie
@tina80lvl tina80lvl Awaiting requested review from tina80lvl
@c24t c24t Awaiting requested review from c24t

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@mf2199 @IlyaFaer
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.