wony617
commited on
Commit
Β·
d583cc9
1
Parent(s):
9247d25
log: always append JSONL log regardless of status
Browse filesDeduplicate logging and ensure every workflow run appends a JSON line to pr_success.log on the log_event branch.
- agent/workflow.py +17 -33
agent/workflow.py
CHANGED
|
@@ -203,25 +203,25 @@ def generate_github_pr(
|
|
| 203 |
toctree_status = f"\nπ **Toctree Updated:** β
{toctree_result['message']}"
|
| 204 |
else:
|
| 205 |
toctree_status = f"\nπ **Toctree Update Failed:** β {toctree_result['message']}"
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
import json
|
| 210 |
log_entry = json.dumps(result, ensure_ascii=False) + "\n"
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
return f"""β
**GitHub PR Creation Successful!**
|
| 226 |
|
| 227 |
π **PR URL:** {result.get('pr_url', 'NO_PR_URL')}
|
|
@@ -231,22 +231,6 @@ def generate_github_pr(
|
|
| 231 |
{result["message"]}"""
|
| 232 |
|
| 233 |
elif result["status"] == "partial_success":
|
| 234 |
-
# Append full result JSON to GitHub log file on 'log_event' branch
|
| 235 |
-
import json
|
| 236 |
-
log_entry = json.dumps(result, ensure_ascii=False) + "\n"
|
| 237 |
-
try:
|
| 238 |
-
log_res = agent.append_to_log_file(
|
| 239 |
-
owner=github_config["owner"],
|
| 240 |
-
repo_name=github_config["repo_name"],
|
| 241 |
-
branch_name="log_event",
|
| 242 |
-
path="pr_success.log",
|
| 243 |
-
log_entry=log_entry,
|
| 244 |
-
header_if_new="",
|
| 245 |
-
)
|
| 246 |
-
print(f"π Log append result: {log_res}")
|
| 247 |
-
except Exception as e:
|
| 248 |
-
print(f"β Failed to append PR log via GitHub API: {e}")
|
| 249 |
-
|
| 250 |
return f"""β οΈ **Partial Success**
|
| 251 |
|
| 252 |
πΏ **Branch:** {result["branch"]}
|
|
|
|
| 203 |
toctree_status = f"\nπ **Toctree Updated:** β
{toctree_result['message']}"
|
| 204 |
else:
|
| 205 |
toctree_status = f"\nπ **Toctree Update Failed:** β {toctree_result['message']}"
|
| 206 |
+
|
| 207 |
+
# Append full result JSON to GitHub log file on 'log_event' branch (always)
|
| 208 |
+
try:
|
| 209 |
import json
|
| 210 |
log_entry = json.dumps(result, ensure_ascii=False) + "\n"
|
| 211 |
+
log_res = agent.append_to_log_file(
|
| 212 |
+
owner=github_config["owner"],
|
| 213 |
+
repo_name=github_config["repo_name"],
|
| 214 |
+
branch_name="log_event",
|
| 215 |
+
path="pr_success.log",
|
| 216 |
+
log_entry=log_entry,
|
| 217 |
+
# Ensure pure JSONL (no header)
|
| 218 |
+
header_if_new="",
|
| 219 |
+
)
|
| 220 |
+
print(f"π Log append result: {log_res}")
|
| 221 |
+
except Exception as e:
|
| 222 |
+
print(f"β Failed to append PR log via GitHub API: {e}")
|
| 223 |
+
|
| 224 |
+
if result["status"] == "success":
|
| 225 |
return f"""β
**GitHub PR Creation Successful!**
|
| 226 |
|
| 227 |
π **PR URL:** {result.get('pr_url', 'NO_PR_URL')}
|
|
|
|
| 231 |
{result["message"]}"""
|
| 232 |
|
| 233 |
elif result["status"] == "partial_success":
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 234 |
return f"""β οΈ **Partial Success**
|
| 235 |
|
| 236 |
πΏ **Branch:** {result["branch"]}
|