Skip to content

Commit 628e464

Browse files
committed
code changes
1 parent 733d0b0 commit 628e464

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

supporting-blog-content/from-image-idea-to-kibana-dashboard-using-ai/from-image-idea-to-kibana-dashboard-using-ai.ipynb

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -394,22 +394,24 @@
394394
"\n",
395395
"job_url = f\"{os.getenv('KIBANA_URL')}{r.json()['path']}\"\n",
396396
"\n",
397-
"# Wait for job to complete\n",
397+
"\n",
398398
"while True:\n",
399399
" resp = requests.get(job_url, headers=headers)\n",
400-
" status_code = resp.status_code\n",
401400
"\n",
402-
" if status_code == 200:\n",
401+
" print(resp.status_code)\n",
402+
" if resp.status_code == 200:\n",
403403
" with open(\"dashboard.png\", \"wb\") as f:\n",
404404
" f.write(resp.content)\n",
405405
"\n",
406406
" print(\"PNG downloaded as dashboard.png\")\n",
407407
" display(Image(\"dashboard.png\"))\n",
408408
" break\n",
409-
" elif status_code == 503:\n",
410-
" print(\"Waiting for job to complete...\")\n",
411409
"\n",
412-
" time.sleep(5)"
410+
" retry_after = resp.headers.get(\"Retry-After\")\n",
411+
"\n",
412+
" if retry_after:\n",
413+
" print(f\"Waiting {retry_after} seconds before retrying...\")\n",
414+
" time.sleep(int(retry_after))"
413415
]
414416
}
415417
],

0 commit comments

Comments
 (0)