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 — #260: break datastore cycles via factories by tseaver · Pull Request #268 · googleapis/google-cloud-python

Conversation

@tseaver

@tseaver tseaver commented Oct 20, 2014

Copy link
Copy Markdown
Contributor

My take on breaking the import cycles in 'gcloud.datastore' by adding a "factory registry" for the classes normally imported.

Note that some classes have more than one factory (class methods like'from_protobuf' and 'from_path'): each is registered under a separate name.

Also drops 'Dataset.query' and 'Dataset.entity' convenience APIs, pointing instead to constructing Query and Entity directly.

Addresses #260 (for 'gcloud.datastore').

Sorry, something went wrong.

Uh oh!

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

All reactions
@tseaver tseaver added api: datastore Issues related to the Datastore API. hygiene labels Oct 20, 2014
dhermes
dhermes reviewed Oct 20, 2014
View reviewed changes
Comment thread gcloud/datastore/__init__.py Outdated

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

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

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

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

@tseaver tseaver mentioned this pull request Oct 20, 2014
Disentangle import cycles #260
Closed
@coveralls

coveralls commented Oct 20, 2014

Copy link
Copy Markdown

Coverage Status

Coverage remained the same when pulling 6a77c1a on tseaver:260-break_datastore_cycles_via_factories into 99e4d53 on GoogleCloudPlatform:master.

All reactions

Sorry, something went wrong.

Uh oh!

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

@coveralls

coveralls commented Oct 20, 2014

Copy link
Copy Markdown

Coverage Status

Coverage remained the same when pulling 6a77c1a on tseaver:260-break_datastore_cycles_via_factories into 99e4d53 on GoogleCloudPlatform:master.

All reactions

Sorry, something went wrong.

Uh oh!

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

dhermes
dhermes reviewed Oct 20, 2014
View reviewed changes
Comment thread gcloud/datastore/_helpers.py Outdated

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

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

@dhermes

dhermes commented Oct 20, 2014

Copy link
Copy Markdown
Contributor

I think this concept is a little too Pythonic.

In other words, cyclic imports are more desirable to me than a module global which is mutable.

Having _FACTORIES change at run time makes the codebase impossible to reason about statically as well.

All reactions

Sorry, something went wrong.

Uh oh!

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

@tseaver

tseaver commented Oct 20, 2014

Copy link
Copy Markdown
Contributor Author

@dhermes I don't agree about the "mutable global": modules themselves get mutated during import. Note that the _FACTORIES bit (originally _factories, until pylint's bitching made me changed it) gets changed only as the registering module is imported (except for tests). Cyclical imports are a sign of much worse muddiness than a simple, controlled registry.

All reactions

Sorry, something went wrong.

Uh oh!

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

@coveralls

coveralls commented Oct 20, 2014

Copy link
Copy Markdown

Coverage Status

Coverage remained the same when pulling cb2352f on tseaver:260-break_datastore_cycles_via_factories into 99e4d53 on GoogleCloudPlatform:master.

All reactions

Sorry, something went wrong.

Uh oh!

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

@dhermes

dhermes commented Oct 21, 2014

Copy link
Copy Markdown
Contributor

Potential compromise:

Can we add very clear docs to _helpers and give references to all the places we expect a class to be registered?

All reactions

Sorry, something went wrong.

Uh oh!

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

@dhermes

dhermes commented Oct 21, 2014

Copy link
Copy Markdown
Contributor

I also realized that the "run time" complaints are contradictory since a import inside a method/function happens at run time.

All reactions

Sorry, something went wrong.

Uh oh!

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

@tseaver

tseaver commented Oct 21, 2014

Copy link
Copy Markdown
Contributor Author

1305e81 encapsulates the registry as an object with 'register', 'get', and 'invoke' methods. It also ensures that the relevant modules get imported early (to ensure that the registry is populated).

All reactions

Sorry, something went wrong.

Uh oh!

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

@coveralls

coveralls commented Oct 21, 2014

Copy link
Copy Markdown

