lumos commited on
Commit
940cf83
·
1 Parent(s): 23b5833

更新README_CN:完整推送流程和格式要求

Browse files
Files changed (1) hide show
  1. README_CN.md +110 -60
README_CN.md CHANGED
@@ -4,99 +4,149 @@
4
 
5
  ```
6
  sre-challenge-dataset/
7
- ├── README.md # HuggingFace 数据集说明
8
  ├── README_CN.md # 中文使用说明(本文件)
9
- ├── data.jsonl # 数据文件(30道题)
10
- ├── data.parquet # 预构建 parquet(HF Viewer 需
11
- ├── add_case.py # 添加/删除/列出题目(自动生成 parquet)
12
  ├── gen_parquet.py # 从 data.jsonl 生成 data.parquet
13
  ├── gen_stats.py # 生成统计 badge 并更新 README
14
- ├── push_to_hf.py # 推送到 HuggingFace(自动生成 parquet
15
  └── import_from_timu.sh # 从 timu 文件夹批量导入
16
  ```
17
 
18
- ## 快速开始
19
 
20
- ### 1. 查看所有题目
 
 
 
 
21
  ```bash
22
- python3 add_case.py --list
23
  ```
24
 
25
- ### 2. 添加新题目(从文件夹)
 
 
 
26
  ```bash
27
- python3 add_case.py --from-folder /path/to/challenge-11-new-case
28
  ```
29
 
30
- ### 3. 添加新题目(手动指定)
 
 
 
31
  ```bash
32
- python3 add_case.py \
33
- --id "new-case" \
34
- --title "新题目" \
35
- --prompt "故障现象描述" \
36
- --case /path/to/case.json \
37
- --ideal /path/to/ideal-answer.json
 
 
 
 
 
 
 
 
 
 
 
38
  ```
39
 
40
- ### 4. 删除题目
 
41
  ```bash
42
- python3 add_case.py --delete phantom-timeout
 
 
43
  ```
44
 
45
- ### 5. 推送到 HuggingFace
46
- ```bash
47
- # 先登录
48
- huggingface-cli login
49
 
50
- # 推送
51
- python3 push_to_hf.py --repo your-username/sre-challenge-dataset
 
 
 
 
 
 
52
  ```
53
 
54
- ## 添加新题目的流程
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
 
56
- 1. 在 timu 文件夹创建新的 challenge 目录:
57
  ```
58
- /Users/Mai/Desktop/timu/challenge-11-new-case/
59
- ├── case.json # 题目信息
60
- ├── ideal-answer.json # 理想答案
 
61
  ├── inject.sh # 故障注入脚本
62
  └── recover.sh # 恢复脚本
63
  ```
64
 
65
  2. 运行导入命令:
66
  ```bash
67
- python3 add_case.py --from-folder /Users/Mai/Desktop/timu/challenge-11-new-case
68
  ```
69
 
70
- 3. 推送到 HuggingFace:
71
- ```bash
72
- python3 push_to_hf.py --repo your-username/sre-challenge-dataset
73
- ```
74
 
75
- ## 数据格式
76
 
77
- 每条数据的格式:
78
- ```json
79
- {
80
- "canary": "phantom-timeout",
81
- "tags": {
82
- "layer": "混沌工程层",
83
- "sub_category": "多故障与干扰",
84
- "faults": ["IO延迟", "网络丢包", "Pod被杀死"],
85
- "difficulty": "hard",
86
- "scope": "multi-cloud"
87
- },
88
- "case": { ... },
89
- "ideal_answer": { ... },
90
- "prompt": "",
91
- "rubrics": [ ... ]
92
- }
93
- ```
94
 
95
- ## 注意事项
96
 
97
- - `data.jsonl` 是核心数据文件,备份很重要
98
- - 推送到 HuggingFace 需要先注册账号并登录
99
- - 每次修改后记得重新推送
100
- - **重要**:HF Dataset Viewer 无法自动转换深度嵌套 JSON,必须预构建 `data.parquet`
101
- - `add_case.py` 和 `push_to_hf.py` 会自动调用 `gen_parquet.py`
102
- - 如果直接编辑了 `data.jsonl`,记得手动运行 `python3 gen_parquet.py`
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
 
5
  ```
6
  sre-challenge-dataset/
7
+ ├── README.md # HuggingFace 数据集说明(英文元数据)
8
  ├── README_CN.md # 中文使用说明(本文件)
9
+ ├── data.jsonl # 核心数据文件(35道题)
10
+ ├── data.parquet # 预构建 parquet(HF Viewer 需)
11
+ ├── add_case.py # 添加/删除/列出题目
12
  ├── gen_parquet.py # 从 data.jsonl 生成 data.parquet
13
  ├── gen_stats.py # 生成统计 badge 并更新 README
14
+ ├── push_to_hf.py # 推送到 HuggingFace(已废弃,别用
15
  └── import_from_timu.sh # 从 timu 文件夹批量导入
16
  ```
17
 
18
+ ---
19
 
