Skip to content

Commit 8534340

Browse files
authored
Merge pull request #3 from tswast/b375472297-js-libraries
try to setup github actions to test workload identity federation
2 parents 6977d10 + 7d57305 commit 8534340

17 files changed

+322
-910
lines changed

.github/workflows/bigquery.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Simple workflow for deploying static content to GitHub Pages
2+
name: Run BigQuery snippets as a test
3+
4+
on:
5+
push:
6+
paths-ignore:
7+
- ".gitignore"
8+
branches:
9+
- main
10+
pull_request_target:
11+
types:
12+
- labeled
13+
14+
jobs:
15+
build:
16+
runs-on: ubuntu-latest
17+
if: github.event_name == 'push' || github.event.label.name == 'ci-run-cloud'
18+
19+
# Add "id-token" with the intended permissions.
20+
permissions:
21+
contents: 'read'
22+
# required for GCP workload identity federation
23+
id-token: 'write'
24+
25+
steps:
26+
- name: checkout
27+
uses: actions/checkout@v4
28+
if: github.event.label.name != 'ci-run-cloud'
29+
30+
- name: checkout
31+
if: github.event.label.name == 'ci-run-cloud'
32+
uses: actions/checkout@v4
33+
with:
34+
fetch-depth: 0
35+
ref: ${{ github.event.pull_request.head.sha }}
36+
37+
- name: Set up Python
38+
# This is the version of the action for setting up Python, not the Python version.
39+
uses: actions/setup-python@v5
40+
with:
41+
# Semantic version range syntax or exact version of a Python version
42+
python-version: '3.12'
43+
# Optional - x64 or x86 architecture, defaults to x64
44+
architecture: 'x64'
45+
46+
- uses: 'google-github-actions/auth@v2'
47+
with:
48+
project_id: 'friendliness-dev-demo'
49+
workload_identity_provider: 'projects/368174856750/locations/global/workloadIdentityPools/github/providers/code-snippets'
50+
51+
- name: Display Python version
52+
run: python -c "import sys; print(sys.version)"
53+
54+
- name: Install packages
55+
run: python -m pip install -r requirements.txt
56+
57+
- name: Test the notebook
58+
run: python -m jupyter nbconvert --to html --execute 2024/12-bigquery-utils/bigquery-utils.ipynb

2017/acl-weather/acl-weather.ipynb

