From 6aa2522a3bbeb7de35f87e4ff16c7a553f036218 Mon Sep 17 00:00:00 2001 From: Patrick Devaney Date: Sun, 22 Dec 2024 22:59:53 -0500 Subject: [PATCH] hotfix using datetime.now().strftime() to format the time on spreadsheet_swarm.py --- api/main.py | 4 +--- swarms/structs/spreadsheet_swarm.py | 9 ++++----- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/api/main.py b/api/main.py index 10123634..bc1a5d62 100644 --- a/api/main.py +++ b/api/main.py @@ -962,7 +962,6 @@ def create_app() -> FastAPI: logger.info("FastAPI application created successfully") return app - def run_server(): """Run the API server""" try: @@ -974,8 +973,7 @@ def run_server(): asyncio.run(server.startup()) except Exception as e: logger.error(f"Failed to start API: {str(e)}") - print(f"Error starting server: {str(e)}" - + print(f"Error starting server: {str(e)}") # <-- Fixed here if __name__ == "__main__": run_server() diff --git a/swarms/structs/spreadsheet_swarm.py b/swarms/structs/spreadsheet_swarm.py index 2e691f78..3a934920 100644 --- a/swarms/structs/spreadsheet_swarm.py +++ b/swarms/structs/spreadsheet_swarm.py @@ -1,6 +1,6 @@ import asyncio import csv -import datetime +from datetime import datetime # Correct import statement import os import uuid from typing import List, Union @@ -16,15 +16,14 @@ from swarms.utils.loguru_logger import initialize_logger logger = initialize_logger(log_folder="spreadsheet_swarm") -time = datetime.datetime.now().isoformat() +# Corrected line +time = datetime.now().isoformat() # Use datetime.now() instead of datetime.datetime.now() 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): @@ -299,4 +298,4 @@ class SpreadSheetSwarm(BaseSwarm): output.result, output.timestamp, ] - ) + ) \ No newline at end of file