Terry Zhuo
commited on
Commit
·
9e6d628
1
Parent(s):
881554c
update
Browse files- app.py +13 -71
- azure_count_ip_data.py +43 -334
app.py
CHANGED
@@ -3,22 +3,9 @@ import gradio as gr
|
|
3 |
import pandas as pd
|
4 |
from datetime import datetime
|
5 |
import time
|
6 |
-
import
|
7 |
-
import importlib.util
|
8 |
-
import threading
|
9 |
from log_reader import RemoteLogReader
|
10 |
-
|
11 |
-
# Define the path for the azure_count_ip_data module
|
12 |
-
azure_count_ip_data_path = os.path.join(os.path.dirname(__file__), 'azure_count_ip_data.py')
|
13 |
-
|
14 |
-
# Import the module dynamically
|
15 |
-
spec = importlib.util.spec_from_file_location("azure_count_ip_data", azure_count_ip_data_path)
|
16 |
-
azure_count_ip_data = importlib.util.module_from_spec(spec)
|
17 |
-
spec.loader.exec_module(azure_count_ip_data)
|
18 |
-
|
19 |
-
# Get the functions we need
|
20 |
-
count_files_per_annotator = azure_count_ip_data.count_files_per_annotator
|
21 |
-
count_deduplicated_files_per_annotator = azure_count_ip_data.count_deduplicated_files_per_annotator
|
22 |
|
23 |
# Define the path for storing the data
|
24 |
DATA_DIR = os.path.join(os.path.dirname(__file__), 'data')
|
@@ -42,61 +29,18 @@ def load_stats():
|
|
42 |
last_update = f.read().strip()
|
43 |
return df, last_update
|
44 |
except (FileNotFoundError, pd.errors.EmptyDataError):
|
45 |
-
return pd.DataFrame(columns=['Annotator', '
|
46 |
|
47 |
def update_stats():
|
48 |
-
"""Get the latest battle statistics
|
49 |
try:
|
50 |
# Initialize RemoteLogReader
|
51 |
reader = RemoteLogReader()
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
unique_counts = count_deduplicated_files_per_annotator(reader)
|
58 |
-
|
59 |
-
# Combine the data into a single DataFrame
|
60 |
-
data = []
|
61 |
-
all_annotators = set(total_counts.keys()) | set(unique_counts.keys())
|
62 |
-
|
63 |
-
# Track totals for summary row
|
64 |
-
total_sum = 0
|
65 |
-
unique_sum = 0
|
66 |
-
|
67 |
-
for annotator in all_annotators:
|
68 |
-
total = total_counts.get(annotator, 0)
|
69 |
-
unique = unique_counts.get(annotator, 0)
|
70 |
-
# Calculate percentage of unique prompts
|
71 |
-
percentage = round((unique / total * 100) if total > 0 else 0, 1)
|
72 |
-
|
73 |
-
# Add to totals
|
74 |
-
total_sum += total
|
75 |
-
unique_sum += unique
|
76 |
-
|
77 |
-
data.append({
|
78 |
-
'Annotator': annotator,
|
79 |
-
'Total Count': total,
|
80 |
-
'Unique Count': unique,
|
81 |
-
'Unique %': f"{percentage}%"
|
82 |
-
})
|
83 |
-
|
84 |
-
# Add summary row
|
85 |
-
overall_percentage = round((unique_sum / total_sum * 100) if total_sum > 0 else 0, 1)
|
86 |
-
data.append({
|
87 |
-
'Annotator': 'TOTAL',
|
88 |
-
'Total Count': total_sum,
|
89 |
-
'Unique Count': unique_sum,
|
90 |
-
'Unique %': f"{overall_percentage}%"
|
91 |
-
})
|
92 |
-
|
93 |
-
# Convert to DataFrame and sort by total count, keeping TOTAL at the bottom
|
94 |
-
df = pd.DataFrame(data)
|
95 |
-
# Move TOTAL row to the end
|
96 |
-
df = pd.concat([
|
97 |
-
df[df['Annotator'] != 'TOTAL'].sort_values('Total Count', ascending=False),
|
98 |
-
df[df['Annotator'] == 'TOTAL']
|
99 |
-
]).reset_index(drop=True)
|
100 |
|
101 |
# Get current time
|
102 |
current_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
@@ -107,7 +51,7 @@ def update_stats():
|
|
107 |
return df, current_time
|
108 |
except Exception as e:
|
109 |
print(f"Error updating stats: {e}")
|
110 |
-
return pd.DataFrame(columns=['Annotator', '
|
111 |
|
112 |
def auto_update(state):
|
113 |
"""Background task to update stats every hour"""
|
@@ -142,7 +86,7 @@ def create_ui():
|
|
142 |
|
143 |
with gr.Blocks(title="Battle Count Statistics") as app:
|
144 |
gr.Markdown("# Battle Count Statistics")
|
145 |
-
gr.Markdown("Displays the count of battles per annotator.
|
146 |
|
147 |
with gr.Row():
|
148 |
last_update = gr.Textbox(
|
@@ -156,12 +100,10 @@ def create_ui():
|
|
156 |
value=get_current_stats,
|
157 |
interactive=False,
|
158 |
wrap=True,
|
159 |
-
column_widths=["40%", "20%", "20%", "20%"],
|
160 |
-
height=600
|
161 |
)
|
162 |
|
163 |
-
refresh_btn = gr.Button("Refresh Now")
|
164 |
-
refresh_btn.click(fn=manual_refresh, outputs=[output, last_update])
|
165 |
|
166 |
return app
|
167 |
|
|
|
3 |
import pandas as pd
|
4 |
from datetime import datetime
|
5 |
import time
|
6 |
+
from azure_count_ip_data import count_files_per_annotator
|
|
|
|
|
7 |
from log_reader import RemoteLogReader
|
8 |
+
import threading
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
# Define the path for storing the data
|
11 |
DATA_DIR = os.path.join(os.path.dirname(__file__), 'data')
|
|
|
29 |
last_update = f.read().strip()
|
30 |
return df, last_update
|
31 |
except (FileNotFoundError, pd.errors.EmptyDataError):
|
32 |
+
return pd.DataFrame(columns=['Annotator', 'Battle Count']), ""
|
33 |
|
34 |
def update_stats():
|
35 |
+
"""Get the latest battle statistics"""
|
36 |
try:
|
37 |
# Initialize RemoteLogReader
|
38 |
reader = RemoteLogReader()
|
39 |
+
# Get annotator counts using Azure storage
|
40 |
+
annotator_counts = count_files_per_annotator(reader)
|
41 |
+
# Convert to DataFrame for better display
|
42 |
+
df = pd.DataFrame(list(annotator_counts.items()), columns=['Annotator', 'Battle Count'])
|
43 |
+
df = df.sort_values('Battle Count', ascending=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
|
45 |
# Get current time
|
46 |
current_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
|
|
51 |
return df, current_time
|
52 |
except Exception as e:
|
53 |
print(f"Error updating stats: {e}")
|
54 |
+
return pd.DataFrame(columns=['Annotator', 'Battle Count']), ""
|
55 |
|
56 |
def auto_update(state):
|
57 |
"""Background task to update stats every hour"""
|
|
|
86 |
|
87 |
with gr.Blocks(title="Battle Count Statistics") as app:
|
88 |
gr.Markdown("# Battle Count Statistics")
|
89 |
+
gr.Markdown("Displays the count of valid battles per annotator. Updates automatically every hour.")
|
90 |
|
91 |
with gr.Row():
|
92 |
last_update = gr.Textbox(
|
|
|
100 |
value=get_current_stats,
|
101 |
interactive=False,
|
102 |
wrap=True,
|
|
|
|
|
103 |
)
|
104 |
|
105 |
+
# refresh_btn = gr.Button("Refresh Now")
|
106 |
+
# refresh_btn.click(fn=manual_refresh, outputs=[output, last_update])
|
107 |
|
108 |
return app
|
109 |
|
azure_count_ip_data.py
CHANGED
@@ -8,7 +8,6 @@ import re
|
|
8 |
import argparse
|
9 |
from typing import Dict, Set, Tuple, Optional, List, Union
|
10 |
from log_reader import RemoteLogReader
|
11 |
-
import csv
|
12 |
|
13 |
# List of IP addresses we care about
|
14 |
WHITELIST_IPS_DICT = {
|
@@ -61,47 +60,42 @@ WHITELIST_IPS = [ip for ips in WHITELIST_IPS_DICT.values() for ip in ips]
|
|
61 |
# Flatten username list for backward compatibility
|
62 |
WHITELIST_USERNAMES = [username for usernames in WHITELIST_USERNAMES_DICT.values() for username in usernames]
|
63 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
logging.basicConfig(level=logging.WARNING)
|
65 |
log = logging.getLogger(__name__)
|
66 |
|
67 |
-
# List of example prompts to exclude from counting
|
68 |
-
EXAMPLE_PROMPTS = [
|
69 |
-
"使用SVG绘制春节主题的动态图案,包括:1)一个红色的灯笼,带有金色的流苏 2)一个金色的福字,使用书法字体 3)背景添加一些烟花效果 4)在灯笼和福字周围添加一些祥云图案。确保图案布局美观,颜色搭配符合春节传统风格。",
|
70 |
-
"SVGを使用して日本の伝統的な和柄パターンを描画してください。1)波紋(さざなみ)模様 2)市松模様 3)麻の葉模様 4)雷文(らいもん)模様を含めてください。色は伝統的な日本の色(藍色、朱色、金色など)を使用し、レイアウトはバランスよく配置してください。",
|
71 |
-
"Write HTML with P5.js that simulates 25 particles in a vacuum space of a cylindrical container, bouncing within its boundaries. Use different colors for each ball and ensure they leave a trail showing their movement. Add a slow rotation of the container to give better view of what's going on in the scene. Make sure to create proper collision detection and physic rules to ensure particles remain in the container. Add an external spherical container. Add a slow zoom in and zoom out effect to the whole scene.",
|
72 |
-
"Write a Python script to scrape NVIDIA's stock price for the past month using the yfinance library. Clean the data and create an interactive visualization using Matplotlib. Include: 1) A candlestick chart showing daily price movements 2) A line chart with 7-day and 30-day moving averages. Add hover tooltips showing exact values and date. Make the layout professional with proper titles and axis labels.",
|
73 |
-
"Write a Python script that uses the Gradio library to create a functional calculator. The calculator should support basic arithmetic operations: addition, subtraction, multiplication, and division. It should have two input fields for numbers and a dropdown menu to select the operation.",
|
74 |
-
"Write a Todo list app using React.js. The app should allow users to add, delete, and mark tasks as completed. Include features like filtering tasks by status (completed, active), sorting tasks by priority, and displaying the total number of tasks.",
|
75 |
-
"Write a Python script using the Streamlit library to create a web application for uploading and displaying files. The app should allow users to upload files of type .csv or .txt. If a .csv file is uploaded, display its contents as a table using Streamlit's st.dataframe() method. If a .txt file is uploaded, display its content as plain text.",
|
76 |
-
"Write a Python function to solve the Trapping Rain Water problem. The function should take a list of non-negative integers representing the height of bars in a histogram and return the total amount of water trapped between the bars after raining. Use an efficient algorithm with a time complexity of O(n).",
|
77 |
-
"Create a simple Pygame script for a game where the player controls a bouncing ball that changes direction when it collides with the edges of the window. Add functionality for the player to control a paddle using arrow keys, aiming to keep the ball from touching the bottom of the screen. Include basic collision detection and a scoring system that increases as the ball bounces off the paddle. You need to add clickable buttons to start the game, and reset the game.",
|
78 |
-
"Create a financial management Dashboard using Vue.js, focusing on local data handling without APIs. Include features like a clean dashboard for tracking income and expenses, dynamic charts for visualizing finances, and a budget planner. Implement functionalities for adding, editing, and deleting transactions, as well as filtering by date or category. Ensure responsive design and smooth user interaction for an intuitive experience.",
|
79 |
-
"Create a Mermaid diagram to visualize a flowchart of a user login process. Include the following steps: User enters login credentials; Credentials are validated; If valid, the user is directed to the dashboard; If invalid, an error message is shown, and the user can retry or reset the password.",
|
80 |
-
"Write a Python function to calculate the Fibonacci sequence up to n numbers. Then write test cases to verify the function works correctly for edge cases like negative numbers, zero, and large inputs.",
|
81 |
-
"Build an HTML page for a Kanban board with three columns with Vue.js: To Do, In Progress, and Done. Each column should allow adding, moving, and deleting tasks. Implement drag-and-drop functionality using Vue Draggable and persist the state using Vuex.",
|
82 |
-
"Develop a Streamlit app that takes a CSV file as input and provides: 1) Basic statistics about the data 2) Interactive visualizations using Plotly 3) A data cleaning interface with options to handle missing values 4) An option to download the cleaned data.",
|
83 |
-
"Write an HTML page with embedded JavaScript that creates an interactive periodic table. Each element should display its properties on hover and allow filtering by category (metals, non-metals, etc.). Include a search bar to find elements by name or symbol.",
|
84 |
-
"Here's a Python function that sorts a list of dictionaries by a specified key:\n\n```python\ndef sort_dicts(data, key):\n return sorted(data, key=lambda x: x[key])\n```\n\nWrite test cases to verify the function works correctly for edge cases like empty lists, missing keys, and different data types. If you use unittest, please use `unittest.main(argv=['first-arg-is-ignored'], exit=False)` to run the tests.",
|
85 |
-
"Create a React component for a fitness tracker that shows: 1) Daily step count 2) Calories burned 3) Distance walked 4) A progress bar for daily goals.",
|
86 |
-
"Build a Vue.js dashboard for monitoring server health. Include: 1) Real-time CPU and memory usage graphs 2) Disk space visualization 3) Network activity monitor 4) Alerts for critical thresholds.",
|
87 |
-
"Write a C program that calculates and prints the first 100 prime numbers in a formatted table with 10 numbers per row. Include a function to check if a number is prime and use it in your solution.",
|
88 |
-
"Write a C++ program that implements a simple calculator using object-oriented programming. Create a Calculator class with methods for addition, subtraction, multiplication, and division. Include error handling for division by zero.",
|
89 |
-
"Write a Rust program that generates and prints a Pascal's Triangle with 10 rows. Format the output to center-align the numbers in each row.",
|
90 |
-
"Write a Java program that simulates a simple bank account system. Create a BankAccount class with methods for deposit, withdrawal, and balance inquiry. Include error handling for insufficient funds and demonstrate its usage with a few transactions.",
|
91 |
-
"Write a Go program that calculates and prints the Fibonacci sequence up to the 50th number. Format the output in a table with 5 numbers per row and include the index of each Fibonacci number.",
|
92 |
-
"Write a C program that calculates and prints a histogram of letter frequencies from a predefined string. Use ASCII art to display the histogram vertically.",
|
93 |
-
"Write a C++ program that implements a simple stack data structure with push, pop, and peek operations. Demonstrate its usage by reversing a predefined string using the stack.",
|
94 |
-
"Write a Rust program that calculates and prints the first 20 happy numbers. Include a function to check if a number is happy and use it in your solution.",
|
95 |
-
"Write a Java program that implements a simple binary search algorithm. Create a sorted array of integers and demonstrate searching for different values, including cases where the value is found and not found.",
|
96 |
-
"Write a Go program that generates and prints a multiplication table from 1 to 12. Format the output in a neat grid with proper alignment.",
|
97 |
-
"hello",
|
98 |
-
"Hello",
|
99 |
-
"hi",
|
100 |
-
"Hi",
|
101 |
-
"test",
|
102 |
-
"Test"
|
103 |
-
]
|
104 |
-
|
105 |
def get_ip_from_jsonl(content: str) -> Optional[str]:
|
106 |
"""Extract IP from the first line of a JSONL content"""
|
107 |
try:
|
@@ -166,8 +160,9 @@ def get_file_data(content: str) -> Tuple[Optional[str], Optional[str], bool]:
|
|
166 |
"""Read file content and return IP, username, and vote condition status"""
|
167 |
try:
|
168 |
lines = [line.strip() for line in content.split('\n') if line.strip()]
|
|
|
169 |
if not lines:
|
170 |
-
return None, None, False
|
171 |
|
172 |
# Get IP from first line
|
173 |
try:
|
@@ -221,12 +216,12 @@ def get_file_data(content: str) -> Tuple[Optional[str], Optional[str], bool]:
|
|
221 |
|
222 |
# Early return if neither IP nor username is in whitelist
|
223 |
if not (ip_in_whitelist or username_in_whitelist):
|
224 |
-
return ip, username, False
|
225 |
|
226 |
return ip, username, vote_conditions_met
|
227 |
except Exception as e:
|
228 |
log.error(f"Error processing file content: {e}")
|
229 |
-
return None, None, False
|
230 |
|
231 |
def get_annotator_name(ip: Optional[str], username: Optional[str]) -> Optional[str]:
|
232 |
"""Get annotator name from IP or username"""
|
@@ -244,187 +239,11 @@ def get_annotator_name(ip: Optional[str], username: Optional[str]) -> Optional[s
|
|
244 |
|
245 |
return None
|
246 |
|
247 |
-
def get_first_user_prompt(content: str) -> Optional[str]:
|
248 |
-
"""Extract the first user prompt from the conversation content"""
|
249 |
-
try:
|
250 |
-
lines = [line.strip() for line in content.split('\n') if line.strip()]
|
251 |
-
if not lines:
|
252 |
-
return None
|
253 |
-
|
254 |
-
# Parse the first line to get the messages
|
255 |
-
first_line_data = json.loads(lines[0])
|
256 |
-
|
257 |
-
# Try different message formats
|
258 |
-
|
259 |
-
# Format 1: state.messages array with ["<|im_start|>user", "hello"] format
|
260 |
-
messages = first_line_data.get('state', {}).get('messages', [])
|
261 |
-
if messages and len(messages) > 0:
|
262 |
-
first_message = messages[0]
|
263 |
-
if isinstance(first_message, list) and len(first_message) > 1:
|
264 |
-
# Format: ["<|im_start|>user", "hello"]
|
265 |
-
message_content = first_message[1]
|
266 |
-
# Ensure message_content is a string
|
267 |
-
if isinstance(message_content, str):
|
268 |
-
return message_content
|
269 |
-
elif isinstance(message_content, list):
|
270 |
-
# If it's a list, try to join it or get the first element
|
271 |
-
if message_content and all(isinstance(item, str) for item in message_content):
|
272 |
-
return ' '.join(message_content)
|
273 |
-
elif message_content and isinstance(message_content[0], str):
|
274 |
-
return message_content[0]
|
275 |
-
return str(message_content) if message_content else None
|
276 |
-
|
277 |
-
# Format 2: state.messages array with {"role": "user", "content": "hello"} format
|
278 |
-
if messages and len(messages) > 0:
|
279 |
-
first_message = messages[0]
|
280 |
-
if isinstance(first_message, dict) and 'content' in first_message:
|
281 |
-
message_content = first_message.get('content')
|
282 |
-
# Ensure message_content is a string
|
283 |
-
if isinstance(message_content, str):
|
284 |
-
return message_content
|
285 |
-
elif isinstance(message_content, list):
|
286 |
-
# If it's a list, try to join it or get the first element
|
287 |
-
if message_content and all(isinstance(item, str) for item in message_content):
|
288 |
-
return ' '.join(message_content)
|
289 |
-
elif message_content and isinstance(message_content[0], str):
|
290 |
-
return message_content[0]
|
291 |
-
return str(message_content) if message_content else None
|
292 |
-
|
293 |
-
# Format 3: Direct messages array in the root
|
294 |
-
messages = first_line_data.get('messages', [])
|
295 |
-
if messages and len(messages) > 0:
|
296 |
-
first_message = messages[0]
|
297 |
-
if isinstance(first_message, list) and len(first_message) > 1:
|
298 |
-
message_content = first_message[1]
|
299 |
-
# Ensure message_content is a string
|
300 |
-
if isinstance(message_content, str):
|
301 |
-
return message_content
|
302 |
-
elif isinstance(message_content, list):
|
303 |
-
# If it's a list, try to join it or get the first element
|
304 |
-
if message_content and all(isinstance(item, str) for item in message_content):
|
305 |
-
return ' '.join(message_content)
|
306 |
-
elif message_content and isinstance(message_content[0], str):
|
307 |
-
return message_content[0]
|
308 |
-
return str(message_content) if message_content else None
|
309 |
-
elif isinstance(first_message, dict) and 'content' in first_message:
|
310 |
-
message_content = first_message.get('content')
|
311 |
-
# Ensure message_content is a string
|
312 |
-
if isinstance(message_content, str):
|
313 |
-
return message_content
|
314 |
-
elif isinstance(message_content, list):
|
315 |
-
# If it's a list, try to join it or get the first element
|
316 |
-
if message_content and all(isinstance(item, str) for item in message_content):
|
317 |
-
return ' '.join(message_content)
|
318 |
-
elif message_content and isinstance(message_content[0], str):
|
319 |
-
return message_content[0]
|
320 |
-
return str(message_content) if message_content else None
|
321 |
-
|
322 |
-
# Format 4: Look for a specific user role key
|
323 |
-
for key in ['user', 'human', 'Human']:
|
324 |
-
if key in first_line_data:
|
325 |
-
message_content = first_line_data[key]
|
326 |
-
# Ensure message_content is a string
|
327 |
-
if isinstance(message_content, str):
|
328 |
-
return message_content
|
329 |
-
elif isinstance(message_content, list):
|
330 |
-
# If it's a list, try to join it or get the first element
|
331 |
-
if message_content and all(isinstance(item, str) for item in message_content):
|
332 |
-
return ' '.join(message_content)
|
333 |
-
elif message_content and isinstance(message_content[0], str):
|
334 |
-
return message_content[0]
|
335 |
-
return str(message_content) if message_content else None
|
336 |
-
|
337 |
-
log.warning(f"Could not extract first user prompt from content: {content[:200]}...")
|
338 |
-
return None
|
339 |
-
except Exception as e:
|
340 |
-
log.error(f"Error extracting first user prompt: {e}")
|
341 |
-
return None
|
342 |
-
|
343 |
-
def get_unique_prompts_per_annotator(reader: 'RemoteLogReader', start_date_str: str = "2025_02_18") -> Dict[str, Set[str]]:
|
344 |
-
"""Get the set of unique prompts for each annotator from the given start date
|
345 |
-
|
346 |
-
Only includes conversations that pass the vote conditions.
|
347 |
-
Excludes prompts from the predefined list of example prompts.
|
348 |
-
"""
|
349 |
-
# Convert start date string to datetime
|
350 |
-
start_date = datetime.strptime(start_date_str, "%Y_%m_%d")
|
351 |
-
|
352 |
-
# Dictionary to store unique prompts per annotator
|
353 |
-
annotator_prompts = defaultdict(set)
|
354 |
-
|
355 |
-
try:
|
356 |
-
# Get current date for iteration
|
357 |
-
current_date = start_date
|
358 |
-
today = datetime.now()
|
359 |
-
|
360 |
-
while current_date <= today:
|
361 |
-
date_str = current_date.strftime("%Y_%m_%d")
|
362 |
-
|
363 |
-
try:
|
364 |
-
# Get conversation logs for battle_anony mode
|
365 |
-
conv_logs = reader.get_conv_logs(date_str)
|
366 |
-
battle_anony_logs = conv_logs.get('battle_anony', {})
|
367 |
-
|
368 |
-
# Process each conversation
|
369 |
-
for conv_id, messages in battle_anony_logs.items():
|
370 |
-
if messages:
|
371 |
-
try:
|
372 |
-
# Convert messages to file content format
|
373 |
-
content = '\n'.join(json.dumps(msg) for msg in messages)
|
374 |
-
|
375 |
-
# First check if the conversation passes the vote conditions
|
376 |
-
ip, username, vote_conditions_met = get_file_data(content)
|
377 |
-
|
378 |
-
# Only proceed if vote conditions are met
|
379 |
-
if vote_conditions_met:
|
380 |
-
# Get annotator name from either IP or username
|
381 |
-
annotator_name = get_annotator_name(ip, username)
|
382 |
-
if annotator_name:
|
383 |
-
# Extract first user prompt
|
384 |
-
try:
|
385 |
-
first_prompt = get_first_user_prompt(content)
|
386 |
-
if first_prompt:
|
387 |
-
# Strip whitespace and check if it's not in the example prompts list
|
388 |
-
cleaned_prompt = first_prompt.strip()
|
389 |
-
if cleaned_prompt and cleaned_prompt not in EXAMPLE_PROMPTS:
|
390 |
-
# Add to set of unique prompts for this annotator
|
391 |
-
annotator_prompts[annotator_name].add(cleaned_prompt.lower())
|
392 |
-
else:
|
393 |
-
log.warning(f"Could not extract first user prompt for conversation {conv_id}")
|
394 |
-
except Exception as e:
|
395 |
-
log.error(f"Error processing first prompt for conversation {conv_id}: {e}")
|
396 |
-
except Exception as e:
|
397 |
-
log.error(f"Error processing conversation {conv_id}: {e}")
|
398 |
-
|
399 |
-
except Exception as e:
|
400 |
-
log.error(f"Error processing logs for date {date_str}: {e}")
|
401 |
-
|
402 |
-
# Move to next day
|
403 |
-
current_date += timedelta(days=1)
|
404 |
-
|
405 |
-
except Exception as e:
|
406 |
-
log.error(f"Error accessing logs: {e}")
|
407 |
-
|
408 |
-
return dict(annotator_prompts)
|
409 |
-
|
410 |
-
def count_deduplicated_files_per_annotator(reader: 'RemoteLogReader', start_date_str: str = "2025_02_18") -> Dict[str, int]:
|
411 |
-
"""Count deduplicated files per annotator name from the given start date, considering both IP and username
|
412 |
-
|
413 |
-
Deduplication is based on the first user prompt for each annotator.
|
414 |
-
Only counts conversations that pass the vote conditions.
|
415 |
-
Excludes prompts from the predefined list of example prompts.
|
416 |
-
"""
|
417 |
-
# Get the unique prompts for each annotator
|
418 |
-
annotator_prompts = get_unique_prompts_per_annotator(reader, start_date_str)
|
419 |
-
|
420 |
-
# Convert sets to counts
|
421 |
-
return {name: len(prompts) for name, prompts in annotator_prompts.items()}
|
422 |
-
|
423 |
def count_files_per_annotator(reader: 'RemoteLogReader', start_date_str: str = "2025_02_18") -> Dict[str, int]:
|
424 |
"""Count files per annotator name from the given start date, considering both IP and username"""
|
425 |
# Convert start date string to datetime
|
426 |
start_date = datetime.strptime(start_date_str, "%Y_%m_%d")
|
427 |
-
|
428 |
try:
|
429 |
# Get current date for iteration
|
430 |
current_date = start_date
|
@@ -442,13 +261,13 @@ def count_files_per_annotator(reader: 'RemoteLogReader', start_date_str: str = "
|
|
442 |
if messages:
|
443 |
# Convert messages to file content format
|
444 |
content = '\n'.join(json.dumps(msg) for msg in messages)
|
445 |
-
ip, username, vote_conditions_met = get_file_data(content)
|
446 |
|
447 |
if vote_conditions_met:
|
448 |
# Get annotator name from either IP or username
|
449 |
annotator_name = get_annotator_name(ip, username)
|
450 |
-
if annotator_name:
|
451 |
-
|
452 |
|
453 |
except Exception as e:
|
454 |
log.error(f"Error processing logs for date {date_str}: {e}")
|
@@ -459,7 +278,7 @@ def count_files_per_annotator(reader: 'RemoteLogReader', start_date_str: str = "
|
|
459 |
except Exception as e:
|
460 |
log.error(f"Error accessing logs: {e}")
|
461 |
|
462 |
-
return
|
463 |
|
464 |
def download_files_by_name(reader: 'RemoteLogReader', start_date_str: str = "2025_02_18", check_sandbox: bool = True) -> None:
|
465 |
"""Download files and organize them by annotator name
|
@@ -540,85 +359,6 @@ def download_files_by_name(reader: 'RemoteLogReader', start_date_str: str = "202
|
|
540 |
except Exception as e:
|
541 |
log.error(f"Error accessing logs: {e}")
|
542 |
|
543 |
-
def export_unique_prompts_to_csv(reader: 'RemoteLogReader', output_file: str, start_date_str: str = "2025_02_18") -> None:
|
544 |
-
"""Export the unique prompts for each annotator to a CSV file
|
545 |
-
|
546 |
-
Args:
|
547 |
-
reader: RemoteLogReader instance
|
548 |
-
output_file: Path to the output CSV file
|
549 |
-
start_date_str: The start date in YYYY_MM_DD format
|
550 |
-
"""
|
551 |
-
# Get the unique prompts for each annotator
|
552 |
-
annotator_prompts = get_unique_prompts_per_annotator(reader, start_date_str)
|
553 |
-
|
554 |
-
# Prepare data for CSV
|
555 |
-
rows = []
|
556 |
-
for annotator, prompts in annotator_prompts.items():
|
557 |
-
for prompt in prompts:
|
558 |
-
rows.append({
|
559 |
-
'Annotator': annotator,
|
560 |
-
'Prompt': prompt
|
561 |
-
})
|
562 |
-
|
563 |
-
# Write to CSV
|
564 |
-
with open(output_file, 'w', newline='', encoding='utf-8') as f:
|
565 |
-
writer = csv.DictWriter(f, fieldnames=['Annotator', 'Prompt'])
|
566 |
-
writer.writeheader()
|
567 |
-
writer.writerows(rows)
|
568 |
-
|
569 |
-
print(f"Exported {len(rows)} unique prompts to {output_file}")
|
570 |
-
|
571 |
-
def debug_problematic_conversations(reader: 'RemoteLogReader', date_str: str) -> None:
|
572 |
-
"""Debug function to identify problematic conversations for a specific date
|
573 |
-
|
574 |
-
Args:
|
575 |
-
reader: RemoteLogReader instance
|
576 |
-
date_str: The date in YYYY_MM_DD format
|
577 |
-
"""
|
578 |
-
try:
|
579 |
-
# Get conversation logs for battle_anony mode
|
580 |
-
conv_logs = reader.get_conv_logs(date_str)
|
581 |
-
battle_anony_logs = conv_logs.get('battle_anony', {})
|
582 |
-
|
583 |
-
print(f"Found {len(battle_anony_logs)} conversations for date {date_str}")
|
584 |
-
|
585 |
-
# Process each conversation
|
586 |
-
for conv_id, messages in battle_anony_logs.items():
|
587 |
-
if not messages:
|
588 |
-
continue
|
589 |
-
|
590 |
-
try:
|
591 |
-
# Convert messages to file content format
|
592 |
-
content = '\n'.join(json.dumps(msg) for msg in messages)
|
593 |
-
|
594 |
-
# Check if the conversation passes the vote conditions
|
595 |
-
ip, username, vote_conditions_met = get_file_data(content)
|
596 |
-
|
597 |
-
if vote_conditions_met:
|
598 |
-
# Get annotator name from either IP or username
|
599 |
-
annotator_name = get_annotator_name(ip, username)
|
600 |
-
if annotator_name:
|
601 |
-
# Try to extract first user prompt
|
602 |
-
try:
|
603 |
-
first_prompt = get_first_user_prompt(content)
|
604 |
-
if first_prompt:
|
605 |
-
print(f"Conversation {conv_id} - Annotator: {annotator_name} - First prompt: {first_prompt[:50]}...")
|
606 |
-
else:
|
607 |
-
print(f"WARNING: Could not extract first user prompt for conversation {conv_id} - Annotator: {annotator_name}")
|
608 |
-
# Print the first line of the content for debugging
|
609 |
-
first_line = content.split('\n')[0]
|
610 |
-
print(f"First line: {first_line[:200]}...")
|
611 |
-
except Exception as e:
|
612 |
-
print(f"ERROR: Error processing first prompt for conversation {conv_id}: {e}")
|
613 |
-
# Print the first line of the content for debugging
|
614 |
-
first_line = content.split('\n')[0]
|
615 |
-
print(f"First line: {first_line[:200]}...")
|
616 |
-
except Exception as e:
|
617 |
-
print(f"ERROR: Error processing conversation {conv_id}: {e}")
|
618 |
-
|
619 |
-
except Exception as e:
|
620 |
-
print(f"ERROR: Error processing logs for date {date_str}: {e}")
|
621 |
-
|
622 |
def main():
|
623 |
# Initialize RemoteLogReader
|
624 |
reader = RemoteLogReader()
|
@@ -627,49 +367,18 @@ def main():
|
|
627 |
parser = argparse.ArgumentParser(description='Download and organize conversation files by annotator name')
|
628 |
parser.add_argument('--sandbox-check', action='store_true', help='Check for matching sandbox logs')
|
629 |
parser.add_argument('--download', action='store_true', help='Enable file download')
|
630 |
-
parser.add_argument('--export-prompts', action='store_true', help='Export unique prompts to CSV')
|
631 |
-
parser.add_argument('--output-file', default='unique_prompts.csv', help='Output file for unique prompts (default: unique_prompts.csv)')
|
632 |
-
parser.add_argument('--debug-date', help='Debug problematic conversations for a specific date (format: YYYY_MM_DD)')
|
633 |
args = parser.parse_args()
|
634 |
|
635 |
-
# Debug problematic conversations if date is provided
|
636 |
-
if args.debug_date:
|
637 |
-
print(f"\nDebugging problematic conversations for date {args.debug_date}...")
|
638 |
-
debug_problematic_conversations(reader, args.debug_date)
|
639 |
-
return
|
640 |
-
|
641 |
# Download files if enabled
|
642 |
if args.download:
|
643 |
print("\nDownloading files and organizing by annotator name...")
|
644 |
download_files_by_name(reader, check_sandbox=args.sandbox_check)
|
645 |
|
646 |
-
# Export unique prompts if enabled
|
647 |
-
if args.export_prompts:
|
648 |
-
print(f"\nExporting unique prompts to {args.output_file}...")
|
649 |
-
export_unique_prompts_to_csv(reader, args.output_file)
|
650 |
-
|
651 |
# Count and display statistics
|
652 |
name_counts = count_files_per_annotator(reader)
|
653 |
-
unique_counts = count_deduplicated_files_per_annotator(reader)
|
654 |
-
|
655 |
print("\nFile counts per annotator:")
|
656 |
-
print(f"{'Name':<20} {'Total':<10} {'Unique':<10} {'Unique %':<10}")
|
657 |
-
print("-" * 50)
|
658 |
-
|
659 |
-
# Calculate totals
|
660 |
-
total_sum = sum(name_counts.values())
|
661 |
-
unique_sum = sum(unique_counts.values())
|
662 |
-
|
663 |
-
# Display counts for each annotator
|
664 |
for name, count in sorted(name_counts.items(), key=lambda x: x[1], reverse=True):
|
665 |
-
|
666 |
-
percentage = round((unique / count * 100) if count > 0 else 0, 1)
|
667 |
-
print(f"{name:<20} {count:<10} {unique:<10} {percentage:<10}%")
|
668 |
-
|
669 |
-
# Display totals
|
670 |
-
overall_percentage = round((unique_sum / total_sum * 100) if total_sum > 0 else 0, 1)
|
671 |
-
print("-" * 50)
|
672 |
-
print(f"{'TOTAL':<20} {total_sum:<10} {unique_sum:<10} {overall_percentage:<10}%")
|
673 |
|
674 |
if __name__ == "__main__":
|
675 |
main()
|
|
|
8 |
import argparse
|
9 |
from typing import Dict, Set, Tuple, Optional, List, Union
|
10 |
from log_reader import RemoteLogReader
|
|
|
11 |
|
12 |
# List of IP addresses we care about
|
13 |
WHITELIST_IPS_DICT = {
|
|
|
60 |
# Flatten username list for backward compatibility
|
61 |
WHITELIST_USERNAMES = [username for usernames in WHITELIST_USERNAMES_DICT.values() for username in usernames]
|
62 |
|
63 |
+
EXAMPLES = [
|
64 |
+
["使用SVG绘制春节主题的动态图案,包括:1)一个红色的灯笼,带有金色的流苏 2)一个金色的福字,使用书法字体 3)背景添加一些烟花效果 4)在灯笼和福字周围添加一些祥云图案。确保图案布局美观,颜色搭配符合春节传统风格。"],
|
65 |
+
["SVGを使用して日本の伝統的な和柄パターンを描画してください。1)波紋(さざなみ)模様 2)市松模様 3)麻の葉模様 4)雷文(らいもん)模様を含めてください。色は伝統的な日本の色(藍色、朱色、金色など)を使用し、レイアウトはバランスよく配置してください。"],
|
66 |
+
["Write HTML with P5.js that simulates 25 particles in a vacuum space of a cylindrical container, bouncing within its boundaries. Use different colors for each ball and ensure they leave a trail showing their movement. Add a slow rotation of the container to give better view of what's going on in the scene. Make sure to create proper collision detection and physic rules to ensure particles remain in the container. Add an external spherical container. Add a slow zoom in and zoom out effect to the whole scene."],
|
67 |
+
["Write a Python script to scrape NVIDIA's stock price for the past month using the yfinance library. Clean the data and create an interactive visualization using Matplotlib. Include: 1) A candlestick chart showing daily price movements 2) A line chart with 7-day and 30-day moving averages. Add hover tooltips showing exact values and date. Make the layout professional with proper titles and axis labels."],
|
68 |
+
["Write a Python script that uses the Gradio library to create a functional calculator. The calculator should support basic arithmetic operations: addition, subtraction, multiplication, and division. It should have two input fields for numbers and a dropdown menu to select the operation."],
|
69 |
+
["Write a Todo list app using React.js. The app should allow users to add, delete, and mark tasks as completed. Include features like filtering tasks by status (completed, active), sorting tasks by priority, and displaying the total number of tasks."],
|
70 |
+
["Write a Python script using the Streamlit library to create a web application for uploading and displaying files. The app should allow users to upload files of type .csv or .txt. If a .csv file is uploaded, display its contents as a table using Streamlit's st.dataframe() method. If a .txt file is uploaded, display its content as plain text."],
|
71 |
+
["Write a Python function to solve the Trapping Rain Water problem. The function should take a list of non-negative integers representing the height of bars in a histogram and return the total amount of water trapped between the bars after raining. Use an efficient algorithm with a time complexity of O(n)."],
|
72 |
+
["Create a simple Pygame script for a game where the player controls a bouncing ball that changes direction when it collides with the edges of the window. Add functionality for the player to control a paddle using arrow keys, aiming to keep the ball from touching the bottom of the screen. Include basic collision detection and a scoring system that increases as the ball bounces off the paddle. You need to add clickable buttons to start the game, and reset the game."],
|
73 |
+
["Create a financial management Dashboard using Vue.js, focusing on local data handling without APIs. Include features like a clean dashboard for tracking income and expenses, dynamic charts for visualizing finances, and a budget planner. Implement functionalities for adding, editing, and deleting transactions, as well as filtering by date or category. Ensure responsive design and smooth user interaction for an intuitive experience."],
|
74 |
+
["Create a Mermaid diagram to visualize a flowchart of a user login process. Include the following steps: User enters login credentials; Credentials are validated; If valid, the user is directed to the dashboard; If invalid, an error message is shown, and the user can retry or reset the password."],
|
75 |
+
["Write a Python function to calculate the Fibonacci sequence up to n numbers. Then write test cases to verify the function works correctly for edge cases like negative numbers, zero, and large inputs."],
|
76 |
+
["Build an HTML page for a Kanban board with three columns with Vue.js: To Do, In Progress, and Done. Each column should allow adding, moving, and deleting tasks. Implement drag-and-drop functionality using Vue Draggable and persist the state using Vuex."],
|
77 |
+
["Develop a Streamlit app that takes a CSV file as input and provides: 1) Basic statistics about the data 2) Interactive visualizations using Plotly 3) A data cleaning interface with options to handle missing values 4) An option to download the cleaned data."],
|
78 |
+
["Write an HTML page with embedded JavaScript that creates an interactive periodic table. Each element should display its properties on hover and allow filtering by category (metals, non-metals, etc.). Include a search bar to find elements by name or symbol."],
|
79 |
+
["Here's a Python function that sorts a list of dictionaries by a specified key:\n\n```python\ndef sort_dicts(data, key):\n return sorted(data, key=lambda x: x[key])\n```\n\nWrite test cases to verify the function works correctly for edge cases like empty lists, missing keys, and different data types. If you use unittest, please use `unittest.main(argv=['first-arg-is-ignored'], exit=False)` to run the tests."],
|
80 |
+
["Create a React component for a fitness tracker that shows: 1) Daily step count 2) Calories burned 3) Distance walked 4) A progress bar for daily goals."],
|
81 |
+
["Build a Vue.js dashboard for monitoring server health. Include: 1) Real-time CPU and memory usage graphs 2) Disk space visualization 3) Network activity monitor 4) Alerts for critical thresholds."],
|
82 |
+
["Write a C program that calculates and prints the first 100 prime numbers in a formatted table with 10 numbers per row. Include a function to check if a number is prime and use it in your solution."],
|
83 |
+
["Write a C++ program that implements a simple calculator using object-oriented programming. Create a Calculator class with methods for addition, subtraction, multiplication, and division. Include error handling for division by zero."],
|
84 |
+
["Write a Rust program that generates and prints a Pascal's Triangle with 10 rows. Format the output to center-align the numbers in each row."],
|
85 |
+
["Write a Java program that simulates a simple bank account system. Create a BankAccount class with methods for deposit, withdrawal, and balance inquiry. Include error handling for insufficient funds and demonstrate its usage with a few transactions."],
|
86 |
+
["Write a Go program that calculates and prints the Fibonacci sequence up to the 50th number. Format the output in a table with 5 numbers per row and include the index of each Fibonacci number."],
|
87 |
+
["Write a C program that calculates and prints a histogram of letter frequencies from a predefined string. Use ASCII art to display the histogram vertically."],
|
88 |
+
["Write a C++ program that implements a simple stack data structure with push, pop, and peek operations. Demonstrate its usage by reversing a predefined string using the stack."],
|
89 |
+
["Write a Rust program that calculates and prints the first 20 happy numbers. Include a function to check if a number is happy and use it in your solution."],
|
90 |
+
["Write a Java program that implements a simple binary search algorithm. Create a sorted array of integers and demonstrate searching for different values, including cases where the value is found and not found."],
|
91 |
+
["Write a Go program that generates and prints a multiplication table from 1 to 12. Format the output in a neat grid with proper alignment."],
|
92 |
+
]
|
93 |
+
|
94 |
+
EXAMPLES = [e[0] for e in EXAMPLES]
|
95 |
+
|
96 |
logging.basicConfig(level=logging.WARNING)
|
97 |
log = logging.getLogger(__name__)
|
98 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
99 |
def get_ip_from_jsonl(content: str) -> Optional[str]:
|
100 |
"""Extract IP from the first line of a JSONL content"""
|
101 |
try:
|
|
|
160 |
"""Read file content and return IP, username, and vote condition status"""
|
161 |
try:
|
162 |
lines = [line.strip() for line in content.split('\n') if line.strip()]
|
163 |
+
user_prompt = lines[0]["messages"][0][1]
|
164 |
if not lines:
|
165 |
+
return None, None, False, user_prompt
|
166 |
|
167 |
# Get IP from first line
|
168 |
try:
|
|
|
216 |
|
217 |
# Early return if neither IP nor username is in whitelist
|
218 |
if not (ip_in_whitelist or username_in_whitelist):
|
219 |
+
return ip, username, False, user_prompt
|
220 |
|
221 |
return ip, username, vote_conditions_met
|
222 |
except Exception as e:
|
223 |
log.error(f"Error processing file content: {e}")
|
224 |
+
return None, None, False, user_prompt
|
225 |
|
226 |
def get_annotator_name(ip: Optional[str], username: Optional[str]) -> Optional[str]:
|
227 |
"""Get annotator name from IP or username"""
|
|
|
239 |
|
240 |
return None
|
241 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
242 |
def count_files_per_annotator(reader: 'RemoteLogReader', start_date_str: str = "2025_02_18") -> Dict[str, int]:
|
243 |
"""Count files per annotator name from the given start date, considering both IP and username"""
|
244 |
# Convert start date string to datetime
|
245 |
start_date = datetime.strptime(start_date_str, "%Y_%m_%d")
|
246 |
+
name_prompts = defaultdict(set)
|
247 |
try:
|
248 |
# Get current date for iteration
|
249 |
current_date = start_date
|
|
|
261 |
if messages:
|
262 |
# Convert messages to file content format
|
263 |
content = '\n'.join(json.dumps(msg) for msg in messages)
|
264 |
+
ip, username, vote_conditions_met, user_prompt = get_file_data(content)
|
265 |
|
266 |
if vote_conditions_met:
|
267 |
# Get annotator name from either IP or username
|
268 |
annotator_name = get_annotator_name(ip, username)
|
269 |
+
if annotator_name and user_prompt not in EXAMPLES:
|
270 |
+
name_prompts[annotator_name].add(user_prompt.lower())
|
271 |
|
272 |
except Exception as e:
|
273 |
log.error(f"Error processing logs for date {date_str}: {e}")
|
|
|
278 |
except Exception as e:
|
279 |
log.error(f"Error accessing logs: {e}")
|
280 |
|
281 |
+
return {name: len(prompts) for name, prompts in name_prompts.items()}
|
282 |
|
283 |
def download_files_by_name(reader: 'RemoteLogReader', start_date_str: str = "2025_02_18", check_sandbox: bool = True) -> None:
|
284 |
"""Download files and organize them by annotator name
|
|
|
359 |
except Exception as e:
|
360 |
log.error(f"Error accessing logs: {e}")
|
361 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
362 |
def main():
|
363 |
# Initialize RemoteLogReader
|
364 |
reader = RemoteLogReader()
|
|
|
367 |
parser = argparse.ArgumentParser(description='Download and organize conversation files by annotator name')
|
368 |
parser.add_argument('--sandbox-check', action='store_true', help='Check for matching sandbox logs')
|
369 |
parser.add_argument('--download', action='store_true', help='Enable file download')
|
|
|
|
|
|
|
370 |
args = parser.parse_args()
|
371 |
|
|
|
|
|
|
|
|
|
|
|
|
|
372 |
# Download files if enabled
|
373 |
if args.download:
|
374 |
print("\nDownloading files and organizing by annotator name...")
|
375 |
download_files_by_name(reader, check_sandbox=args.sandbox_check)
|
376 |
|
|
|
|
|
|
|
|
|
|
|
377 |
# Count and display statistics
|
378 |
name_counts = count_files_per_annotator(reader)
|
|
|
|
|
379 |
print("\nFile counts per annotator:")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
380 |
for name, count in sorted(name_counts.items(), key=lambda x: x[1], reverse=True):
|
381 |
+
print(f"Name: {name:<20} Count: {count}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
382 |
|
383 |
if __name__ == "__main__":
|
384 |
main()
|