mirror of
https://github.com/GoogleCloudPlatform/vertex-ai-samples.git
synced 2026-09-26 14:42:04 +00:00
Added project to BQ client instantiation (#285)
This commit is contained in:
@@ -786,7 +786,7 @@
|
||||
" PROJECT_ID, batch_predict_bq_output_dataset_name\n",
|
||||
")\n",
|
||||
"# Must be the same region as batch_predict_bq_input_uri\n",
|
||||
"client = bigquery.Client()\n",
|
||||
"client = bigquery.Client(project=PROJECT_ID)\n",
|
||||
"bq_dataset = bigquery.Dataset(batch_predict_bq_output_dataset_path)\n",
|
||||
"dataset_region = \"US\" # @param {type : \"string\"}\n",
|
||||
"bq_dataset.location = dataset_region\n",
|
||||
|
||||
@@ -273,7 +273,7 @@
|
||||
"\n",
|
||||
"if not os.getenv(\"IS_TESTING\"):\n",
|
||||
" # Get your Google Cloud project ID from gcloud\n",
|
||||
" shell_output=!gcloud config list --format 'value(core.project)' 2>/dev/null\n",
|
||||
" shell_output = !gcloud config list --format 'value(core.project)' 2>/dev/null\n",
|
||||
" PROJECT_ID = shell_output[0]\n",
|
||||
" print(\"Project ID: \", PROJECT_ID)"
|
||||
]
|
||||
@@ -674,7 +674,7 @@
|
||||
"NA_VALUES = [\"NA\", \".\"]\n",
|
||||
"\n",
|
||||
"# Set up BigQuery clients\n",
|
||||
"bqclient = bigquery.Client()\n",
|
||||
"bqclient = bigquery.Client(project=PROJECT_ID)\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"# Download a table\n",
|
||||
|
||||
@@ -657,7 +657,7 @@
|
||||
"def get_dataframe(bq_table: str, output_data_path: OutputPath(\"Dataset\")):\n",
|
||||
" from google.cloud import bigquery\n",
|
||||
"\n",
|
||||
" bqclient = bigquery.Client()\n",
|
||||
" bqclient = bigquery.Client(project=PROJECT_ID)\n",
|
||||
" table = bigquery.TableReference.from_string(bq_table)\n",
|
||||
" rows = bqclient.list_rows(table)\n",
|
||||
" dataframe = rows.to_dataframe(\n",
|
||||
|
||||
@@ -309,7 +309,7 @@
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"PROJECT_ID = \"[your-project-id]\" # @param {type:\"string\"}"
|
||||
"PROJECT_ID = \"python-docs-samples-tests\" # @param {type:\"string\"}"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -320,7 +320,7 @@
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"if PROJECT_ID == \"\" or PROJECT_ID is None or PROJECT_ID == \"[your-project-id]\":\n",
|
||||
"if PROJECT_ID == \"\" or PROJECT_ID is None or PROJECT_ID == \"python-docs-samples-tests\":\n",
|
||||
" # Get your GCP project id from gcloud\n",
|
||||
" shell_output = ! gcloud config list --format 'value(core.project)' 2>/dev/null\n",
|
||||
" PROJECT_ID = shell_output[0]\n",
|
||||
|
||||
Reference in New Issue
Block a user