Skip to content

Commit

Permalink
Guard against empty Loki query results
Browse files Browse the repository at this point in the history
  • Loading branch information
hsinfang committed Feb 1, 2024
1 parent 1fa3e3c commit 6aa7832
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion prompt-processing/groups.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,9 @@
" search_phrase)\n",
" results = !{command}\n",
" logger.debug(f\"Got {len(results)} Loki records for {phrase}\")\n",
" if not results:\n",
" return pandas.DataFrame(columns=[\"group\", \"ts\"])\n",
"\n",
" data = [json.loads(_) for _ in results]\n",
" df = pandas.json_normalize(data)\n",
" df = df.merge(pandas.json_normalize(df[\"line\"].apply(json.loads)),\n",
Expand Down Expand Up @@ -522,7 +525,7 @@
"metadata": {},
"outputs": [],
"source": [
"phases = [\"raw\"] + list(phrases.keys())[:-1]\n",
"phases = [\"raw\"] + list(phrases.keys())[:-1] # Exclude the timeout search\n",
"groups = dict()\n",
"groups[\"raw\"] = set(df_md.index)\n",
"for ph in ['unpckMsg', 'prepBtlr', 'waitSnap', 'runPipe1', 'pipeSucc', 'outputSa']:\n",
Expand Down

0 comments on commit 6aa7832

Please sign in to comment.