You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
set_default_project living inside each service module is confusing #838
If that's not the case, we need to figure out some other way of doing this... maybe moving the helper method into the top level as gcloud.set_default_project()...
@jgeewax It seems you're just concerned with the fact that the method lives in each sub-package?
We discussed the idea of a library-wide default project with you at a standup meeting and you signed off on it. (@tseavernoted this immediately after.)
The method is only defined in one place gcloud._helpers but it is imported as a public method (i.e. no import ... as rename) in both storage.__init__ and pubsub.__init__.
This is so that we can call it from set_defaults() in each of those packages.
An easy (partial) way to address your concern will just be
because the value 'proj1' will become the global (not just pubsub only) default. A "wrong global" would not be that big an issue for storage since the project is seldom used. It would be a huge issue for pubsub since a project is sent in every request.
3. We could address the above point by either removing project= from set_defaults or by making the default project local to each sub-package.
You're correct in the case of (2) -- we expose the method under each service, but it's not specific to the service. That's pretty confusing to me -- I'd expect a separate default for the service in which I called the method...
Option 4 might be to have a gcloud.get_default_project() and then service specific ones that override the global one... But that's getting pretty tricky...
We don't have any cross-package objects / data other than the project string. The connections in each sub-package are only able to talk to their own service.
"make project specific to a connection" makes sense for pubsub but not for storage. In storage only 2 out of 34 API requests use the project.
I was a fan of having the default project by package specific, but @tseaver was more enthusiastic about having it be a global than I was about having it be package specific. I can be persuaded either way.
Activity
dhermes commentedon Apr 17, 2015
@jgeewax It seems you're just concerned with the fact that the method lives in each sub-package?
We discussed the idea of a library-wide default project with you at a standup meeting and you signed off on it. (@tseaver noted this immediately after.)
The method is only defined in one place
gcloud._helpersbut it is imported as a public method (i.e. noimport ... asrename) in bothstorage.__init__andpubsub.__init__.This is so that we can call it from
set_defaults()in each of those packages.because the value
'proj1'will become the global (not justpubsubonly) default. A "wrong global" would not be that big an issue forstoragesince the project is seldom used. It would be a huge issue forpubsubsince a project is sent in every request.3. We could address the above point by either removing
project=fromset_defaultsor by making the default project local to each sub-package.jgeewax commentedon Apr 17, 2015
You're correct in the case of (2) -- we expose the method under each service, but it's not specific to the service. That's pretty confusing to me -- I'd expect a separate default for the service in which I called the method...
Option 4 might be to have a gcloud.get_default_project() and then service specific ones that override the global one... But that's getting pretty tricky...
dhermes commentedon Apr 17, 2015
Yeah I had thought of Option 4. It would be a lot of code for a non-crucial feature.
jgeewax commentedon Apr 29, 2015
This is correct.
This brings about a further issue that I'm curious about:
What is the default connection used when talking to Pub Sub here? I think it's conn1 (even though I set the "pubsub connection" to be
conn2)...So:
set_defaultsas separate methods inside each module?If we had the defaults pulled out:
Assigning back to you to take a look :)
dhermes commentedon Apr 29, 2015
We don't have any cross-package objects / data other than the project string. The connections in each sub-package are only able to talk to their own service.
jgeewax commentedon Apr 29, 2015
Yep, so
pubsub.set_defaults()does the exact same thing asstorage.set_defaults()... Is there a reason for that? Legacy?dhermes commentedon Apr 29, 2015
No. They both set a global project (which I am uneasy with and is the point of this) but the connection is only package specific.
The interface is the same but the internals are different.
jgeewax commentedon Apr 29, 2015
OK so the connection is package specific... Totally misread.
So, Option 3 above has two pieces:
project=from the defaultsDo you have a preference?
dhermes commentedon Apr 29, 2015
"make project specific to a connection" makes sense for
pubsubbut not forstorage. In storage only 2 out of 34 API requests use the project.I was a fan of having the default project by package specific, but @tseaver was more enthusiastic about having it be a global than I was about having it be package specific. I can be persuaded either way.
dhermes commentedon Aug 27, 2015
This is moot in the presence of client pattern
3 remaining items
Fix: Add response object to any append rows requests exception (#838)
Fix: Add response object to any append rows requests exception (#838)
fix: `to_gbq` uses `default_type` for ambiguous array types and struc…
chore: use trim_blocks and lstrip_blocks for jinja templates (#838)
chore(main): release 2.25.2 (#838)
chore: Revert autogenerated changes which have not been released (#838)
docs(CONTRIBUTING): Note the need for Redis/Memcached env vars in tes…
test: address comments for downscoping tests (#838)
chore(python): add support for python 3.11 [autoapprove] (#838)
chore(deps): update dependency google-cloud-bigquery to v2.23.2 (#838)
chore: [autoapprove] Update `black` and `isort` to latest versions (#838
chore(deps): update opentelemetry-python monorepo to v1.40.0 (#838)
chore(main): release 2.6.0 (#838)
feat: support requiest options in !autocommit mode (#838)
docs: migrate code from googleapis/python-bigquery (#18303)