Write structure-tool / agentic outputs to disk. Mirrors the old Docker tool's output layout so the destination connector finds what it expects: 1. ``{output_dir_path}/{stem}.json`` — primary output file. 2. INFILE overwritten with JSON (destination connector reads INFILE and
(
fs: Any,
structured_output: dict,
output_dir_path: str,
input_file_path: str,
execution_data_dir: str,
source_file_name: str,
label: str,
)
| 780 | |
| 781 | |
| 782 | def _write_pipeline_outputs( |
| 783 | fs: Any, |
| 784 | structured_output: dict, |
| 785 | output_dir_path: str, |
| 786 | input_file_path: str, |
| 787 | execution_data_dir: str, |
| 788 | source_file_name: str, |
| 789 | label: str, |
| 790 | ) -> str | None: |
| 791 | """Write structure-tool / agentic outputs to disk. |
| 792 | |
| 793 | Mirrors the old Docker tool's output layout so the destination |
| 794 | connector finds what it expects: |
| 795 | |
| 796 | 1. ``{output_dir_path}/{stem}.json`` — primary output file. |
| 797 | 2. INFILE overwritten with JSON (destination connector reads INFILE |
| 798 | and checks MIME type — without this it still sees the original |
| 799 | PDF). |
| 800 | 3. ``{execution_data_dir}/COPY_TO_FOLDER/{stem}.json`` — what the |
| 801 | old ``ToolExecutor._setup_for_run()`` created for FS destinations. |
| 802 | |
| 803 | Args: |
| 804 | label: Short label for log lines (``"structured"`` or |
| 805 | ``"agentic"``). |
| 806 | |
| 807 | Returns: |
| 808 | ``None`` on success, or the error string on failure. |
| 809 | """ |
| 810 | try: |
| 811 | stem = Path(source_file_name).stem |
| 812 | output_path = Path(output_dir_path) / f"{stem}.json" |
| 813 | logger.info("Writing %s output to %s", label, output_path) |
| 814 | fs.json_dump(path=output_path, data=structured_output) |
| 815 | |
| 816 | logger.info("Overwriting INFILE with %s output: %s", label, input_file_path) |
| 817 | fs.json_dump(path=input_file_path, data=structured_output) |
| 818 | |
| 819 | copy_to_folder = str(Path(execution_data_dir) / "COPY_TO_FOLDER") |
| 820 | fs.mkdir(copy_to_folder) |
| 821 | copy_output_path = str(Path(copy_to_folder) / f"{stem}.json") |
| 822 | fs.json_dump(path=copy_output_path, data=structured_output) |
| 823 | logger.info( |
| 824 | "%s output written to COPY_TO_FOLDER: %s", |
| 825 | label.capitalize(), |
| 826 | copy_output_path, |
| 827 | ) |
| 828 | |
| 829 | logger.info("Output written successfully to workflow storage") |
| 830 | return None |
| 831 | except Exception as e: |
| 832 | logger.error("Failed to write %s output files: %s", label, e, exc_info=True) |
| 833 | return str(e) |
| 834 | |
| 835 | |
| 836 | def _write_tool_result( |
no test coverage detected