File size: 1,202 Bytes
0ce0b49 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
import os
import argparse
import json
user_names = [
'xcl', 'sx', 'pbw', 'jcy', 'wjy', 'wcx'
]
user_to_port = {
'pbw': 5002,
'jcy': 5011,
'xcl': 5021,
'sx': 5031,
'wjy': 5041,
'wcx': 5051,
}
total_data_num = 32016
data_per_user = total_data_num // len(user_names)
user_to_data_range = {
user: start_idx for user, start_idx in zip(
user_names,
range(1, total_data_num + 1, data_per_user)
)
}
def launch(user):
if user not in user_names:
raise ValueError(f"User {user} not recognized. Available users: {user_names}")
port = user_to_port[user]
start_idx = user_to_data_range[user]
command = f"python annotator/annotate.py --user {user} --port {port} --start_idx {start_idx}"
print(f"Launching for user {user} on port {port}")
os.system(command)
def parse_args():
parser = argparse.ArgumentParser(description="Launch annotation server for a specific user.")
parser.add_argument('--user', type=str, required=True, help='Username to launch the server for.')
args = parser.parse_args()
return args
def main():
args = parse_args()
launch(args.user)
if __name__ == "__main__":
main() |