I like to code directly in the GCP console editor to test some POCs, but with this approach you have to deal with some situations, such as, getting your shell and editor disconnected after a few minutes idle, then when you retake your coding and re running your python code to execute some bigquery statements, you can see a nasty error like this:
google.api_core.exceptions.BadRequest: 400 POST https://bigquery.googleapis.com/bigquery/v2/projects//jobs: Invalid project ID ''. Project IDs must contain 6-63 lowercase letters, digits, or dashes. Some project IDs also include domain name separated by a colon. IDs must start with a letter and may not end with a dash.
what happened?, you gcp shell was reseted and you lost your project connection, you can check that:
(venv) jcalfucura@cloudshell:~/crossprod$ gcloud config list --format 'value(core.project)' 2>/dev/null
returns nothing.
You can also use this statement:
(venv) jcalfucura@cloudshell:~/crossprod$ gcloud config get-value projectYour active configuration is: [cloudshell-12345]WARNING: The project property is set to the empty string, which is invalid.To set your project, run: $ gcloud config set project PROJECT_IDor to unset it, run: $ gcloud config unset project
So, the correct way is to bind your code with the project.
Comments
Post a Comment