import subprocess import os ACTIVE_BUCKET = None LOCALPATH = "./sovereignruntime" def run(cmd: str): print(f"[CMD] {cmd}") subprocess.run(cmd, shell=True, check=False) def set_bucket(bucketurl: str): global ACTIVE_BUCKET ACTIVE_BUCKET = bucketurl ensure_runtime() def ensure_runtime(): if not os.path.exists(LOCALPATH): os.makedirs(LOCALPATH) # Ensure modules subfolder exists for drop-in execution os.makedirs(os.path.join(LOCALPATH, "modules"), exist_ok=True) if ACTIVE_BUCKET: mount_bucket() syncfrombucket() def mount_bucket(): run(f"hf-mount stop {LOCALPATH}") run(f"hf-mount {ACTIVE_BUCKET} {LOCALPATH}") def syncfrombucket(): if ACTIVE_BUCKET: run(f"hf sync {ACTIVE_BUCKET} {LOCALPATH}") def synctobucket(): if ACTIVE_BUCKET: run(f"hf sync {LOCALPATH} {ACTIVE_BUCKET}")