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

Mutating '__module__' of proto-generated messages considered harmful #4715

Closed
tseaver opened this issue Jan 8, 2018 · 2 comments
Closed
Assignees
Labels
api: bigquerydatatransfer Issues related to the BigQuery Data Transfer Service API. api: cloudtrace Issues related to the Cloud Trace API. api: container Issues related to the Kubernetes Engine API API. api: dataproc Issues related to the Dataproc API. api: datastore Issues related to the Datastore API. api: firestore Issues related to the Firestore API. api: language Issues related to the Cloud Natural Language API API. api: pubsub Issues related to the Pub/Sub API. api: spanner Issues related to the Spanner API. api: speech Issues related to the Speech-to-Text API. api: videointelligence Issues related to the Video Intelligence API API. api: vision Issues related to the Cloud Vision API. triaged for GA type: question Request for information or clarification. Not an issue.

Comments

@tseaver
Copy link
Contributor

tseaver commented Jan 8, 2018

From #4695 (comment):

I wrote:

I still cannot see how it is correct to scribble on the message objects defined outside spanner: it hides the actual source location, and worse, is likely to get stomped on by every one of our modules which uses it.

E.g.:

>>> from google.longrunning import operations_pb2
>>> operations_pb2.CancelOperationRequest.__module__
'google.longrunning.operations_pb2'
>>> import google.cloud.spanner_admin_instance_v1.types
>>> operations_pb2.CancelOperationRequest.__module__
'google.cloud.spanner_admin_instance_v1.types'
>>> import google.cloud.spanner_admin_database_v1.types
>>> operations_pb2.CancelOperationRequest.__module__
'google.cloud.spanner_admin_database_v1.types'
>>> import google.cloud.language_v1beta2.types
>>> operations_pb2.CancelOperationRequest.__module__
'google.cloud.language_v1beta2.types'

@dhermes responded:

I am with @tseaver here.

@lukesneeringer responded:

I agree that this is a problem in theory. I am less convinced that it is a problem in practice.

The key problem that this solves is with documentation: There is no good way (as far as I can tell) to tell Sphinx to present the message objects at a sane location other than doing what I did.

I am all for an alternative method that gets a similar result. Essentially what I want is:

  • The message classes must be documented, and presented as part of the overall package.
  • The documentation should not make the user think about _pb2 junk.
  • Users should not have to think about the internal proto sorting.

Basically, if there is some good way to have Sphinx present the modules in the location where we want to teach users to import them from, then I am completely fine with doing that in favor of what I have now.

(I am also fine with being told that my goals above should be non-goals, with supporting argumentation of course.)

I replied:

Until we are generating Sphinx docs from post-repo-split world, given the "last one wins" import race I demonstrated above, I don't believe your current solution actually means what you think it means. The messages will be generated with whatever module happened to be imported last as their faux location.

The documentation should not make the user think about _pb2 junk.

I would argue that this goal is the source of the breakage, and should be removed. For instance, users who look at docs for stdlib modules are not confused by references to top-level imports from other modules. Knowing that the message comes from proto-generated code (and which proto to examine, if need be) is actually claritying, IMNSHO.

Even if we agreed that hiding the _pb2 was a good thing for messages defined inside e.g., google.cloud.spanner, it cannot be the Right Thing (TM) to pretend that stuff like LRO, Empty, etc. are defined there.

@tseaver tseaver added api: bigquerydatatransfer Issues related to the BigQuery Data Transfer Service API. api: container Issues related to the Kubernetes Engine API API. api: dataproc Issues related to the Dataproc API. api: datastore Issues related to the Datastore API. api: firestore Issues related to the Firestore API. api: language Issues related to the Cloud Natural Language API API. api: pubsub Issues related to the Pub/Sub API. api: spanner Issues related to the Spanner API. api: speech Issues related to the Speech-to-Text API. api: cloudtrace Issues related to the Cloud Trace API. api: videointelligence Issues related to the Video Intelligence API API. api: vision Issues related to the Cloud Vision API. documentation type: cleanup An internal cleanup or hygiene concern. labels Jan 8, 2018
@tseaver tseaver added type: question Request for information or clarification. Not an issue. and removed type: cleanup An internal cleanup or hygiene concern. labels Jan 8, 2018
@theacodes
Copy link
Contributor