Coverage Status

Coverage remained the same when pulling 1305e81 on tseaver:260-break_datastore_cycles_via_factories into 99e4d53 on GoogleCloudPlatform:master.

All reactions

Sorry, something went wrong.

Uh oh!

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

dhermes
dhermes reviewed Oct 21, 2014
View reviewed changes
Comment thread gcloud/datastore/_helpers.py

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

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

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

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

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

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

@coveralls

coveralls commented Oct 21, 2014

Copy link
Copy Markdown

Coverage Status

Coverage remained the same when pulling fd9cd02 on tseaver:260-break_datastore_cycles_via_factories into 99e4d53 on GoogleCloudPlatform:master.

All reactions

Sorry, something went wrong.

Uh oh!

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

@coveralls

coveralls commented Oct 21, 2014

Copy link
Copy Markdown

Coverage Status

Coverage remained the same when pulling fd9cd02 on tseaver:260-break_datastore_cycles_via_factories into 99e4d53 on GoogleCloudPlatform:master.

All reactions

Sorry, something went wrong.

Uh oh!

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

@coveralls

coveralls commented Oct 22, 2014

Copy link
Copy Markdown

Coverage Status

Coverage remained the same when pulling ccc79fd on tseaver:260-break_datastore_cycles_via_factories into c2a38fb on GoogleCloudPlatform:master.

All reactions

Sorry, something went wrong.

Uh oh!

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

tseaver added 8 commits October 22, 2014 15:34
@tseaver
Drop 'Dataset.query' and 'Dataset.entity' convenience APIs.
1036f85
Point instead to constructing Query and Entity directly.

Addresses #260, but only partially, for gcloud.datastore.
@tseaver
Add a factory registry to datastore._helpers.
1c432a9
Work toward breaking cycles based on import-for-construction.
@tseaver
Break import cycles via a factory registry.
8d05122
Note that some classes have more than one factory (class methodsd like
'from_protobuf' and 'from_path').  Each is registered under a separate name.

