Newer
Older
cortex-hub / patch_grpc.py
with open("ai-hub/app/core/grpc/services/grpc_server.py", "r") as f:
    content = f.read()

target = """                if fs.session_id != "__fs_explorer__":
                    drifts = self.mirror.reconcile(fs.session_id, fs.manifest)"""

replacement = """                if fs.session_id != "__fs_explorer__":
                    # Do not reconcile on shallow manifests triggered by interactive FS tools
                    if task_id and any(task_id.startswith(p) for p in ("fs-ls-", "fs-write-", "fs-rm-")):
                        pass
                    else:
                        drifts = self.mirror.reconcile(fs.session_id, fs.manifest)"""

if target in content:
    with open("ai-hub/app/core/grpc/services/grpc_server.py", "w") as f:
        f.write(content.replace(target, replacement))
    print("Patched grpc_server.py")
else:
    print("Target not found")