| |
| """Hotpatch the stale Space image before training runs.""" |
| import os, sys, shutil |
|
|
| |
| p = "/workspace/feather/hydra/model.py" |
| txt = open(p).read() |
| old = "self.sdr_semantic.retina_contrastive is not None" |
| new = "getattr(self.sdr_semantic, 'retina_contrastive', None) is not None" |
| if old in txt: |
| txt = txt.replace(old, new) |
| open(p, "w").write(txt) |
| print("[hotpatch] retina_contrastive guard patched") |
| else: |
| print("[hotpatch] retina_contrastive guard already present or ref changed") |
|
|
| |
| sp = "/workspace/feather/subsystems/sdr_semantic.py" |
| stxt = open(sp).read() |
| |
| |
| fallback = """ |
| # Hotpatch safety: ensure retina_contrastive always exists |
| if not hasattr(self, 'retina_contrastive'): |
| self.retina_contrastive = None |
| """ |
| if "Hotpatch safety" not in stxt: |
| stxt = stxt.replace("self._som_step: int = 0", "self._som_step: int = 0" + fallback) |
| open(sp, "w").write(stxt) |
| print("[hotpatch] sdr_semantic retina_contrastive safety added") |
| else: |
| print("[hotpatch] safety already present") |
|
|
| os.execl(sys.executable, sys.executable, "/app/entrypoint.py") |
|
|