Lines changed: 17 additions & 25 deletions
Large diffs are not rendered by default.
Lines changed: 243 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,243 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": 2,
6+
"metadata": {},
7+
"outputs": [],
8+
"source": [
9+
"%load_ext bigquery_magics"
10+
]
11+
},
12+
{
13+
"cell_type": "markdown",
14+
"metadata": {},
15+
"source": [
16+
"Try a query that doesn't require any additional libraries."
17+
]
18+
},
19+
{
20+
"cell_type": "code",
21+
"execution_count": 4,
22+
"metadata": {},
23+
"outputs": [
24+
{
25+
"data": {
26+
"application/vnd.jupyter.widget-view+json": {
27+
"model_id": "e44fc98d1439478482520de48f1e4b6c",
28+
"version_major": 2,
29+
"version_minor": 0
30+
},
31+
"text/plain": [
32+
"Query is running: 0%| |"
33+
]
34+
},
35+
"metadata": {},
36+
"output_type": "display_data"
37+
},
38+
{
39+
"data": {
40+
"application/vnd.jupyter.widget-view+json": {
41+
"model_id": "aa559ce9c11540af9b8a7f9c94138063",
42+
"version_major": 2,
43+
"version_minor": 0
44+
},
45+
"text/plain": [
46+
"Downloading: 0%| |"
47+
]
48+
},
49+
"metadata": {},
50+
"output_type": "display_data"
51+
},
52+
{
53+
"data": {
54+
"text/html": [
55+
"<div>\n",
56+
"<style scoped>\n",
57+
" .dataframe tbody tr th:only-of-type {\n",
58+
" vertical-align: middle;\n",
59+
" }\n",
60+
"\n",
61+
" .dataframe tbody tr th {\n",
62+
" vertical-align: top;\n",
63+
" }\n",
64+
"\n",
65+
" .dataframe thead th {\n",
66+
" text-align: right;\n",
67+
" }\n",
68+
"</style>\n",
69+
"<table border=\"1\" class=\"dataframe\">\n",
70+
" <thead>\n",
71+
" <tr style=\"text-align: right;\">\n",
72+
" <th></th>\n",
73+
" <th>x</th>\n",
74+
" <th>hex</th>\n",
75+
" </tr>\n",
76+
" </thead>\n",
77+
" <tbody>\n",
78+
" <tr>\n",
79+
" <th>0</th>\n",
80+
" <td>1</td>\n",
81+
" <td>0000000000000001</td>\n",
82+
" </tr>\n",
83+
" <tr>\n",
84+
" <th>1</th>\n",
85+
" <td>123456</td>\n",
86+
" <td>000000000001e240</td>\n",
87+
" </tr>\n",
88+
" <tr>\n",
89+
" <th>2</th>\n",
90+
" <td>9876543210</td>\n",
91+
" <td>000000024cb016ea</td>\n",
92+
" </tr>\n",
93+
" <tr>\n",
94+
" <th>3</th>\n",
95+
" <td>-1001</td>\n",
96+
" <td>fffffffffffffc17</td>\n",
97+
" </tr>\n",
98+
" </tbody>\n",
99+
"</table>\n",
100+
"</div>"
101+
],
102+
"text/plain": [
103+
" x hex\n",
104+
"0 1 0000000000000001\n",
105+
"1 123456 000000000001e240\n",
106+
"2 9876543210 000000024cb016ea\n",
107+
"3 -1001 fffffffffffffc17"
108+
]
109+
},
110+
"execution_count": 4,
111+
"metadata": {},
112+
"output_type": "execute_result"
113+
}
114+
],
115+
"source": [
116+
"%%bigquery\n",
117+
"SELECT\n",
118+
" x,\n",
119+
" bqutil.fn.to_hex(x) AS hex\n",
120+
"FROM\n",
121+
" UNNEST([1, 123456, 9876543210, -1001]) AS x;"
122+
]
123+
},
124+
{
125+
"cell_type": "markdown",
126+
"metadata": {},
127+
"source": [
128+
"Try a function that uses a JS library hosted in GCS. See: https://github.com/GoogleCloudPlatform/bigquery-utils/pull/434 and https://github.com/GoogleCloudPlatform/bigquery-utils/blob/master/udfs/community/README.md#xml_to_jsonxml-string\n"
129+
]
130+
},
131+
{
132+
"cell_type": "code",
133+
"execution_count": 3,
134+
"metadata": {},
135+
"outputs": [
136+
{
137+
"data": {
138+
"application/vnd.jupyter.widget-view+json": {
139+
"model_id": "9a7df3ece0584d909681ec621cdbbfd6",
140+
"version_major": 2,
141+
"version_minor": 0
142+
},
143+
"text/plain": [
144+
"Query is running: 0%| |"
145+
]
146+
},
147+
"metadata": {},
148+
"output_type": "display_data"
149+
},
150+
{
151+
"data": {
152+
"application/vnd.jupyter.widget-view+json": {
153+
"model_id": "38ff038524e84cc39d7c6adf5ae33807",
154+
"version_major": 2,
155+
"version_minor": 0
156+
},
157+
"text/plain": [
158+
"Downloading: 0%| |"
159+
]
160+
},
161+
"metadata": {},
162+
"output_type": "display_data"
163+
},
164+
{
165+
"data": {
166+
"text/html": [
167+
"<div>\n",
168+
"<style scoped>\n",
169+
" .dataframe tbody tr th:only-of-type {\n",
170+
" vertical-align: middle;\n",
171+
" }\n",
172+
"\n",
173+
" .dataframe tbody tr th {\n",
174+
" vertical-align: top;\n",
175+
" }\n",
176+
"\n",
177+
" .dataframe thead th {\n",
178+
" text-align: right;\n",
179+
" }\n",
180+
"</style>\n",
181+
"<table border=\"1\" class=\"dataframe\">\n",
182+
" <thead>\n",
183+
" <tr style=\"text-align: right;\">\n",
184+
" <th></th>\n",
185+
" <th>output_json</th>\n",
186+
" </tr>\n",
187+
" </thead>\n",
188+
" <tbody>\n",
189+
" <tr>\n",
190+
" <th>0</th>\n",
191+
" <td>{\"xml\":{\"_attributes\":{\"foo\":\"FOO\"},\"bar\":{\"ba...</td>\n",
192+
" </tr>\n",
193+
" </tbody>\n",
194+
"</table>\n",
195+
"</div>"
196+
],
197+
"text/plain": [
198+
" output_json\n",
199+
"0 {\"xml\":{\"_attributes\":{\"foo\":\"FOO\"},\"bar\":{\"ba..."
200+
]
201+
},
202+
"execution_count": 3,
203+
"metadata": {},
204+
"output_type": "execute_result"
205+
}
206+
],
207+
"source": [
208+
"%%bigquery\n",
209+
"SELECT bqutil.fn.xml_to_json(\n",
210+
" '<xml foo=\"FOO\"><bar><baz>BAZ</baz></bar></xml>'\n",
211+
") AS output_json"
212+
]
213+
},
214+
{
215+
"cell_type": "code",
216+
"execution_count": null,
217+
"metadata": {},
218+
"outputs": [],
219+
"source": []
220+
}
221+
],
222+
"metadata": {
223+
"kernelspec": {
224+
"display_name": "scratch",
225+
"language": "python",
226+
"name": "python3"
227+
},
228+
"language_info": {
229+
"codemirror_mode": {
230+
"name": "ipython",
231+
"version": 3
232+
},
233+
"file_extension": ".py",
234+
"mimetype": "text/x-python",
235+
"name": "python",
236+
"nbconvert_exporter": "python",
237+
"pygments_lexer": "ipython3",
238+
"version": "3.12.6"
239+
}
240+
},
241+
"nbformat": 4,
242+
"nbformat_minor": 2
243+
}

bigquery-dataframes-iowa-liquor-sales/codelab.json

Lines changed: 0 additions & 26 deletions
This file was deleted.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)