Skip to content

Commit a15e773

Browse files
xingyousongcopybara-github
authored andcommitted
Fix endpoint issues in pyglove colab. Should resolve #1044
PiperOrigin-RevId: 603124975
1 parent f3839e7 commit a15e773

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

docs/advanced_topics/pyglove/vizier_as_backend.ipynb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
"\n",
5050
"import pyglove as pg\n",
5151
"from vizier import pyglove as pg_vizier\n",
52-
"from vizier.service import vizier_server"
52+
"from vizier.service import servers"
5353
]
5454
},
5555
{
@@ -136,7 +136,7 @@
136136
"id": "zIbLEGi6prpm"
137137
},
138138
"source": [
139-
"Alternatively, if using a remote server, the endpoint can be specified as well:"
139+
"**Alternatively**, if using a remote server, the endpoint can be specified as well:"
140140
]
141141
},
142142
{
@@ -147,7 +147,7 @@
147147
},
148148
"outputs": [],
149149
"source": [
150-
"server = vizier_server.DefaultVizierServer(host=hostname) # Normally hosted on a remote machine.\n",
150+
"server = servers.DefaultVizierServer() # Normally hosted on a remote machine.\n",
151151
"pg_vizier.init('my_study', vizier_endpoint=server.endpoint)"
152152
]
153153
},
@@ -169,15 +169,15 @@
169169
},
170170
"outputs": [],
171171
"source": [
172-
"num_workers = 10\n",
172+
"NUM_WORKERS = 10\n",
173173
"\n",
174174
"\n",
175175
"def work_fn(worker_id):\n",
176176
" print(f\"Worker ID: {worker_id}\")\n",
177177
" for value, feedback in pg.sample(\n",
178178
" search_space,\n",
179179
" algorithm=algorithm,\n",
180-
" num_examples=num_trials // num_workers,\n",
180+
" num_examples=num_trials // NUM_WORKERS,\n",
181181
" name=\"worker_run\",\n",
182182
" ):\n",
183183
" reward = evaluator(value)\n",
@@ -217,7 +217,7 @@
217217
"outputs": [],
218218
"source": [
219219
"with multiprocessing.pool.ThreadPool(num_workers) as pool:\n",
220-
" pool.map(work_fn, range(num_workers))"
220+
" pool.map(work_fn, range(NUM_WORKERS))"
221221
]
222222
},
223223
{
@@ -238,7 +238,7 @@
238238
"outputs": [],
239239
"source": [
240240
"processes = []\n",
241-
"for worker_id in range(num_workers):\n",
241+
"for worker_id in range(NUM_WORKERS):\n",
242242
" p = multiprocessing.Process(target=work_fn, args=(worker_id,))\n",
243243
" p.start()\n",
244244
" processes.append(p)\n",
@@ -265,7 +265,7 @@
265265
"outputs": [],
266266
"source": [
267267
"# Server Machine\n",
268-
"server = vizier_server.DefaultVizierServer(host=hostname)"
268+
"server = servers.DefaultVizierServer()"
269269
]
270270
},
271271
{

0 commit comments

Comments
 (0)