Update script_for_automation.py
Browse files- script_for_automation.py +5 -34
script_for_automation.py
CHANGED
|
@@ -408,20 +408,13 @@ def generate_markdown_output(df):
|
|
| 408 |
for _, row in df.iterrows():
|
| 409 |
markdown += f"\n### Recipe ID: {row['Recipe_ID']}\n"
|
| 410 |
for key in ["planting", "interactions", "trials"]:
|
| 411 |
-
|
| 412 |
-
|
| 413 |
-
machine_yaml = yaml.dump(row['Machine_Generated_YAML'].get(key, {}), default_flow_style=False, sort_keys=True)
|
| 414 |
-
|
| 415 |
-
# Add proper line breaks between YAML blocks
|
| 416 |
-
gold_yaml = "\n".join([line for line in gold_yaml.splitlines()]) # Ensure clean output
|
| 417 |
-
machine_yaml = "\n".join([line for line in machine_yaml.splitlines()])
|
| 418 |
-
|
| 419 |
-
# Add Markdown table
|
| 420 |
markdown += f"#### {key.capitalize()}\n"
|
| 421 |
markdown += "| Type | YAML Content |\n"
|
| 422 |
markdown += "|------|--------------|\n"
|
| 423 |
-
markdown += f"| Gold Standard | ```yaml\n{
|
| 424 |
-
markdown += f"| Machine Generated | ```yaml\n{
|
| 425 |
|
| 426 |
return markdown
|
| 427 |
|
|
@@ -506,26 +499,6 @@ def drive_process():
|
|
| 506 |
differences_interactions = list(diff(gold_standard_interactions_json, processed_interactions_json))
|
| 507 |
differences_trials = list(diff(gold_standard_trials_json, processed_trials_json))
|
| 508 |
|
| 509 |
-
print("yaml world")
|
| 510 |
-
|
| 511 |
-
# Convert to yaml
|
| 512 |
-
completed_gold_standard_planting_json = sanitize_json_for_yaml(gold_standard_planting_json)
|
| 513 |
-
completed_gold_standard_interactions_json = sanitize_json_for_yaml(gold_standard_interactions_json)
|
| 514 |
-
completed_gold_standard_trials_json = sanitize_json_for_yaml(gold_standard_trials_json)
|
| 515 |
-
|
| 516 |
-
completed_processed_farm_activity_json = sanitize_json_for_yaml(processed_farm_activity_json)
|
| 517 |
-
completed_processed_interactions_json = sanitize_json_for_yaml(processed_interactions_json)
|
| 518 |
-
completed_processed_trials_json = sanitize_json_for_yaml(processed_trials_json)
|
| 519 |
-
|
| 520 |
-
completed_gold_standard_planting_yaml = yaml.safe_load(completed_gold_standard_planting_json)
|
| 521 |
-
completed_gold_standard_interactions_yaml = yaml.safe_load(completed_gold_standard_interactions_json)
|
| 522 |
-
completed_gold_standard_trials_yaml = yaml.safe_load(completed_gold_standard_trials_json)
|
| 523 |
-
|
| 524 |
-
completed_comparison_planting_yaml = yaml.safe_load(completed_processed_farm_activity_json)
|
| 525 |
-
completed_comparison_interactions_yaml = yaml.safe_load(completed_processed_interactions_json)
|
| 526 |
-
completed_comparison_trials_yaml = yaml.safe_load(completed_processed_trials_json)
|
| 527 |
-
|
| 528 |
-
|
| 529 |
json_diff = {
|
| 530 |
"planting": differences_planting,
|
| 531 |
"interactions": differences_interactions,
|
|
@@ -571,9 +544,7 @@ def drive_process():
|
|
| 571 |
"Input_Transcript": input_chunks,
|
| 572 |
"Gold_Standard_JSON": gold_standard_json,
|
| 573 |
"Machine_Generated_JSON": comparison_json,
|
| 574 |
-
"Differences": json_diff
|
| 575 |
-
"Gold_Standard_YAML": gold_standard_yaml,
|
| 576 |
-
"Machine_Generated_YAML": comparison_yaml
|
| 577 |
})
|
| 578 |
|
| 579 |
df = pd.DataFrame(output_rows)
|
|
|
|
| 408 |
for _, row in df.iterrows():
|
| 409 |
markdown += f"\n### Recipe ID: {row['Recipe_ID']}\n"
|
| 410 |
for key in ["planting", "interactions", "trials"]:
|
| 411 |
+
gold = yaml.dumps(row['Gold_Standard_JSON'].get(key, {}), indent=2)
|
| 412 |
+
machine = yaml.dumps(row['Machine_Generated_JSON'].get(key, {}), indent=2)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 413 |
markdown += f"#### {key.capitalize()}\n"
|
| 414 |
markdown += "| Type | YAML Content |\n"
|
| 415 |
markdown += "|------|--------------|\n"
|
| 416 |
+
markdown += f"| Gold Standard | ```yaml\n{gold}\n``` |\n"
|
| 417 |
+
markdown += f"| Machine Generated | ```yaml\n{machine}\n``` |\n"
|
| 418 |
|
| 419 |
return markdown
|
| 420 |
|
|
|
|
| 499 |
differences_interactions = list(diff(gold_standard_interactions_json, processed_interactions_json))
|
| 500 |
differences_trials = list(diff(gold_standard_trials_json, processed_trials_json))
|
| 501 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 502 |
json_diff = {
|
| 503 |
"planting": differences_planting,
|
| 504 |
"interactions": differences_interactions,
|
|
|
|
| 544 |
"Input_Transcript": input_chunks,
|
| 545 |
"Gold_Standard_JSON": gold_standard_json,
|
| 546 |
"Machine_Generated_JSON": comparison_json,
|
| 547 |
+
"Differences": json_diff
|
|
|
|
|
|
|
| 548 |
})
|
| 549 |
|
| 550 |
df = pd.DataFrame(output_rows)
|