fix: refine details (#979)

* feat: add parquet preview and extract common DataFrame preview logic

* refactor: improve error messages, prompts, regex, and session loading

* lint
This commit is contained in:
you-n-g
2025-06-23 10:38:27 +08:00
committed by GitHub
parent a4206e99b2
commit b60f5fc506
8 changed files with 62 additions and 26 deletions
+2 -1
View File
@@ -31,7 +31,8 @@ class PythonAgentOut(AgentOut):
@classmethod
def extract_output(cls, resp: str):
match = re.search(r".*```[Pp]ython\n(.*)\n```.*", resp, re.DOTALL)
# We use lazy mode (.*?) to only extract the first code block in the response.
match = re.search(r".*```[Pp]ython\n(.*?)\n```.*", resp, re.DOTALL)
if match:
code = match.group(1)
code = re.sub(r"</?code>", "", code, flags=re.IGNORECASE)
+1
View File
@@ -116,6 +116,7 @@ def pull_image_with_progress(image: str) -> None:
class EnvConf(ExtendedBaseSettings):
# TODO: add prefix ....
default_entry: str
extra_volumes: dict = {}
running_timeout_period: int = 3600 # 10 minutes
+17 -1
View File
@@ -250,7 +250,11 @@ class LoopBase:
current_step = self.step_idx[li]
self.pbar.n = current_step
next_step = self.step_idx[li] % len(self.steps)
self.pbar.set_postfix(loop_index=li, step_index=next_step, step_name=self.steps[next_step])
self.pbar.set_postfix(
loop_index=li + next_step_idx // len(self.steps),
step_index=next_step,
step_name=self.steps[next_step],
)
self._check_exit_conditions_on_step()
else:
logger.warning(f"Step forward {si} of loop {li} is skipped.")
@@ -411,6 +415,18 @@ class LoopBase:
An instance of LoopBase with the loaded session.
"""
path = Path(path)
# if the path is a directory, load the latest session
if path.is_dir():
if path.name != "__session__":
path = path / "__session__"
if not path.exists():
raise FileNotFoundError(f"No session file found in {path}")
# iterate the dump steps in increasing order
files = sorted(path.glob("*/*_*"), key=lambda f: (int(f.parent.name), int(f.name.split("_")[0])))
path = files[-1]
logger.info(f"Loading latest session from {path}")
with path.open("rb") as f:
session = cast(LoopBase, pickle.load(f))