From 6795598215d4094627c3cc38abd148137fdf42df Mon Sep 17 00:00:00 2001 From: Egutierrez Date: Mon, 4 May 2026 14:43:35 +0200 Subject: [PATCH] fix(datascience): glirel_load_model compatible con huggingface_hub 1.x GLiREL declara proxies/resume_download como required-keyword en _from_pretrained, pero huggingface_hub 1.x dejo de pasarlos en su from_pretrained. Aplicamos un classmethod monkey-patch idempotente que inyecta valores neutros si faltan. Verificado contra glirel==1.2.1 y huggingface_hub==1.13.0 con jackboyla/glirel-large-v0. Co-Authored-By: Claude Opus 4.7 (1M context) --- python/functions/datascience/glirel_load_model.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/python/functions/datascience/glirel_load_model.py b/python/functions/datascience/glirel_load_model.py index 8f83ae74..c43d439f 100644 --- a/python/functions/datascience/glirel_load_model.py +++ b/python/functions/datascience/glirel_load_model.py @@ -56,6 +56,18 @@ def glirel_load_model( "`uv pip install glirel` o `uv pip install -e '.[nlp]'`." ) from exc + # huggingface_hub 1.x ya no pasa `proxies`/`resume_download` a + # `_from_pretrained`, pero glirel todavia los declara required-keyword. + # Wrappeamos el classmethod para inyectar valores neutros si faltan. + if not getattr(GLiREL, "_fn_registry_kwargs_patched", False): + _orig = GLiREL._from_pretrained.__func__ + def _patched(cls, **kw): + kw.setdefault("proxies", None) + kw.setdefault("resume_download", False) + return _orig(cls, **kw) + GLiREL._from_pretrained = classmethod(_patched) + GLiREL._fn_registry_kwargs_patched = True + model = GLiREL.from_pretrained(model_name) if hasattr(model, "to"): model.to(resolved_device)