Skip to content

Commit

Permalink
chore: ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
JoFrost committed May 21, 2024
1 parent c70ce5c commit bd19379
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions lavague-core/lavague/core/agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,15 @@ def run(self, objective, display=True, log: bool = False):

if log:
import csv

if os.path.isdir("./logs") == False:
os.mkdir("./logs")
with open(f"./logs/{run_id}.csv", "w", newline="") as output_file:
keys = log_lines[0].keys()
dict_writer = csv.DictWriter(output_file, keys)
dict_writer.writeheader()
dict_writer.writerows(log_lines)
print(f"Logs exported to logs/{run_id}.csv")

try:
if os.path.isdir("./logs") == False:
os.mkdir("./logs")
with open(f"./logs/{run_id}.csv", "w", newline="") as output_file:
keys = log_lines[0].keys()
dict_writer = csv.DictWriter(output_file, keys)
dict_writer.writeheader()
dict_writer.writerows(log_lines)
print(f"Logs exported to logs/{run_id}.csv")
except:
print("Logs couldn't be exported due to an error.")

0 comments on commit bd19379

Please sign in to comment.