Skip to content

Add checkpoint#16

Open
huangzhenhua111 wants to merge 3 commits intoBUPT-GAMMA:mainfrom
huangzhenhua111:checkpoint-dev
Open

Add checkpoint#16
huangzhenhua111 wants to merge 3 commits intoBUPT-GAMMA:mainfrom
huangzhenhua111:checkpoint-dev

Conversation

@huangzhenhua111
Copy link
Copy Markdown
Contributor

@huangzhenhua111 huangzhenhua111 commented May 5, 2026

1.openai那个是bug我顺手修了一下:(跑一下这个就知道bug是什么问题了)
huangzhenhua111.github.io/static/code/AgentProject/checkpoint/test/test_openai.py

2.graph那个是个换行,之前两段代码贴一起不好看

Quick Start

这里说明用法,完整示例见:

huangzhenhua111.github.io/static/code/AgentProject/checkpoint/test/test17_run.py和test17_resume.py(粒度为node版)
test18_run.py和test18_resume.py(粒度为graph版)

第一次跑代码用的文件:

from masfactory.checkpoint.manager import CheckpointManager
from masfactory.checkpoint.storage import FileCheckpointStorage
from pathlib import Path

你的图代码

g.build()

#这三行是第一次run的时候保存用的:
storage=FileCheckpointStorage(str(Path(__file__).parent))
manager=CheckpointManager(g,storage,"node"或者"graph")
manager.attach_hooks()

out,_=g.invoke({"count":0})

断点续跑用的文件:

from masfactory.checkpoint.manager import CheckpointManager
from masfactory.checkpoint.storage import FileCheckpointStorage
from pathlib import Path

你的图代码

g.build()

#这五行是接着上次保存的checkpoint文件状态接着跑,同时也会继续保存,第二次还断了可以接着用这些代码
storage=FileCheckpointStorage(str(Path(__file__).parent))
manager=CheckpointManager(g,storage,"node"或者"graph")
manager.attach_hooks()
manager.load_last()
out,_=manager.resume()

any question else ? please see

huangzhenhua111.github.io/blog/2026-05-05-给masfactory增加checkpoint功能.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant