From ed8684af9c81042e034e1bf808ac575352f28131 Mon Sep 17 00:00:00 2001 From: patrickbdevaney Date: Fri, 20 Dec 2024 21:47:59 +0000 Subject: [PATCH] save_to_csv file name is now windows-compatible using datetime.now().strftime(%Y-%m-%dT%H-%M-%S) ; issues/694 --- swarms/structs/spreadsheet_swarm.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/swarms/structs/spreadsheet_swarm.py b/swarms/structs/spreadsheet_swarm.py index e57d6a5c..2e691f78 100644 --- a/swarms/structs/spreadsheet_swarm.py +++ b/swarms/structs/spreadsheet_swarm.py @@ -19,6 +19,13 @@ logger = initialize_logger(log_folder="spreadsheet_swarm") time = datetime.datetime.now().isoformat() uuid_hex = uuid.uuid4().hex +# --------------- NEW CHANGE START --------------- +# Format time variable to be compatible across operating systems +formatted_time = datetime.now().strftime("%Y-%m-%dT%H-%M-%S") + +# Create the save file path with the formatted time and UUID hex +self.save_file_path = f"spreadsheet_swarm_{formatted_time}_run_id_{uuid_hex}.csv" +# --------------- NEW CHANGE END --------------- class AgentOutput(BaseModel): agent_name: str @@ -89,9 +96,10 @@ class SpreadSheetSwarm(BaseSwarm): self.max_loops = max_loops self.workspace_dir = workspace_dir - self.save_file_path = ( - f"spreadsheet_swarm_{time}_run_id_{uuid_hex}.csv" - ) + # --------------- NEW CHANGE START --------------- + # The save_file_path now uses the formatted_time and uuid_hex + self.save_file_path = f"spreadsheet_swarm_{formatted_time}_run_id_{uuid_hex}.csv" + # --------------- NEW CHANGE END --------------- self.metadata = SwarmRunMetadata( run_id=f"spreadsheet_swarm_run_{time}",