Let an optional step fail without taking the whole refresh with it
Browse filesThe Senate eFD portal now answers the agreement POST with an Akamai 403, so step_10_senate_index raises. run_step only caught SystemExit, so the exception escaped the optional flag and killed the refresh after the House index had already been built: 49025 filings collected and thrown away, twice. An optional step that raises is now logged and skipped, and the skipped steps are named at the end so a half-updated bundle does not pass unnoticed.
- recipe/run_refresh.py +27 -2
recipe/run_refresh.py
CHANGED
|
@@ -35,6 +35,7 @@ import argparse
|
|
| 35 |
import os
|
| 36 |
import runpy
|
| 37 |
import sys
|
|
|
|
| 38 |
from pathlib import Path
|
| 39 |
|
| 40 |
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
|
@@ -128,6 +129,17 @@ def run_step(recipe_dir: Path, module: str, argv: list[str], *, optional: bool)
|
|
| 128 |
if exc.code not in (0, None):
|
| 129 |
print(f"✗ {module} завершился с кодом {exc.code}", flush=True)
|
| 130 |
return False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 131 |
finally:
|
| 132 |
sys.argv = saved
|
| 133 |
return True
|
|
@@ -159,11 +171,24 @@ def main() -> None:
|
|
| 159 |
selected = [
|
| 160 |
(n, m, [*argv, "--rebuild"] if n == "45" else argv) for n, m, argv in selected
|
| 161 |
]
|
|
|
|
| 162 |
for number, module, argv in selected:
|
| 163 |
-
# Шаги 30 и
|
| 164 |
optional = number not in ("30", "40", "45")
|
| 165 |
if not run_step(recipe_dir, module, argv, optional=optional):
|
| 166 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 167 |
|
| 168 |
if args.no_publish:
|
| 169 |
print("\n— публикация отключена флагом --no-publish", flush=True)
|
|
|
|
| 35 |
import os
|
| 36 |
import runpy
|
| 37 |
import sys
|
| 38 |
+
import traceback
|
| 39 |
from pathlib import Path
|
| 40 |
|
| 41 |
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
|
|
|
| 129 |
if exc.code not in (0, None):
|
| 130 |
print(f"✗ {module} завершился с кодом {exc.code}", flush=True)
|
| 131 |
return False
|
| 132 |
+
except Exception:
|
| 133 |
+
# Шаг, который падает исключением, а не кодом возврата, — это ровно
|
| 134 |
+
# то, как ведёт себя источник, закрывшийся без предупреждения. Для
|
| 135 |
+
# обязательного шага разницы нет, пересборка всё равно встанет; для
|
| 136 |
+
# необязательного разница принципиальна: иначе недоступный Сенат
|
| 137 |
+
# уносит с собой и свежие данные Палаты, которые уже собраны.
|
| 138 |
+
if not optional:
|
| 139 |
+
raise
|
| 140 |
+
traceback.print_exc()
|
| 141 |
+
print(f"✗ {module} упал с исключением", flush=True)
|
| 142 |
+
return False
|
| 143 |
finally:
|
| 144 |
sys.argv = saved
|
| 145 |
return True
|
|
|
|
| 171 |
selected = [
|
| 172 |
(n, m, [*argv, "--rebuild"] if n == "45" else argv) for n, m, argv in selected
|
| 173 |
]
|
| 174 |
+
skipped: list[str] = []
|
| 175 |
for number, module, argv in selected:
|
| 176 |
+
# Шаги 30, 40 и 45 обязательны — без них публиковать нечего и незачем.
|
| 177 |
optional = number not in ("30", "40", "45")
|
| 178 |
if not run_step(recipe_dir, module, argv, optional=optional):
|
| 179 |
+
if not optional:
|
| 180 |
+
raise SystemExit(f"пересборка остановлена на шаге {number}")
|
| 181 |
+
skipped.append(f"{number} {module}")
|
| 182 |
+
|
| 183 |
+
if skipped:
|
| 184 |
+
# Это та самая тишина, из-за которой датасет застывает незаметно:
|
| 185 |
+
# сборка прошла, публикация прошла, а половина источников не
|
| 186 |
+
# обновилась. Пусть в логе это будет видно отдельной строкой.
|
| 187 |
+
print(
|
| 188 |
+
"\n⚠ шаги не выполнены, их данные остались от прошлой сборки: "
|
| 189 |
+
+ ", ".join(skipped),
|
| 190 |
+
flush=True,
|
| 191 |
+
)
|
| 192 |
|
| 193 |
if args.no_publish:
|
| 194 |
print("\n— публикация отключена флагом --no-publish", flush=True)
|