From 180a943051ec3fd7bd2c825609392c5f35928769 Mon Sep 17 00:00:00 2001 From: Henry Lemersal Date: Fri, 11 Oct 2024 14:27:00 -0400 Subject: [PATCH 1/7] establish temporary branch for pull request --- .gitignore | 1 + environment/frontend_server/temp_storage/curr_sim_code.json | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index afa589f2a9..2028544833 100644 --- a/.gitignore +++ b/.gitignore @@ -126,3 +126,4 @@ ENV/ .ropeproject .history/ +environment/frontend_server/temp_storage/curr_sim_code.json diff --git a/environment/frontend_server/temp_storage/curr_sim_code.json b/environment/frontend_server/temp_storage/curr_sim_code.json index 310d4314bc..7c12751745 100644 --- a/environment/frontend_server/temp_storage/curr_sim_code.json +++ b/environment/frontend_server/temp_storage/curr_sim_code.json @@ -1,3 +1,3 @@ { - "sim_code": "33" -} + "sim_code": "ssar-48-s-0-0-200" +} \ No newline at end of file From 652771d0536656a80bb722efeccc3dfe91f67a60 Mon Sep 17 00:00:00 2001 From: Henry Lemersal Date: Fri, 11 Oct 2024 14:31:10 -0400 Subject: [PATCH 2/7] Updated print_conversations.py --- print_conversations.py | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/print_conversations.py b/print_conversations.py index ff7cf382d3..eb46405550 100644 --- a/print_conversations.py +++ b/print_conversations.py @@ -1,31 +1,35 @@ import os +import glob +import os import sys import json - def get_unique_conversations(simulation_name): - step_folder = f"environment/frontend_server/storage/{simulation_name}/movement" + step_folder = "environment/frontend_server/storage" + + # Use glob to find all files that start with the simulation_name + search_pattern = os.path.join(step_folder, f"{simulation_name}*/movement/*") + filepaths = glob.glob(search_pattern) observed_conversations = set() file_contents = [] - # Iterate over all files in the simulation folder - for filename in os.listdir(step_folder): - filepath = os.path.join(step_folder, filename) - + # Iterate over all matching files + for filepath in filepaths: with open(filepath, "r") as file: data = json.load(file) - personas = data["persona"] + personas = data.get("persona", {}) # Loop over all personas except one, since conversations are always # between two people for name in list(personas.keys())[:-1]: persona = personas[name] - chat = persona["chat"] + chat = persona.get("chat") if chat: chat_string = str(chat) + # Add unique conversations if chat_string not in observed_conversations: observed_conversations.add(chat_string) file_contents.append(data) @@ -33,6 +37,15 @@ def get_unique_conversations(simulation_name): return file_contents +def write_conversations_to_file(conversations, simulation_name): + output_directory = "logs/conversations" + if not os.path.exists(output_directory): + os.makedirs(output_directory) + output_filename = f"{simulation_name}_highlights.json" + full_path = os.path.join(output_directory, output_filename); + with open(full_path, "w") as file: + for conversation in conversations: + json.dump(conversation, file, indent=4) if __name__ == "__main__": if len(sys.argv) < 2: @@ -41,4 +54,9 @@ def get_unique_conversations(simulation_name): simulation_name = sys.argv[1] unique_conversations = get_unique_conversations(simulation_name) - print(json.dumps(unique_conversations, indent=2)) + + if unique_conversations: + write_conversations_to_file(unique_conversations, simulation_name) + print(f"Unique conversations written to {simulation_name}_highlights.txt") + else: + print("No unique conversations found.") \ No newline at end of file From 93c5487a91dd251b94b39092ca25e56a6623dbf8 Mon Sep 17 00:00:00 2001 From: Henry Lemersal Date: Fri, 11 Oct 2024 14:39:08 -0400 Subject: [PATCH 3/7] fix gitignore issue --- .gitignore | 3 - .../temp_storage/curr_sim_code.json | 2 +- print_conversations.py | 62 ------------------- 3 files changed, 1 insertion(+), 66 deletions(-) delete mode 100644 print_conversations.py diff --git a/.gitignore b/.gitignore index 2028544833..d07ec7ca12 100644 --- a/.gitignore +++ b/.gitignore @@ -124,6 +124,3 @@ ENV/ # Rope project settings .ropeproject - -.history/ -environment/frontend_server/temp_storage/curr_sim_code.json diff --git a/environment/frontend_server/temp_storage/curr_sim_code.json b/environment/frontend_server/temp_storage/curr_sim_code.json index 7c12751745..33ad340bc7 100644 --- a/environment/frontend_server/temp_storage/curr_sim_code.json +++ b/environment/frontend_server/temp_storage/curr_sim_code.json @@ -1,3 +1,3 @@ { - "sim_code": "ssar-48-s-0-0-200" + "sim_code": "33" } \ No newline at end of file diff --git a/print_conversations.py b/print_conversations.py deleted file mode 100644 index eb46405550..0000000000 --- a/print_conversations.py +++ /dev/null @@ -1,62 +0,0 @@ -import os -import glob -import os -import sys -import json - -def get_unique_conversations(simulation_name): - step_folder = "environment/frontend_server/storage" - - # Use glob to find all files that start with the simulation_name - search_pattern = os.path.join(step_folder, f"{simulation_name}*/movement/*") - filepaths = glob.glob(search_pattern) - - observed_conversations = set() - file_contents = [] - - # Iterate over all matching files - for filepath in filepaths: - with open(filepath, "r") as file: - data = json.load(file) - personas = data.get("persona", {}) - - # Loop over all personas except one, since conversations are always - # between two people - for name in list(personas.keys())[:-1]: - persona = personas[name] - chat = persona.get("chat") - - if chat: - chat_string = str(chat) - - # Add unique conversations - if chat_string not in observed_conversations: - observed_conversations.add(chat_string) - file_contents.append(data) - break - - return file_contents - -def write_conversations_to_file(conversations, simulation_name): - output_directory = "logs/conversations" - if not os.path.exists(output_directory): - os.makedirs(output_directory) - output_filename = f"{simulation_name}_highlights.json" - full_path = os.path.join(output_directory, output_filename); - with open(full_path, "w") as file: - for conversation in conversations: - json.dump(conversation, file, indent=4) - -if __name__ == "__main__": - if len(sys.argv) < 2: - print("Please provide the simulation name as a command line argument.") - sys.exit(1) - - simulation_name = sys.argv[1] - unique_conversations = get_unique_conversations(simulation_name) - - if unique_conversations: - write_conversations_to_file(unique_conversations, simulation_name) - print(f"Unique conversations written to {simulation_name}_highlights.txt") - else: - print("No unique conversations found.") \ No newline at end of file From ebf60f3993a9d3620f667a4851e21ecbcc76a5ae Mon Sep 17 00:00:00 2001 From: Henry Lemersal Date: Fri, 11 Oct 2024 14:40:21 -0400 Subject: [PATCH 4/7] fix print_convo glitch --- print_conversations.py | 62 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 print_conversations.py diff --git a/print_conversations.py b/print_conversations.py new file mode 100644 index 0000000000..eb46405550 --- /dev/null +++ b/print_conversations.py @@ -0,0 +1,62 @@ +import os +import glob +import os +import sys +import json + +def get_unique_conversations(simulation_name): + step_folder = "environment/frontend_server/storage" + + # Use glob to find all files that start with the simulation_name + search_pattern = os.path.join(step_folder, f"{simulation_name}*/movement/*") + filepaths = glob.glob(search_pattern) + + observed_conversations = set() + file_contents = [] + + # Iterate over all matching files + for filepath in filepaths: + with open(filepath, "r") as file: + data = json.load(file) + personas = data.get("persona", {}) + + # Loop over all personas except one, since conversations are always + # between two people + for name in list(personas.keys())[:-1]: + persona = personas[name] + chat = persona.get("chat") + + if chat: + chat_string = str(chat) + + # Add unique conversations + if chat_string not in observed_conversations: + observed_conversations.add(chat_string) + file_contents.append(data) + break + + return file_contents + +def write_conversations_to_file(conversations, simulation_name): + output_directory = "logs/conversations" + if not os.path.exists(output_directory): + os.makedirs(output_directory) + output_filename = f"{simulation_name}_highlights.json" + full_path = os.path.join(output_directory, output_filename); + with open(full_path, "w") as file: + for conversation in conversations: + json.dump(conversation, file, indent=4) + +if __name__ == "__main__": + if len(sys.argv) < 2: + print("Please provide the simulation name as a command line argument.") + sys.exit(1) + + simulation_name = sys.argv[1] + unique_conversations = get_unique_conversations(simulation_name) + + if unique_conversations: + write_conversations_to_file(unique_conversations, simulation_name) + print(f"Unique conversations written to {simulation_name}_highlights.txt") + else: + print("No unique conversations found.") \ No newline at end of file From 437e183aa750fa51421801dcf46584f394a44d1f Mon Sep 17 00:00:00 2001 From: Henry Lemersal Date: Fri, 11 Oct 2024 14:43:40 -0400 Subject: [PATCH 5/7] fix changes --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index d07ec7ca12..5ed4e12626 100644 --- a/.gitignore +++ b/.gitignore @@ -124,3 +124,5 @@ ENV/ # Rope project settings .ropeproject + +.history/ \ No newline at end of file From 9608a031a3103e127f52765decf9e6c263e69a0f Mon Sep 17 00:00:00 2001 From: Henry Lemersal Date: Fri, 11 Oct 2024 18:35:05 -0400 Subject: [PATCH 6/7] fix double commit --- environment/frontend_server/temp_storage/curr_sim_code.json | 2 +- print_conversations.py | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/environment/frontend_server/temp_storage/curr_sim_code.json b/environment/frontend_server/temp_storage/curr_sim_code.json index 33ad340bc7..85bae21958 100644 --- a/environment/frontend_server/temp_storage/curr_sim_code.json +++ b/environment/frontend_server/temp_storage/curr_sim_code.json @@ -1,3 +1,3 @@ { - "sim_code": "33" + "sim_code": "so-2-s-3-599-799" } \ No newline at end of file diff --git a/print_conversations.py b/print_conversations.py index eb46405550..34de32d23f 100644 --- a/print_conversations.py +++ b/print_conversations.py @@ -1,4 +1,3 @@ -import os import glob import os import sys From ffbe85086a820dfdf6a87241e20f354a4f69147f Mon Sep 17 00:00:00 2001 From: Henry Lemersal Date: Mon, 14 Oct 2024 17:16:29 -0400 Subject: [PATCH 7/7] fix wrong sim_code --- environment/frontend_server/temp_storage/curr_sim_code.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/environment/frontend_server/temp_storage/curr_sim_code.json b/environment/frontend_server/temp_storage/curr_sim_code.json index 85bae21958..33ad340bc7 100644 --- a/environment/frontend_server/temp_storage/curr_sim_code.json +++ b/environment/frontend_server/temp_storage/curr_sim_code.json @@ -1,3 +1,3 @@ { - "sim_code": "so-2-s-3-599-799" + "sim_code": "33" } \ No newline at end of file