Skip to content

Commit 222d623

Browse files
committed
repl /unload command
1 parent fc4e66a commit 222d623

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
- readers provide source information.
1212
- `hyperbase.parsers.badness` module for parser-agnostic combined structural + token-matching validation.
1313
- built-in REPL setting `check_badness` to render a badness panel after each parse, available regardless of the active parser plugin.
14-
- more REPL commands: /load, /save, /search, /count, /count-csv, /types, /transform and /classify.
14+
- more REPL commands: /load, /unload, /save, /search, /count, /count-csv, /types, /transform and /classify.
1515

1616
### Changed
1717

src/hyperbase/cli/repl.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,10 @@ def __init__(self, parser_name: str | None, settings: dict[str, Any]) -> None:
358358
"help": "Load hyperedges from a .jsonl parse-results file",
359359
"handler": self.cmd_load,
360360
},
361+
"unload": {
362+
"help": "Unload the current dataset and forget it on restart",
363+
"handler": self.cmd_unload,
364+
},
361365
"save": {
362366
"help": "Save in-memory edges to a .jsonl file",
363367
"handler": self.cmd_save,
@@ -781,6 +785,21 @@ def cmd_load(self, args: list) -> bool:
781785
)
782786
return False
783787

788+
def cmd_unload(self, args: list) -> bool:
789+
if not self.edges and self.edges_source is None:
790+
self.console.print("[yellow]No dataset loaded.[/yellow]")
791+
return False
792+
prev = self.edges_source
793+
self.edges = []
794+
self.edges_source = None
795+
self.settings.pop("edges_path", None)
796+
save_settings(self.settings)
797+
if prev is not None:
798+
self.console.print(f"[green]✓[/green] Unloaded dataset [cyan]{prev}[/cyan]")
799+
else:
800+
self.console.print("[green]✓[/green] Unloaded dataset")
801+
return False
802+
784803
def cmd_save(self, args: list) -> bool:
785804
if len(args) < 1:
786805
self.console.print(

0 commit comments

Comments
 (0)