Spaces:
Runtime error
Runtime error
Download test_exporting.py from ngohel58/Drawing_Extraction: direct link, hf CLI and curl.
- Browser
- Download file 1.07 kB
-
https://huggingface.co/spaces/ngohel58/Drawing_Extraction/resolve/main/test_exporting.py
- Command line
-
hf download hf://spaces/ngohel58/Drawing_Extraction/test_exporting.py
-
curl -L -o test_exporting.py https://huggingface.co/spaces/ngohel58/Drawing_Extraction/resolve/main/test_exporting.py
1.07 kB
| import json | |
| from pathlib import Path | |
| from openpyxl import load_workbook | |
| from drawing_intelligence.document import create_sample_drawing | |
| from drawing_intelligence.exporting import create_export_files, records_to_dataframe | |
| from drawing_intelligence.pipeline import run_extraction | |
| def test_excel_and_json_exports_are_traceable(tmp_path: Path) -> None: | |
| output = run_extraction( | |
| create_sample_drawing(), model_key="demo", dpi=150, max_pages=1 | |
| ) | |
| table = records_to_dataframe(output.result.characteristics) | |
| excel, json_file = create_export_files(table, output.result, tmp_path) | |
| workbook = load_workbook(excel) | |
| assert workbook.sheetnames == [ | |
| "Characteristics", | |
| "Drawing metadata", | |
| "General notes", | |
| "Extraction log", | |
| ] | |
| assert workbook["Characteristics"]["A2"].value == "1" | |
| payload = json.loads(Path(json_file).read_text(encoding="utf-8")) | |
| assert payload["source_name"] == "drawing_intelligence_sample.png" | |
| assert len(payload["characteristics"]) == 6 | |
| assert "approval_notice" in payload | |