theacodes commented Jan 9, 2018

We can likely resolve this using a sphinx plugin. :)

tseaver added a commit that referenced this issue May 22, 2018
Note that we *are* still overwriting it for messages from modules defined
within the current package.

See #4715.
@tseaver
Copy link
Contributor Author

tseaver commented May 22, 2018

I'm still dubious about hiding the actual source module for "local" messages, but that ship is likely sailed.

@tseaver tseaver closed this as completed May 22, 2018
atulep pushed a commit that referenced this issue Apr 3, 2023
Note that we *are* still overwriting it for messages from modules defined
within the current package.

See #4715.
atulep pushed a commit that referenced this issue Apr 18, 2023
Note that we *are* still overwriting it for messages from modules defined
within the current package.

See #4715.
parthea pushed a commit that referenced this issue Jun 4, 2023
Note that we *are* still overwriting it for messages from modules defined
within the current package.

See #4715.
parthea pushed a commit that referenced this issue Jun 4, 2023
Note that we *are* still overwriting it for messages from modules defined
within the current package.

See #4715.
parthea pushed a commit that referenced this issue Jul 6, 2023
Note that we *are* still overwriting it for messages from modules defined
within the current package.

See #4715.
parthea pushed a commit that referenced this issue Sep 22, 2023
Note that we *are* still overwriting it for messages from modules defined
within the current package.

See #4715.
parthea pushed a commit that referenced this issue Sep 22, 2023
Note that we *are* still overwriting it for messages from modules defined
within the current package.

See #4715.
parthea pushed a commit that referenced this issue Sep 22, 2023
Note that we *are* still overwriting it for messages from modules defined
within the current package.

See #4715.
parthea pushed a commit that referenced this issue Sep 22, 2023
Note that we *are* still overwriting it for messages from modules defined
within the current package.

See #4715.
parthea pushed a commit that referenced this issue Sep 22, 2023
Note that we *are* still overwriting it for messages from modules defined
within the current package.

See #4715.
parthea pushed a commit that referenced this issue Sep 22, 2023
Note that we *are* still overwriting it for messages from modules defined
within the current package.

See #4715.
parthea pushed a commit that referenced this issue Sep 22, 2023
Note that we *are* still overwriting it for messages from modules defined
within the current package.

See #4715.
parthea pushed a commit that referenced this issue Oct 21, 2023
Note that we *are* still overwriting it for messages from modules defined
within the current package.

See #4715.
parthea pushed a commit that referenced this issue Oct 21, 2023
Note that we *are* still overwriting it for messages from modules defined
within the current package.

See #4715.
parthea pushed a commit that referenced this issue Oct 22, 2023
Note that we *are* still overwriting it for messages from modules defined
within the current package.

See #4715.
parthea pushed a commit that referenced this issue Oct 22, 2023
Note that we *are* still overwriting it for messages from modules defined
within the current package.

See #4715.
parthea pushed a commit that referenced this issue Oct 31, 2023
Note that we *are* still overwriting it for messages from modules defined
within the current package.

See #4715.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: bigquerydatatransfer Issues related to the BigQuery Data Transfer Service API. api: cloudtrace Issues related to the Cloud Trace API. api: container Issues related to the Kubernetes Engine API API. api: dataproc Issues related to the Dataproc API. api: datastore Issues related to the Datastore API. api: firestore Issues related to the Firestore API. api: language Issues related to the Cloud Natural Language API API. api: pubsub Issues related to the Pub/Sub API. api: spanner Issues related to the Spanner API. api: speech Issues related to the Speech-to-Text API. api: videointelligence Issues related to the Video Intelligence API API. api: vision Issues related to the Cloud Vision API. triaged for GA type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

No branches or pull requests

6 participants