Merge branch 'main' into feature/procedure_v2

This commit is contained in:
Brandon Hancock
2024-07-29 14:27:28 -04:00
4 changed files with 22 additions and 43 deletions

View File

@@ -356,6 +356,9 @@ class Task(BaseModel):
return OutputFormat.RAW
def _save_file(self, result: Any) -> None:
if self.output_file is None:
raise ValueError("output_file is not set.")
directory = os.path.dirname(self.output_file) # type: ignore # Value of type variable "AnyOrLiteralStr" of "dirname" cannot be "str | None"
if directory and not os.path.exists(directory):
@@ -364,6 +367,7 @@ class Task(BaseModel):
with open(self.output_file, "w", encoding="utf-8") as file:
if isinstance(result, dict):
import json
json.dump(result, file, ensure_ascii=False, indent=2)
else:
file.write(str(result))