Skip to content

Conversation

@tseaver
Copy link
Contributor

@tseaver tseaver commented Oct 20, 2014

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').

@tseaver tseaver added api: datastore Issues related to the Datastore API. hygiene labels Oct 20, 2014

This comment was marked as spam.

This comment was marked as spam.

@coveralls
Copy link

Coverage Status

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

@coveralls
Copy link

Coverage Status

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

This comment was marked as spam.

@dhermes
Copy link
Contributor

dhermes commented Oct 20, 2014

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.

@tseaver
Copy link
Contributor Author

tseaver commented Oct 20, 2014

@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.

@coveralls
Copy link

Coverage Status

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

@dhermes
Copy link
Contributor

dhermes commented Oct 21, 2014

Potential compromise:

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

@dhermes
Copy link
Contributor

dhermes commented Oct 21, 2014

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

@tseaver
Copy link
Contributor Author

tseaver commented Oct 21, 2014

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).

@coveralls
Copy link

Coverage Status

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

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

@coveralls
Copy link

Coverage Status

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

@coveralls
Copy link

Coverage Status

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

@coveralls
Copy link

Coverage Status

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

Point instead to constructing Query and Entity directly.

Addresses #260, but only partially, for gcloud.datastore.
Work toward breaking cycles based on import-for-construction.
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).
Incorporate feedback from @dhermes.
parthea added a commit that referenced this pull request Jun 4, 2023
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
Co-authored-by: Anthonios Partheniou <[email protected]>
parthea pushed a commit that referenced this pull request Aug 15, 2023
- [ ] Regenerate this pull request now.

docs: clarified wording around Cloud Storage usage

PiperOrigin-RevId: 433282831

Source-Link: googleapis/googleapis@0e87dc7

Source-Link: googleapis/googleapis-gen@1928631
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMTkyODYzMWYzZWU5MTQ4OGZlMDdiM2Q4MTg4YTUyZDEwODYyNDUzYSJ9
parthea pushed a commit that referenced this pull request Aug 15, 2023
* chore: Update gapic-generator-python to v1.8.4

PiperOrigin-RevId: 507808936

Source-Link: googleapis/googleapis@64cf849

Source-Link: googleapis/googleapis-gen@53c48ca
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNTNjNDhjYWMxNTNkM2IzN2YzZDJjMmRlYzQ4MzBjZmQ5MWVjNDE1MyJ9

* 🦉 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>
parthea pushed a commit that referenced this pull request Sep 22, 2023
chore: relocate owl bot post processor
parthea pushed a commit that referenced this pull request Sep 22, 2023
…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
* 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
fix(deps): require proto-plus >= 1.22.0
parthea pushed a commit that referenced this pull request Sep 22, 2023
* 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
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
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
* 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
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
parthea pushed a commit that referenced this pull request Oct 22, 2023
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
- [ ] 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
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
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
* 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
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
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
…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
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
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
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
)

* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

Development

Successfully merging this pull request may close these issues.

3 participants