20
+ ## 推送全流程(重要!)
21
+
22
+ ### 第一步:修改数据
23
+
24
+ 编辑 `data.jsonl`,或用脚本添加题目:
25
  ```bash
26
+ python3 add_case.py --from-folder /path/to/challenge-xx-xxx
27
  ```
28
 
29
+ **注意**:添加新题目时必须包含 `rubrics.json`,不然评分标准是空的!
30
+
31
+ ### 第二步:生成 parquet
32
+
33
  ```bash
34
+ python3 gen_parquet.py
35
  ```
36
 
37
+ ### 第三步:上传 parquet 到 HuggingFace
38
+
39
+ **⚠️ parquet 是二进制文件,不能用 git 推送!必须用 Python API:**
40
+
41
  ```bash
42
+ python3 -c "
43
+ import os
44
+ os.environ['https_proxy'] = 'http://127.0.0.1:65533'
45
+ os.environ['http_proxy'] = 'http://127.0.0.1:65533'
46
+ os.environ['HF_TOKEN'] = open(os.path.expanduser('~/.cache/huggingface/token')).read().strip()
47
+
48
+ from huggingface_hub import HfApi
49
+ api = HfApi()
50
+ api.upload_file(
51
+ path_or_fileobj='data.parquet',
52
+ path_in_repo='data.parquet',
53
+ repo_id='kluoms/MultiCloudSRE-Ops',
54
+ repo_type='dataset',
55
+ commit_message='更新parquet'
56
+ )
57
+ print('上传成功!')
58
+ "
59
  ```
60
 
61
+ ### 第四步:git 推送代码文件
62
+
63
  ```bash
64
+ git add data.jsonl gen_parquet.py # 只添加代码文件,不要 add data.parquet
65
+ git commit -m "更新说明"
66
+ git push origin main
67
  ```
68
 
69
+ ---
 
 
 
70
 
71
+ ## 数据格式要求
72
+
73
+ ### tags 字段(数组格式)
74
+
75
+ ```json
76
+ {
77
+ "tags": ["定位", "混沌与题面治理", "I/O 延迟", "网络丢包", "Pod 被杀死", "hard", "multi-cloud"]
78
+ }
79
  ```
80
 
81
+ - 第1个:类型标签(发现/定位/度量 三选一)
82
+ - 第2个:分类(如:混沌与题面治理、配置与密钥、网络与协议)
83
+ - 中间:故障类型
84
+ - 倒数第2个:难度(easy/medium/hard)
85
+ - 最后一个:范围(single-cloud/multi-cloud)
86
+
87
+ ### JSON 字段格式化
88
+
89
+ `case`、`ideal_answer`、`rubrics` 等 JSON 字段在 parquet 中要有缩进,便于阅读:
90
+ ```python
91
+ json.dumps(v, ensure_ascii=False, indent=2)
92
+ ```
93
+
94
+ ---
95
+
96
+ ## 添加新题目完整流程
97
 
98
+ 1. 在 timu 文件夹创建目录:
99
  ```
100
+ /Users/Mai/Desktop/timu/36-40/challenge-36-xxx/
101
+ ├── case.json # 题目信息(必须)
102
+ ├── ideal-answer.json # 理想答案(必须)
103
+ ├── rubrics.json # 评分标准(必须!)
104
  ├── inject.sh # 故障注入脚本
105
  └── recover.sh # 恢复脚本
106
  ```
107
 
108
  2. 运行导入命令:
109
  ```bash
110
+ python3 add_case.py --from-folder /Users/Mai/Desktop/timu/36-40/challenge-36-xxx
111
  ```
112
 
113
+ 3. 按上面的推送流程操作
 
 
 
114
 
115
+ ---
116
 
117
+ ## 常见问题
118
+
119
+ ### Q: HuggingFace Dataset Viewer 显示乱码?
120
+ A: 检查 parquet 格式,tags 必须���数组,JSON 字段要有缩进。
121
+
122
+ ### Q: git push 被拒绝,提示 binary files?
123
+ A: parquet 不能用 git 推,用 Python API 上传。
124
+
125
+ ### Q: 新题目没有 rubrics?
126
+ A: 添加题目时必须有 `rubrics.json` 文件,不然评分标准是空的。
127
+
128
+ ### Q: 网络连接失败?
129
+ A: 设置代理 `export https_proxy=http://127.0.0.1:65533`
 
 
 
 
130
 
131
+ ---
132
 
133
+ ## 快速命令
134
+
135
+ ```bash
136
+ # 查看所有题目
137
+ python3 add_case.py --list
138
+
139
+ # 添加新题目
140
+ python3 add_case.py --from-folder /path/to/challenge-xx-xxx
141
+
142
+ # 删除题目
143
+ python3 add_case.py --delete phantom-timeout
144
+
145
+ # 生成 parquet
146
+ python3 gen_parquet.py
147
+
148
+ # 上传 parquet(用上面的 Python 脚本)
149
+
150
+ # git 推送
151
+ git add data.jsonl && git commit -m "更新" && git push origin main
152
+ ```