MCPcopy Create free account
hub / github.com/PaddlePaddle/FastDeploy / parse_tqdm_progress

Function parse_tqdm_progress

tests/ce/deploy/deploy.py:144–168  ·  view source on GitHub ↗

解析 tqdm 风格的进度条

(log_lines)

Source from the content-addressed store, hash-verified

142
143
144def parse_tqdm_progress(log_lines):
145 """
146 解析 tqdm 风格的进度条
147 """
148 tqdm_pattern = re.compile(
149 r"(?P<prefix>.+?):\s+(?P<percent>\d+)%\|(?P<bar>.+?)\|\s+(?P<step>\d+/\d+)\s+\[(?P<elapsed>\d+:\d+)<(?P<eta>\d+:\d+),\s+(?P<speed>[\d\.]+it/s)\]"
150 )
151
152 for line in reversed(log_lines):
153 match = tqdm_pattern.search(line)
154 if match:
155 data = match.groupdict()
156 return {
157 "status": "服务启动中",
158 "progress": {
159 "percent": int(data["percent"]),
160 "step": data["step"],
161 "speed": data["speed"],
162 "eta": data["eta"],
163 "elapsed": data["elapsed"],
164 "bar": data["bar"].strip(),
165 },
166 "raw_line": line.strip(),
167 }
168 return {"status": "服务启动中", "progress": {}, "raw_line": log_lines[-1] if log_lines else "server.log为空"}
169
170
171def stop_server(signum=None, frame=None):

Callers 1

is_server_runningFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected