From 0b757d0b470a55a29d8de176b14d46eecfb4c2f2 Mon Sep 17 00:00:00 2001 From: stellahsr Date: Thu, 12 Oct 2023 17:28:16 +0800 Subject: [PATCH 1/2] update: add round_id for resume --- metagpt/minecraft_team.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/metagpt/minecraft_team.py b/metagpt/minecraft_team.py index 829db84e4..ed815edac 100644 --- a/metagpt/minecraft_team.py +++ b/metagpt/minecraft_team.py @@ -497,6 +497,9 @@ class MinecraftPlayer(SoftwareCompany): "wait_ticks": 20, } ) + with open(f"{CKPT_DIR}/curriculum/round_id.json", "r") as f: + + round_id = json.load(f)["last_round_id"] else: # clear the inventory self.game_memory.mf_instance.reset( @@ -520,7 +523,10 @@ class MinecraftPlayer(SoftwareCompany): round_id += 1 # add new task into env and continue # fixme: update self.task - self.start(task=self.task, round=round_id) + with open(f"{CKPT_DIR}/curriculum/round_id.json", "w") as f: + json.dump({"last_round_id": round_id}, f) + + self.start(task=self.task, round=round_id) logger.info(f"{n_round=}") self._check_balance() From d9cd6f6866cee8e6f934df662516b54198a4babf Mon Sep 17 00:00:00 2001 From: stellahsr Date: Thu, 12 Oct 2023 17:40:22 +0800 Subject: [PATCH 2/2] update: add path check --- metagpt/minecraft_team.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/metagpt/minecraft_team.py b/metagpt/minecraft_team.py index ed815edac..3e92348b7 100644 --- a/metagpt/minecraft_team.py +++ b/metagpt/minecraft_team.py @@ -2,6 +2,7 @@ # @Date : 2023/9/23 14:14 # @Author : stellahong (stellahong@fuzhi.ai) # @Desc : +import os from typing import Iterable, Dict, Any from pydantic import BaseModel, Field import requests @@ -497,9 +498,10 @@ class MinecraftPlayer(SoftwareCompany): "wait_ticks": 20, } ) - with open(f"{CKPT_DIR}/curriculum/round_id.json", "r") as f: - - round_id = json.load(f)["last_round_id"] + ## add resume round_id + if os.path.exists(f"{CKPT_DIR}/curriculum/round_id.json"): + with open(f"{CKPT_DIR}/curriculum/round_id.json", "r") as f: + round_id = json.load(f)["last_round_id"] else: # clear the inventory self.game_memory.mf_instance.reset(