MCPcopy Create free account
hub / github.com/OpenRaiser/PaperFlow / main

Function main

scripts/init_user_metadata.py:80–124  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

78
79
80def main():
81 parser = argparse.ArgumentParser(description="Initialize User Metadata")
82 parser.add_argument("--roles-path", type=str, default="data/roles.json", help="roles.json 路径")
83 parser.add_argument("--db-path", type=str, default="data/paperflow.db", help="数据库路径")
84 parser.add_argument("--output-dir", type=str, default="data/simulation_output", help="输出目录")
85 args = parser.parse_args()
86
87 # 加载数据
88 print(f"Loading roles from {args.roles_path}...")
89 roles = load_roles(args.roles_path)
90 print(f" Found {len(roles)} roles")
91
92 print(f"Loading profiles from {args.db_path}...")
93 profiles = load_profiles(args.db_path)
94 print(f" Found {len(profiles)} profiles")
95
96 # 初始化用户元数据
97 users = init_user_metadata(roles, profiles)
98
99 # 输出
100 output_dir = Path(args.output_dir)
101 if not output_dir.is_absolute():
102 output_dir = PROJECT_ROOT / output_dir
103
104 output_dir.mkdir(parents=True, exist_ok=True)
105
106 output_path = output_dir / "users.json"
107
108 with output_path.open("w", encoding="utf-8") as f:
109 json.dump({"users": users}, f, ensure_ascii=False, indent=2)
110
111 print()
112 print("=" * 60)
113 print("User Metadata Initialized")
114 print("=" * 60)
115 print(f"Users: {len(users)}")
116 print(f"Output: {output_path}")
117
118 # 打印预览
119 print()
120 print("Preview:")
121 for user in users[:5]:
122 print(f" - {user['user_id']} ({user['role_name']}): {len(user['seed_directions'])} directions")
123 if len(users) > 5:
124 print(f" ... and {len(users) - 5} more")
125
126
127if __name__ == "__main__":

Callers 1

Calls 3

load_profilesFunction · 0.85
init_user_metadataFunction · 0.85
load_rolesFunction · 0.70

Tested by

no test coverage detected