已合并
[RFC]: 刷新代码格式——mindie_llm #905
KaiMa创建于 4月16日
[RFC]: 刷新代码格式——mindie_llm #905
已合并
Pull Request已成功合入, 合并人@ascend-robot
(感谢 KaiMa 的贡献)4月16日 关联了issue:[RFC]: 刷新代码格式
4月16日 添加了label:stat/needs-squash
ascend-robot
4月16日 评论:
4月16日 评论:
Thanks for your pull-request.
The full list of commands accepted by me can be found at here。
You can get sig-info at here
PR Approval Progress
✅ Congratulations! All modules have met the lgtm and approve requirements.
Module Approval Details
| module | lgtm status | approve status |
|---|---|---|
| repo-Ascend/MindIE-LLM | ✅ hw-zhoutianyang, 纪涛 (2/2) | ✅ 纪涛 (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
KaiMa, thanks for your pull request. All authors of the commits have signed the CLA. 👍


4月16日 添加了label:ascend-cla/yes
KaiMa
4月16日 评论:
4月16日 评论:
compile


此处折叠了99条消息 查看更多
mindie_llm/connector/request_listener/shared_mem_communication.py
代码可读性: 切片操作中的空格使用不一致,与第149行格式不统一。第151行在冒号后有两个空格。
问题类型: 代码可读性
文件路径:
mindie_llm/connector/request_listener/shared_mem_communication.py行号: 155
问题代码:
self.shared_memory.buf[buffer_offset + msg_length_bytes : buffer_offset + msg_length_bytes + msg_length] = (
proto_data
)修改建议:
统一切片操作的空格格式,建议修改为:`self.shared_memory.buf[buffer_offset + msg_length_bytes:buffer_offset + msg_length_bytes + msg_length] = proto_data`
---
此评论由代码审查工具自动生成
此评论由代码审查工具自动生成


mindie_llm/connector/request_listener/shared_mem_communication.py
代码可读性: 切片操作中的空格使用不一致。第166行在冒号后没有空格,而第167行在冒号后有两个空格。这种不一致会影响代码的可读性。
问题类型: 代码可读性
文件路径:
mindie_llm/connector/request_listener/shared_mem_communication.py行号: 169
问题代码:
self.shared_memory.buf[0:msg_length_bytes] = msg_length.to_bytes(msg_length_bytes, "little") self.shared_memory.buf[msg_length_bytes : msg_length_bytes + msg_length] = byte_message
修改建议:
统一切片操作的空格格式,建议都采用一致的格式。可以修改为:`self.shared_memory.buf[msg_length_bytes:msg_length_bytes + msg_length] = byte_message`
---
此评论由代码审查工具自动生成
此评论由代码审查工具自动生成


mindie_llm/connector/request_router/layerwise/request_router_cloud.py
@@ -98,4 +111,3 @@
98111 prefill_layers_divi_num = int(os.getenv("PREFILL_CUT_NUM", "5"))
99112 prefill_layers_divi_policy = self.prepare_prefill_cut_policy(prefill_layers_divi_num)
100113
101- logger.info(f"[layerwiseDisaggregated] cloud initliaze ok rank:{self.rank}, "
代码可读性: 日志信息中的单词拼写错误。原代码中 `initliaze` 应该是 `initialize` 的拼写错误。
问题类型: 代码可读性
文件路径:
mindie_llm/connector/request_router/layerwise/request_router_cloud.py行号: 114
问题代码:
logger.info(
f"[layerwiseDisaggregated] cloud initliaze ok rank:{self.rank}, "修改建议:
建议修正拼写错误:将 `initliaze` 改为 `initialize`。正确的日志信息应该是:`f"[layerwiseDisaggregated] cloud initialize ok rank:{self.rank}, "`---
此评论由代码审查工具自动生成
此评论由代码审查工具自动生成


mindie_llm/examples/scheduler.py
@@ -311,4 +316,3 @@
311316 req.split_end_position = len(alias_input_ids_list[i])
312317 req.last_prompt = 1
313318 batch_req_status[i] = 1
314- elif (batch_req_status[i] == 1): # 上一次是最后一个prefill快
注释错误: 注释中写的是'上一次是最后一个prefill快',但'快'应该是'块'的笔误。这种注释错误会影响代码的可读性。
问题类型: 注释错误
文件路径:
mindie_llm/examples/scheduler.py行号: 319
问题代码:
elif batch_req_status[i] == 1: # 上一次是最后一个prefill快
修改建议:
修正注释中的错别字:'快'改为'块'。同时确保所有类似注释都正确。
---
此评论由代码审查工具自动生成
此评论由代码审查工具自动生成


mindie_llm/tokenizer/io_utils.py
@@ -193,30 +193,30 @@
193193 else:
194194 os.makedirs(single_dir, exist_ok=True)
195195 os.chmod(single_dir, 0o750)
196- with file_utils.safe_open(shm_save_path, mode='wb', permission_mode=0o640):
196+ with file_utils.safe_open(shm_save_path, mode="wb", permission_mode=0o640):
197197 pass
198198 except FileNotFoundError as file_not_found_error:
199199 raise IOError("Error when create cache dir, file not found.") from file_not_found_error
@@ -207,7 +207,7 @@ def release_shared_memory(file_path):
207207
208208 file_path = file_utils.standardize_path(file_path)
209209 file_utils.check_path_permission(file_path, mode=0o640)
210- with file_utils.safe_open(file_path, mode='r', permission_mode=0o640) as f:
210+ with file_utils.safe_open(file_path, mode="r", permission_mode=0o640) as f:
211211 shm_names = [line.strip() for line in file_utils.safe_readlines(f)]
212212 for name in shm_names:
213213 try:
@@ -230,7 +230,7 @@ def remove_cache_dir(dir_path):
230230 else:
231231 os.makedirs(dir_path, exist_ok=True)
232232 os.chmod(dir_path, 0o640)
233- shm_save_path = os.path.join(dir_path, "shm_name.txt")
233+ shm_save_path = os.path.join(dir_path, "shm_name.txt")
234234 release_shared_memory(shm_save_path)
235235
236236 try:
@@ -246,6 +246,6 @@
246246 raise IOError("Remove cache dir error.") from e
247247
248248
249249def clear_meida_cache(dir_path: str):
变量和数据类型问题: 函数名clear_meida_cache存在拼写错误,应为clear_media_cache。
问题类型: 变量和数据类型问题
文件路径:
mindie_llm/tokenizer/io_utils.py行号: 249
问题代码:
def clear_meida_cache(dir_path: str):
修改建议:
将函数名更正为clear_media_cache。
---
此评论由代码审查工具自动生成
此评论由代码审查工具自动生成


合入背景
Fixes #443
修改内容
资料变更
接口变更
测试结果
CheckList