Skip to content

Commit 0c6e414

Browse files
committed
Fix init encode progress.
1 parent 1d185f5 commit 0c6e414

2 files changed

Lines changed: 38 additions & 2 deletions

File tree

RPG-Kit/scripts/rpg_encoder/semantic_parsing.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,11 @@ def process_class_batch(
501501
"[GLOBAL] process_class_batch error: %s", e, exc_info=True
502502
)
503503
return {}, {}
504+
finally:
505+
self.logger.info(
506+
"[GLOBAL] finished class batch with %d units",
507+
len(batch_units),
508+
)
504509

505510
def process_func_batch(
506511
batch_units: List[CodeUnit],
@@ -540,6 +545,11 @@ def process_func_batch(
540545
"[GLOBAL] process_func_batch error: %s", e, exc_info=True
541546
)
542547
return {}, {}
548+
finally:
549+
self.logger.info(
550+
"[GLOBAL] finished function batch with %d units",
551+
len(batch_units),
552+
)
543553

544554
with ThreadPoolExecutor(max_workers=max_workers) as executor:
545555
futures = []

RPG-Kit/src/rpgkit_cli/__init__.py

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1396,6 +1396,9 @@ def _workspace_has_python_code(project_path: Path) -> bool:
13961396
_ENCODE_RE_TOTAL_FILES = re.compile(r"Total valid Python files to parse:\s*(\d+)")
13971397
_ENCODE_RE_CLASS_BATCHES = re.compile(r"\[GLOBAL\] kind=class,\s*groups=\d+,\s*batches=(\d+)")
13981398
_ENCODE_RE_FUNC_BATCHES = re.compile(r"\[GLOBAL\] kind=function,\s*groups=\d+,\s*batches=(\d+)")
1399+
_ENCODE_RE_CLASS_FINISHED = re.compile(r"\[GLOBAL\] finished class batch with \d+ units")
1400+
_ENCODE_RE_FUNC_FINISHED = re.compile(r"\[GLOBAL\] finished function batch with \d+ units")
1401+
_ENCODE_RE_FILE_REMAP = re.compile(r"\[GLOBAL\] file=")
13991402
_ENCODE_RE_SUMMARY_BATCHES = re.compile(r"\[SUMMARY\] total files=(\d+),\s*batches=(\d+)")
14001403
_ENCODE_RE_SUMMARY_PROCESS = re.compile(r"\[SUMMARY\] processing batch with (\d+) files")
14011404
_ENCODE_RE_SUMMARY_FINISHED = re.compile(r"\[SUMMARY\] finished batch with (\d+) files")
@@ -1411,9 +1414,10 @@ def _parse_encoder_line(line: str, state: Dict[str, Any]) -> None:
14111414
* ``Excluded paths decided`` / ``Parsing features`` /
14121415
``Total valid Python files to parse: N``
14131416
* ``[GLOBAL] kind=class, ..., batches=N`` → class batch total
1414-
* ``[GLOBAL] process_class_batch:`` → +1 class batch done
1417+
* ``[GLOBAL] finished class batch`` → +1 class batch done
14151418
* ``[GLOBAL] kind=function, ..., batches=N`` → function batch total
1416-
* ``[GLOBAL] process_func_batch:`` → +1 function batch done
1419+
* ``[GLOBAL] finished function batch`` → +1 function batch done
1420+
* ``[GLOBAL] file=...`` → feature-to-file mapping
14171421
* ``[SUMMARY] total files=N, batches=M`` → file summary batch total
14181422
* ``[SUMMARY] processing batch with N files`` / ``finished batch``
14191423
* ``Refactoring to RPG`` / ``RPG refactoring done``
@@ -1459,12 +1463,34 @@ def _parse_encoder_line(line: str, state: Dict[str, Any]) -> None:
14591463
state["phase"] = "Parsing function batches"
14601464
return
14611465
if "process_class_batch:" in line:
1466+
state["kind"] = "class"
1467+
state["phase"] = "Parsing class batches"
1468+
return
1469+
if _ENCODE_RE_CLASS_FINISHED.search(line):
14621470
state["class_done"] += 1
1471+
if state.get("class_total"):
1472+
state["class_done"] = min(state["class_done"], state["class_total"])
14631473
state["kind"] = "class"
1474+
state["phase"] = "Parsing class batches"
14641475
return
14651476
if "process_func_batch:" in line:
1477+
state["kind"] = "function"
1478+
state["phase"] = "Parsing function batches"
1479+
return
1480+
if _ENCODE_RE_FUNC_FINISHED.search(line):
14661481
state["func_done"] += 1
1482+
if state.get("func_total"):
1483+
state["func_done"] = min(state["func_done"], state["func_total"])
14671484
state["kind"] = "function"
1485+
state["phase"] = "Parsing function batches"
1486+
return
1487+
if _ENCODE_RE_FILE_REMAP.search(line):
1488+
if state.get("class_total"):
1489+
state["class_done"] = max(state["class_done"], state["class_total"])
1490+
if state.get("func_total"):
1491+
state["func_done"] = max(state["func_done"], state["func_total"])
1492+
state["kind"] = None
1493+
state["phase"] = "Mapping features to files"
14681494
return
14691495
m = _ENCODE_RE_SUMMARY_BATCHES.search(line)
14701496
if m:

0 commit comments

Comments
 (0)