pablogrois Claude Opus 4.8 commited on
Commit
976402e
·
1 Parent(s): 3f110a2

Pre/post: reconstruir zone-features del preprocessed para todas las ligas

Browse files

El head-to-head pro lee team_match_zone_features.parquet, que en el bundle es solo
Segunda -> pre-match fallaba para otras ligas ('No hay datos suficientes'). Ahora el
runner lo reconstruye del preprocessed antes de generar (una vez), así vale para todas
las ligas del modelo. Se quita el rebuild duplicado del post-partido.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

src/racing_reports/reports/post_match.py CHANGED
@@ -33,15 +33,12 @@ def generate(
33
  season: str | None = None,
34
  match_date: str | None = None,
35
  ) -> ReportBundle:
36
- gen = vendor_env.patch_helper_paths(
37
  preprocessed_csv=preprocessed_csv, matches_csv=matches_csv
38
  )
39
-
40
- # Evitar escribir a través de un symlink hacia el cache de Azure.
41
  zone_path = vendor_env.DATA_DIR / "team_match_zone_features.parquet"
42
- if zone_path.is_symlink():
43
- zone_path.unlink()
44
- gen.build_zone_features_from_preprocessed()
45
 
46
  pm = vendor_env.import_script("build_post_match_report")
47
  pm.TEAM_IDS[home_name] = team_ids[home_name]
 
33
  season: str | None = None,
34
  match_date: str | None = None,
35
  ) -> ReportBundle:
36
+ vendor_env.patch_helper_paths(
37
  preprocessed_csv=preprocessed_csv, matches_csv=matches_csv
38
  )
39
+ # Las zone-features ya las reconstruyó el runner desde el preprocessed (para todas
40
+ # las ligas, no solo Segunda). Acá sólo las leemos.
41
  zone_path = vendor_env.DATA_DIR / "team_match_zone_features.parquet"
 
 
 
42
 
43
  pm = vendor_env.import_script("build_post_match_report")
44
  pm.TEAM_IDS[home_name] = team_ids[home_name]
src/racing_reports/runner.py CHANGED
@@ -110,6 +110,24 @@ class ReportRunner:
110
  report_types, request.league, request.season
111
  )
112
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
113
  output_dir = self.settings.output_dir / slugify(request.league) / str(
114
  request.season
115
  ) / slugify(f"{home_name}_vs_{away_name}_{request.match_id or 'libre'}")
 
110
  report_types, request.league, request.season
111
  )
112
 
113
+ # El head-to-head pro (pre/post) lee team_match_zone_features.parquet, que en
114
+ # el bundle es SOLO Segunda. Para cualquier liga lo reconstruimos del
115
+ # preprocessed antes de generar, así funciona con todas las ligas del modelo.
116
+ if {"pre_match", "post_match"} & set(report_types):
117
+ try:
118
+ gen_zones = vendor_env.patch_helper_paths(
119
+ preprocessed_csv=self.datastore.require_preprocessed(
120
+ request.league, request.season
121
+ ),
122
+ matches_csv=paths["matches_csv"],
123
+ )
124
+ zpath = vendor_env.DATA_DIR / "team_match_zone_features.parquet"
125
+ if zpath.is_symlink():
126
+ zpath.unlink()
127
+ gen_zones.build_zone_features_from_preprocessed()
128
+ except Exception:
129
+ pass # si falla, el propio reporte devuelve su error específico
130
+
131
  output_dir = self.settings.output_dir / slugify(request.league) / str(
132
  request.season
133
  ) / slugify(f"{home_name}_vs_{away_name}_{request.match_id or 'libre'}")