mirror of
https://github.com/NicolasBohn/NexQuant.git
synced 2026-07-27 15:37:44 +00:00
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:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user