{
"event": "PreToolUse",
"tool_name": "Grep",
"tool_input": {
"pattern": "class PipelineProgress",
"path": "\/opt\/scripts\/pipeline",
"output_mode": "content",
"-A": 80
}
}
{
"tool_response": {
"mode": "content",
"numFiles": 0,
"filenames": [],
"content": "\/opt\/scripts\/pipeline\/db.py:301:class PipelineProgress:\n\/opt\/scripts\/pipeline\/db.py-302- \"\"\"Tracks and updates pipeline run progress in ki_content.pipeline_runs.\"\"\"\n\/opt\/scripts\/pipeline\/db.py-303-\n\/opt\/scripts\/pipeline\/db.py-304- def __init__(self, run_id: int):\n\/opt\/scripts\/pipeline\/db.py-305- self.run_id = run_id\n\/opt\/scripts\/pipeline\/db.py-306- self.log_lines = []\n\/opt\/scripts\/pipeline\/db.py-307- self.max_log_lines = 20\n\/opt\/scripts\/pipeline\/db.py-308-\n\/opt\/scripts\/pipeline\/db.py-309- def _update(self, **kwargs):\n\/opt\/scripts\/pipeline\/db.py-310- \"\"\"Internal: Update database with progress.\"\"\"\n\/opt\/scripts\/pipeline\/db.py-311- from datetime import datetime\n\/opt\/scripts\/pipeline\/db.py-312-\n\/opt\/scripts\/pipeline\/db.py-313- import mysql.connector\n\/opt\/scripts\/pipeline\/db.py-314-\n\/opt\/scripts\/pipeline\/db.py-315- from config import DB_CONFIG\n\/opt\/scripts\/pipeline\/db.py-316-\n\/opt\/scripts\/pipeline\/db.py-317- if not self.run_id:\n\/opt\/scripts\/pipeline\/db.py-318- return\n\/opt\/scripts\/pipeline\/db.py-319-\n\/opt\/scripts\/pipeline\/db.py-320- kwargs[\"last_update_at\"] = datetime.now().strftime(\"%Y-%m-%d %H:%M:%S\")\n\/opt\/scripts\/pipeline\/db.py-321-\n\/opt\/scripts\/pipeline\/db.py-322- sets = \", \".join(f\"{k} = %s\" for k in kwargs)\n\/opt\/scripts\/pipeline\/db.py-323- values = list(kwargs.values())\n\/opt\/scripts\/pipeline\/db.py-324- values.append(self.run_id)\n\/opt\/scripts\/pipeline\/db.py-325-\n\/opt\/scripts\/pipeline\/db.py-326- try:\n\/opt\/scripts\/pipeline\/db.py-327- conn = mysql.connector.connect(**DB_CONFIG)\n\/opt\/scripts\/pipeline\/db.py-328- cursor = conn.cursor()\n\/opt\/scripts\/pipeline\/db.py-329- cursor.execute(f\"UPDATE pipeline_runs SET {sets} WHERE id = %s\", values) # noqa: S608\n\/opt\/scripts\/pipeline\/db.py-330- conn.commit()\n\/opt\/scripts\/pipeline\/db.py-331- cursor.close()\n\/opt\/scripts\/pipeline\/db.py-332- conn.close()\n\/opt\/scripts\/pipeline\/db.py-333- except Exception as e:\n\/opt\/scripts\/pipeline\/db.py-334- print(f\"Progress update error: {e}\")\n\/opt\/scripts\/pipeline\/db.py-335-\n\/opt\/scripts\/pipeline\/db.py-336- def update_step(self, step_name: str):\n\/opt\/scripts\/pipeline\/db.py-337- \"\"\"Update current pipeline step.\"\"\"\n\/opt\/scripts\/pipeline\/db.py-338- self._update(current_step=step_name)\n\/opt\/scripts\/pipeline\/db.py-339-\n\/opt\/scripts\/pipeline\/db.py-340- def update_document(self, filename: str):\n\/opt\/scripts\/pipeline\/db.py-341- \"\"\"Update current document being processed.\"\"\"\n\/opt\/scripts\/pipeline\/db.py-342- self._update(current_document=filename)\n\/opt\/scripts\/pipeline\/db.py-343-\n\/opt\/scripts\/pipeline\/db.py-344- def update_progress(\n\/opt\/scripts\/pipeline\/db.py-345- self,\n\/opt\/scripts\/pipeline\/db.py-346- processed: int = None,\n\/opt\/scripts\/pipeline\/db.py-347- total: int = None,\n\/opt\/scripts\/pipeline\/db.py-348- failed: int = None,\n\/opt\/scripts\/pipeline\/db.py-349- chunks: int = None,\n\/opt\/scripts\/pipeline\/db.py-350- embeddings: int = None,\n\/opt\/scripts\/pipeline\/db.py-351- ):\n\/opt\/scripts\/pipeline\/db.py-352- \"\"\"Update numeric progress fields.\"\"\"\n\/opt\/scripts\/pipeline\/db.py-353- data = {}\n\/opt\/scripts\/pipeline\/db.py-354- if processed is not None:\n\/opt\/scripts\/pipeline\/db.py-355- data[\"documents_processed\"] = processed\n\/opt\/scripts\/pipeline\/db.py-356- if total is not None:\n\/opt\/scripts\/pipeline\/db.py-357- data[\"documents_total\"] = total\n\/opt\/scripts\/pipeline\/db.py-358- if failed is not None:\n\/opt\/scripts\/pipeline\/db.py-359- data[\"documents_failed\"] = failed\n\/opt\/scripts\/pipeline\/db.py-360- if chunks is not None:\n\/opt\/scripts\/pipeline\/db.py-361- data[\"chunks_created\"] = chunks\n\/opt\/scripts\/pipeline\/db.py-362- if embeddings is not None:\n\/opt\/scripts\/pipeline\/db.py-363- data[\"embeddings_created\"] = embeddings\n\/opt\/scripts\/pipeline\/db.py-364- if data:\n\/opt\/scripts\/pipeline\/db.py-365- self._update(**data)\n\/opt\/scripts\/pipeline\/db.py-366-\n\/opt\/scripts\/pipeline\/db.py-367- def add_log(self, message: str):\n\/opt\/scripts\/pipeline\/db.py-368- \"\"\"Add log line and update log_tail.\"\"\"\n\/opt\/scripts\/pipeline\/db.py-369- from datetime import datetime\n\/opt\/scripts\/pipeline\/db.py-370-\n\/opt\/scripts\/pipeline\/db.py-371- timestamp = datetime.now().strftime(\"%H:%M:%S\")\n\/opt\/scripts\/pipeline\/db.py-372- self.log_lines.append(f\"[{timestamp}] {message}\")\n\/opt\/scripts\/pipeline\/db.py-373- if len(self.log_lines) > self.max_log_lines:\n\/opt\/scripts\/pipeline\/db.py-374- self.log_lines = self.log_lines[-self.max_log_lines :]\n\/opt\/scripts\/pipeline\/db.py-375- self._update(log_tail=\"\\n\".join(self.log_lines))\n\/opt\/scripts\/pipeline\/db.py-376-\n\/opt\/scripts\/pipeline\/db.py-377- def complete(self, status: str = \"completed\", error: str = None):\n\/opt\/scripts\/pipeline\/db.py-378- \"\"\"Mark run as complete or failed.\"\"\"\n\/opt\/scripts\/pipeline\/db.py-379- from datetime import datetime\n\/opt\/scripts\/pipeline\/db.py-380-\n\/opt\/scripts\/pipeline\/db.py-381- data = {",
"numLines": 81
}
}