joonspk-research / generative_agents

Generative Agents: Interactive Simulacra of Human Behavior
Apache License 2.0
16.26k stars 2.09k forks source link

movement folder issue #44

Open technopremium opened 1 year ago

technopremium commented 1 year ago

Hi,

I have followed the steps and everything looks good, but after starting the python reverie.py it satart to generate the actions but at some point it stop with this error message.

Klaus Mueller persona.scratch.importance_trigger_curr:: 145 150 aldhfoaf/???? the Ville:Dorm for Oak Hill College:Klaus Mueller's room:bed Traceback (most recent call last): File "/home/bizon/generative_agents/reverie/backend_server/reverie.py", line 468, in open_server rs.start_server(int_count) File "/home/bizon/generative_agents/reverie/backend_server/reverie.py", line 401, in start_server with open(curr_move_file, "w") as outfile: FileNotFoundError: [Errno 2] No such file or directory: '../../environment/frontend_server/storage/bizon4/movement/0.json' Error.

Then I go to the folder on storage in this case was bizon4 and I only see this folders:

(base) bizon@dl:~/generative_agents/environment/frontend_server/storage/bizon4$ ls environment personas reverie (base) bizon@dl:~/generative_agents/environment/frontend_server/storage/bizon4$

Can you please help me here.

Thanks

zoan37 commented 1 year ago

+1 I'm encountering the same issue

frankcarey commented 1 year ago

See issue #2

adammoro commented 1 year ago

I added a folder named "movement" to the environment/frontend_server/storage/ folder and that resolved it for me. I needed to add it and then restart the backend server and run a new simulation.

technopremium commented 1 year ago

Hi, I hope I can fix this issue for you guys, the main problem is that people solve the problem for themselves but do not explain properly, something so simple prevent the software to run. I hope this help:

Go to the file reverie.py file, use an editor like vscode so you can see the line count. go to line 401, it will look something like this:

  curr_move_file = f"{sim_folder}/movement/{self.step}.json"
  with open(curr_move_file, "w") as outfile: 
    outfile.write(json.dumps(movements, indent=2))

on top of that line 400 add this lines of code:

curr_move_path = f"{sim_folder}/movement"

If the folder doesn't exist, we create it.

if not os.path.exists(curr_move_path): os.makedirs(curr_move_path)

The code should look like this: from line 394 to 406

  # We then write the personas' movements to a file that will be sent 
  # to the frontend server. 
  # Example json output: 
  # {"persona": {"Maria Lopez": {"movement": [58, 9]}},
  #  "persona": {"Klaus Mueller": {"movement": [38, 12]}}, 
  #  "meta": {curr_time: <datetime>}}
  curr_move_path = f"{sim_folder}/movement"
  # If the folder doesn't exist, we create it.
  if not os.path.exists(curr_move_path):
    os.makedirs(curr_move_path)
  curr_move_file = f"{sim_folder}/movement/{self.step}.json"
  with open(curr_move_file, "w") as outfile: 
    outfile.write(json.dumps(movements, indent=2))

After that the problem will go away, I hope this help.