Addresses #260 (for gcloud.datastore).
@tseaver
Tidy local imports, remove remaining cycles.
3c1d516
@tseaver
Fix build: invoke correct factory when unmarshalling key from pb.
cf29c90
@tseaver
Reorder 'Query.__init__' paramters to match Entity.
31f60d8
@tseaver
Rename '_query_factory' helper -> '_get_factory' to avoid confustion.
3a62db9
Incorporates feedback from @dhermees.
@tseaver
Avoid relative imports.
daf889c
Incorporate feedback from @dhermes.
parthea pushed a commit that referenced this pull request Sep 22, 2023
@gcf-owl-bot
build: switch to release-please for tagging (#268)
ed5ed6d
parthea pushed a commit that referenced this pull request Sep 22, 2023
@SurferJeffAtGoogle
chore: relocate owl bot post processor (#268)
87db1f9
chore: relocate owl bot post processor
parthea pushed a commit that referenced this pull request Sep 22, 2023
@gcf-owl-bot
build: use trampoline_v2 for python samples and allow custom dockerfi…
77b2bf3
…le (#268)

Source-Link: googleapis/synthtool@a7ed11e
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:6e7328583be8edd3ba8f35311c76a1ecbc823010279ccb6ab46b7a76e25eafcc

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
parthea added a commit that referenced this pull request Sep 22, 2023
@gcf-owl-bot @parthea
chore: Update gapic-generator-python to v1.8.5 (#268)
5d640c6
* chore: Update gapic-generator-python to v1.8.5

PiperOrigin-RevId: 511892190

Source-Link: googleapis/googleapis@a45d9c0

Source-Link: googleapis/googleapis-gen@1907294
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMTkwNzI5NGIxZDgzNjVlYTI0ZjhjNWYyZTA1OWE2NDEyNGM0ZWQzYiJ9

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

---------

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: Anthonios Partheniou <[email protected]>
parthea added a commit that referenced this pull request Sep 22, 2023
@parthea
fix(deps): allow protobuf < 5.0.0 (#268)
e2d77e0
fix(deps): require proto-plus >= 1.22.0
parthea pushed a commit that referenced this pull request Sep 22, 2023
@gcf-owl-bot
feat: add api key support (#268)
9d9d620
* chore: upgrade gapic-generator-java, gax-java and gapic-generator-python

PiperOrigin-RevId: 423842556

Source-Link: googleapis/googleapis@a616ca0

Source-Link: googleapis/googleapis-gen@29b938c
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMjliOTM4YzU4YzFlNTFkMDE5ZjJlZTUzOWQ1NWRjMGEzYzg2YTkwNSJ9

* 🦉 Updates from OwlBot

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
parthea pushed a commit that referenced this pull request Oct 21, 2023
@renovate-bot
chore(deps): update dependency google-cloud-resource-manager to v1.1.0 (
51bb6f9
#268)
parthea pushed a commit that referenced this pull request Oct 21, 2023
@gcf-owl-bot
chore(python): use ubuntu 22.04 in docs image (#268)
50ecbaf
Source-Link: googleapis/synthtool@f15cc72
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:bc5eed3804aec2f05fad42aacf973821d9500c174015341f721a984a0825b6fd
parthea pushed a commit that referenced this pull request Oct 21, 2023
@gcf-owl-bot
chore(python): refactor unit / system test dependency install (#268)
6502337
Source-Link: googleapis/synthtool@993985f
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:1894490910e891a385484514b22eb5133578897eb5b3c380e6d8ad475c6647cd
parthea added a commit that referenced this pull request Oct 21, 2023
@gcf-owl-bot @parthea
ci(python): run lint / unit tests / docs as GH actions (#268)
c3b3ca6
* ci(python): run lint / unit tests / docs as GH actions

Source-Link: googleapis/synthtool@57be0cd
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:ed1f9983d5a935a89fe8085e8bb97d94e41015252c5b6c9771257cf8624367e6

* add commit to trigger gh actions

* work around template bug

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: Anthonios Partheniou <[email protected]>
parthea pushed a commit that referenced this pull request Oct 21, 2023
@release-please
chore: release 3.5.0 (#268)
e480db3
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
parthea pushed a commit that referenced this pull request Oct 21, 2023
@renovate-bot
chore(deps): update dependency google-analytics-admin to v0.11.0 (#268)
c755066
parthea pushed a commit that referenced this pull request Oct 21, 2023
Ace Nassri
chore(quickstart): clarify private pools instructions (#268)
c575a48
parthea pushed a commit that referenced this pull request Oct 22, 2023
@gcf-owl-bot
build(deps): bump cryptography to 41.0.0 [autoapprove] (#268)
f215f88
Source-Link: https://togithub.com/googleapis/synthtool/commit/d0f51a0c2a9a6bcca86911eabea9e484baadf64b
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:240b5bcc2bafd450912d2da2be15e62bc6de2cf839823ae4bf94d4f392b451dc
parthea pushed a commit that referenced this pull request Oct 22, 2023
@gcf-owl-bot
feat: add context manager support in client (#268)
243d8db
- [ ] Regenerate this pull request now.

chore: fix docstring for first attribute of protos

committer: @busunkim96
PiperOrigin-RevId: 401271153

Source-Link: googleapis/googleapis@787f8c9

Source-Link: googleapis/googleapis-gen@81decff
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiODFkZWNmZmU5ZmM3MjM5NmE4MTUzZTc1NmQxZDY3YTZlZWNmZDYyMCJ9
parthea pushed a commit that referenced this pull request Oct 22, 2023
@gcf-owl-bot
chore: detect samples tests in nested directories (#268)
b4bee60
Source-Link: googleapis/synthtool@50db768
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:e09366bdf0fd9c8976592988390b24d53583dd9f002d476934da43725adbb978
parthea pushed a commit that referenced this pull request Oct 31, 2023
@gcf-owl-bot
build: [autoapprove] bump cryptography from 41.0.2 to 41.0.3 (#268)
d848765
Source-Link: https://togithub.com/googleapis/synthtool/commit/352b9d4c068ce7c05908172af128b294073bf53c
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:3e3800bb100af5d7f9e810d48212b37812c1856d20ffeafb99ebe66461b61fc7
parthea added a commit that referenced this pull request Dec 20, 2024
@parthea
chore: add generation of pb2 files via owlbot/bazel (#268)
4dc815b
* chore: remove pb2 file generation during post processing

* fix: remove obsolete proto files
parthea pushed a commit that referenced this pull request Aug 21, 2025
@tswast
chore: remove unused samples (#268)
d52a0b9
Follow-up to googleapis/python-bigquery-storage#225

I noticed we didn't need several of these samples now that BQ Storage API is used by default.
parthea pushed a commit that referenced this pull request Sep 16, 2025
@tswast @parthea
chore: remove unused samples (#268)
cf7d2cb
Follow-up to googleapis/python-bigquery-storage#225

I noticed we didn't need several of these samples now that BQ Storage API is used by default.
parthea pushed a commit that referenced this pull request Nov 24, 2025
@gcf-owl-bot
build(deps): bump cryptography from 41.0.6 to 42.0.0 in /synthtool/gc…
0ecf7e1
…p/templates/python_library/.kokoro (#268)

Source-Link: googleapis/synthtool@e13b22b
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:97b671488ad548ef783a452a9e1276ac10f144d5ae56d98cc4bf77ba504082b4

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
parthea pushed a commit that referenced this pull request Nov 24, 2025
@gcf-owl-bot
chore: fix prerelease_deps nox session [autoapprove] (#268)
231dce4
Source-Link: https://togithub.com/googleapis/synthtool/commit/26c7505b2f76981ec1707b851e1595c8c06e90fc
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:f946c75373c2b0040e8e318c5e85d0cf46bc6e61d0a01f3ef94d8de974ac6790
parthea pushed a commit that referenced this pull request Nov 24, 2025
@release-please
chore: release 1.19.6 (#268)
ee60553
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
parthea pushed a commit that referenced this pull request Nov 24, 2025
@gcf-owl-bot
build: update actions/checkout and actions/setup-python (#268)
b414525
Source-Link: googleapis/synthtool@3551acd
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:230f7fe8a0d2ed81a519cfc15c6bb11c5b46b9fb449b8b1219b3771bcb520ad2

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
parthea pushed a commit that referenced this pull request Nov 24, 2025
@holtskinner
fix: Changed client_info import and added new quickstart samples (#268
d8aadc4
)

* fix: Changed `client_info` import

`google.api_core.client_info` -> `google.api_core.gapic_v1.client_info`

* Add examples for all document initialization options (w/tests)

Fixes #266
parthea pushed a commit that referenced this pull request Nov 26, 2025
@felixonmars @tseaver
Fix some typos in test_urllib3.py (#268)
0c61531
parthea pushed a commit that referenced this pull request Mar 2, 2026
@danielbankhead
chore: Update CODEOWNERS for @googleapis/cloud-storage-dpe (#268)
0f9628e
parthea pushed a commit that referenced this pull request Mar 6, 2026
@odeke-em
django: add DatabaseOperations.max_name_length()
7b2eda8
While the test was disabled for tables that didn't
declare `max_name_length()`, this change adds the
limit imposed at
https://cloud.google.com/spanner/quotas#tables

Fixes #268
parthea pushed a commit that referenced this pull request Mar 9, 2026
@renovate-bot
chore(deps): update dependency google-api-core to v2.10.2 (#268)
fb9fd89
parthea pushed a commit that referenced this pull request Mar 9, 2026
@dandhlee
fix: remove inheritance details (#268)
1ac4a21
* fix: remove inheritance details

* test: update goldens
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

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

Assignees

No one assigned

Labels

api: datastore Issues related to the Datastore API. do not merge Indicates a pull request not ready for merge, due to either quality or timing.

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.

3 participants

@tseaver @coveralls @dhermes
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.