mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-10 08:38:30 +00:00
Fixed output_file not respecting system path
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import datetime
|
import datetime
|
||||||
import json
|
import json
|
||||||
import os
|
from pathlib import Path
|
||||||
import threading
|
import threading
|
||||||
import uuid
|
import uuid
|
||||||
from concurrent.futures import Future
|
from concurrent.futures import Future
|
||||||
@@ -393,12 +393,13 @@ class Task(BaseModel):
|
|||||||
if self.output_file is None:
|
if self.output_file is None:
|
||||||
raise ValueError("output_file is not set.")
|
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"
|
resolved_path = Path(self.output_file).expanduser().resolve()
|
||||||
|
directory = resolved_path.parent
|
||||||
|
|
||||||
if directory and not os.path.exists(directory):
|
if not directory.exists():
|
||||||
os.makedirs(directory)
|
directory.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
with open(self.output_file, "w", encoding="utf-8") as file:
|
with resolved_path.open("w", encoding="utf-8") as file:
|
||||||
if isinstance(result, dict):
|
if isinstance(result, dict):
|
||||||
import json
|
import json
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user