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 — Impossible to set non-default storage project since 0.5.0 · Issue #832 · googleapis/google-cloud-python

Impossible to set non-default storage project since 0.5.0 #832

New issue
Copy link
New issue
Copy link
Closed
Closed
Impossible to set non-default storage project since 0.5.0#832
Copy link
Assignees
tseaver
Labels
api: storageIssues related to the Cloud Storage API.

Description

@mwitkow
mwitkow
opened on Apr 16, 2015
Issue body actions

The upgrade to 0.5.0 broke the public API without notes in the Release by removing storage.get_connection(project='foo') function.

Moreover, it seems that the Connection class no longer has a project parameter. Neither storage.get_bucket nor storage.lookup_bucket take project as a parameter. Curiously, you can override it in create_bucket and list_buckets.

The only way to set a project for these is through _helpers.set_default_project, which makes it incredibly hard to operate on buckets in multiple projects, since you need to set the default all the time, exposing yourself to race conditions in case of multithreading.

Can we put back the project into Connection? AFAIK the Connection's credentials only make sense for a given project anyway.

Activity

  1. dhermes commented on Apr 16, 2015

    @dhermes
    dhermes
    on Apr 16, 2015
    Contributor
    More actions

    @mwitkow-io Thanks a ton for filing this! It's really great to hear that

    1. We have users
    2. Our users are upgrading
    3. Our users care enough to reach out

    Sorry the release notes didn't clarify some of these things. That's on me.


    The storage.get_connection method was not removed, it just changed signature. It no longer takes a project and has no arguments: now it is just storage.get_connection(). The previous argument (the project) was removed because a project is no longer bound to a connection (as you mentioned).


    We removed project from Connection based on discussion with the API team in #726. A project is only relevant when creating a bucket or listing buckets, so it was overkill to have it bound to a connection since only 2 of the 34 possible API methods used it.


    RE: "makes it incredibly hard to operate on buckets in multiple projects", what is the issue you are experiencing? The bucket name (Bucket instance) and the credentials for your connection should be sufficient to operate differing buckets.

  2. mwitkow commented on Apr 16, 2015

    @mwitkow
    mwitkow
    on Apr 16, 2015
    Author
    More actions

    Well, I blame Github issues not being as nice as Buganizer ;)

    Where does Connection store the project name? The only thing it has access to in the credentials (e.g. in the json file) is the project id that prefixes the client_id or client_email of the service accounts.

    The Bucket also doesn't contain any metadata about the project itself if I can see correctly.

    Can you give me an example of how to use the new API against two separate projects (with separate credentials objects) and getting a Bucket handle for each so I can create/delete Blob by name?

  3. dhermes commented on Apr 16, 2015

    @dhermes
    dhermes
    on Apr 16, 2015
    Contributor
    More actions

    RE: "Where does Connection store the project name?" It doesn't. The project is not bound to the connection.

    RE: "The Bucket also doesn't contain any metadata about the project itself if I can see correctly." It doesn't need to. The bucket name is the only identifier needed.


    Here is an example (we are working on documenting and improving this, see #805 and #830):

    from gcloud.credentials import get_for_service_account_json
    from gcloud import datastore
    
    # Working on making this part easier / shorter
    creds1 = get_for_service_account_json('path/to/key1.json').create_scoped(
        datastore.SCOPE)
    conn1 = datastore.Connection(credentials=creds1)
    
    creds2 = get_for_service_account_json('path/to/key2.json').create_scoped(
        datastore.SCOPE)
    conn2 = datastore.Connection(credentials=creds2)
    
    bucket1 = storage.get_bucket('bucketname1', connection=conn1)
    bucket2 = storage.get_bucket('bucketname2', connection=conn2)
    
    bucket1.delete_blob('blob-name1.txt')
    bucket2.delete_blob('blob-name2.txt')
  4. tseaver commented on Apr 16, 2015

    @tseaver
    tseaver
    on Apr 16, 2015
    Contributor
    More actions

    @mwitkow-io bucket names are globally unique (not per-project), which means you don't need to know the project ID except when creating a new bucket, or listing buckets associated with a given project.

  5. mwitkow commented on Apr 17, 2015

    @mwitkow
    mwitkow
    on Apr 17, 2015
    Author
    More actions

    Oh, indeed. I completely forgot that buckets are globally identifiable.

  6. mwitkow commented on Apr 17, 2015

    @mwitkow
    mwitkow
    on Apr 17, 2015
    Author
    More actions

    Please feel free to close :) (I wish I could)

  7. tseaver
    closed this as completedon Apr 17, 2015
  8. dhermes commented on Apr 17, 2015

    @dhermes
    dhermes
    on Apr 17, 2015
    Contributor
    More actions

    @mwitkow-io I really appreciate the feedback! Please feel free to open more and let us know.

    I am particularly interested in the

    need to set the default all the time, exposing yourself to race conditions in case of multithreading.

    I'd love to hear more about your workload. We have better support for multithreading with our batches than we do for global defaults.

    I have a hunch that you'd rather be passing an explicit connection / dataset ID / project in a multithreaded environment, but again I'd love to hear how it's working in the wild.

  9. dhermes
    added
    api: storageIssues related to the Cloud Storage API.
    on Dec 31, 2015
  10. JustinBeckwith
    assigned
    tseaver
    on Feb 1, 2021
  11. parthea
    added a commit that references this issue on Jul 6, 2023

    Updates client library to version 0.23.0 [(#832)](GoogleCloudPlatform…

    c69e7e1
  12. parthea
    added a commit that references this issue on Aug 21, 2025

    build(deps): bump ipython from 7.31.1 to 8.10.0 in /samples/to_datafr…

    8a51783
  13. parthea
    added 2 commits that reference this issue on Sep 16, 2025

    build(deps): bump ipython from 7.31.1 to 8.10.0 in /samples/to_datafr…

    dbc0217

    fix!: `to_gbq` uploads `ArrowDtype(pa.timestamp(...)` without timezon…

    7689b4f
  14. parthea
    added 5 commits that reference this issue on Nov 22, 2025

    chore: Update gapic-generator-python to v1.11.4 (#832)

    519c006

    fixup: change the default state of the metadata bazel flag (#832)

    af8da44

    feat: provide and use Python version support check (#832)

    f442d1f

    chore(python): update release script dependencies (#832)

    69a5631

    chore: split systests into separate kokoro build (#833)

    592c4b8
  15. parthea
    added 3 commits that reference this issue on Mar 2, 2026

    fix: Drop usage of pkg_resources (#832)

    962f683

    test: retry getting rows after streaming them in `test_insert_rows_fr…

    036fbd3

    chore(deps): update dependency greenlet to v3.3.2 (#832)

    6eee2f7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @tseaver
    tseaver

Labels

api: storageIssues related to the Cloud Storage API.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    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.