lql-cli 0.6.0__tar.gz → 0.7.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. {lql_cli-0.6.0 → lql_cli-0.7.0}/PKG-INFO +13 -1
  2. {lql_cli-0.6.0 → lql_cli-0.7.0}/README.md +12 -0
  3. {lql_cli-0.6.0 → lql_cli-0.7.0}/pyproject.toml +1 -1
  4. lql_cli-0.7.0/src/lql/__init__.py +1 -0
  5. {lql_cli-0.6.0 → lql_cli-0.7.0}/src/lql/commands/instructions.py +11 -2
  6. {lql_cli-0.6.0 → lql_cli-0.7.0}/src/lql/commands/preview.py +93 -7
  7. {lql_cli-0.6.0 → lql_cli-0.7.0}/uv.lock +1 -1
  8. lql_cli-0.6.0/src/lql/__init__.py +0 -1
  9. {lql_cli-0.6.0 → lql_cli-0.7.0}/.claude/settings.local.json +0 -0
  10. {lql_cli-0.6.0 → lql_cli-0.7.0}/.gitignore +0 -0
  11. {lql_cli-0.6.0 → lql_cli-0.7.0}/examples/agent-traces.jsonl +0 -0
  12. {lql_cli-0.6.0 → lql_cli-0.7.0}/package-lock.json +0 -0
  13. {lql_cli-0.6.0 → lql_cli-0.7.0}/src/lql/_group.py +0 -0
  14. {lql_cli-0.6.0 → lql_cli-0.7.0}/src/lql/_opts.py +0 -0
  15. {lql_cli-0.6.0 → lql_cli-0.7.0}/src/lql/api.py +0 -0
  16. {lql_cli-0.6.0 → lql_cli-0.7.0}/src/lql/cli.py +0 -0
  17. {lql_cli-0.6.0 → lql_cli-0.7.0}/src/lql/commands/__init__.py +0 -0
  18. {lql_cli-0.6.0 → lql_cli-0.7.0}/src/lql/commands/annotations.py +0 -0
  19. {lql_cli-0.6.0 → lql_cli-0.7.0}/src/lql/commands/auth.py +0 -0
  20. {lql_cli-0.6.0 → lql_cli-0.7.0}/src/lql/commands/buckets.py +0 -0
  21. {lql_cli-0.6.0 → lql_cli-0.7.0}/src/lql/commands/datasets.py +0 -0
  22. {lql_cli-0.6.0 → lql_cli-0.7.0}/src/lql/commands/edits.py +0 -0
  23. {lql_cli-0.6.0 → lql_cli-0.7.0}/src/lql/commands/evals.py +0 -0
  24. {lql_cli-0.6.0 → lql_cli-0.7.0}/src/lql/commands/highlights.py +0 -0
  25. {lql_cli-0.6.0 → lql_cli-0.7.0}/src/lql/commands/issues.py +0 -0
  26. {lql_cli-0.6.0 → lql_cli-0.7.0}/src/lql/commands/reports.py +0 -0
  27. {lql_cli-0.6.0 → lql_cli-0.7.0}/src/lql/commands/skills.py +0 -0
  28. {lql_cli-0.6.0 → lql_cli-0.7.0}/src/lql/commands/spec.py +0 -0
  29. {lql_cli-0.6.0 → lql_cli-0.7.0}/src/lql/commands/tui.py +0 -0
  30. {lql_cli-0.6.0 → lql_cli-0.7.0}/src/lql/commands/update.py +0 -0
  31. {lql_cli-0.6.0 → lql_cli-0.7.0}/src/lql/commands/workspaces.py +0 -0
  32. {lql_cli-0.6.0 → lql_cli-0.7.0}/src/lql/config.py +0 -0
  33. {lql_cli-0.6.0 → lql_cli-0.7.0}/src/lql/output.py +0 -0
  34. {lql_cli-0.6.0 → lql_cli-0.7.0}/src/lql/sessions.py +0 -0
  35. {lql_cli-0.6.0 → lql_cli-0.7.0}/src/lql/util.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: lql-cli
3
- Version: 0.6.0
3
+ Version: 0.7.0
4
4
  Summary: lql — CLI for the Liquid DataViewer platform
5
5
  Project-URL: Homepage, https://github.com/Liquid4All/lql
6
6
  Author: Liquid AI
@@ -166,11 +166,23 @@ lql preview <file.jsonl|file.json> Local file: each line/object is a row
166
166
  lql preview <dataset-id> Platform dataset (fetched & paged lazily)
167
167
  lql preview <org/name> --hf HuggingFace repo: sync to DataViewer, then view
168
168
  lql preview <src> -c <field> Force field(s) as conversations (repeatable)
169
+ lql preview <src> -f "col=value" Filter rows (repeatable, AND); local & platform
169
170
  lql preview <src> -n <N> Page size when paging a platform dataset
170
171
  lql preview <src> --offset N Start at row index N
171
172
  lql preview <src> --title "<title>" Title shown in the viewer header
172
173
  ```
173
174
 
175
+ **Filtering (`--filter`/`-f`).** Show only matching rows — works on local files and
176
+ platform datasets (platform filtering runs server-side). Repeatable; filters AND
177
+ together; string match is case-insensitive. Operators: `=`, `!=`, `~` (contains),
178
+ `>`, `<`, `>=`, `<=`.
179
+
180
+ ```
181
+ lql preview <dataset-id> -f "domain=telecom"
182
+ lql preview data.jsonl -f "reward>=0.8" -f "split=test" # both must hold
183
+ lql preview <dataset-id> -f "model~lfm" # contains
184
+ ```
185
+
174
186
  **HuggingFace datasets (`--hf`).** `lql preview org/name --hf` syncs the repo
175
187
  into a DataViewer workspace, then opens it. You pick the target workspace from
176
188
  an interactive list (or pass `--workspace <id>`; `--split` defaults to `train`).
@@ -150,11 +150,23 @@ lql preview <file.jsonl|file.json> Local file: each line/object is a row
150
150
  lql preview <dataset-id> Platform dataset (fetched & paged lazily)
151
151
  lql preview <org/name> --hf HuggingFace repo: sync to DataViewer, then view
152
152
  lql preview <src> -c <field> Force field(s) as conversations (repeatable)
153
+ lql preview <src> -f "col=value" Filter rows (repeatable, AND); local & platform
153
154
  lql preview <src> -n <N> Page size when paging a platform dataset
154
155
  lql preview <src> --offset N Start at row index N
155
156
  lql preview <src> --title "<title>" Title shown in the viewer header
156
157
  ```
157
158
 
159
+ **Filtering (`--filter`/`-f`).** Show only matching rows — works on local files and
160
+ platform datasets (platform filtering runs server-side). Repeatable; filters AND
161
+ together; string match is case-insensitive. Operators: `=`, `!=`, `~` (contains),
162
+ `>`, `<`, `>=`, `<=`.
163
+
164
+ ```
165
+ lql preview <dataset-id> -f "domain=telecom"
166
+ lql preview data.jsonl -f "reward>=0.8" -f "split=test" # both must hold
167
+ lql preview <dataset-id> -f "model~lfm" # contains
168
+ ```
169
+
158
170
  **HuggingFace datasets (`--hf`).** `lql preview org/name --hf` syncs the repo
159
171
  into a DataViewer workspace, then opens it. You pick the target workspace from
160
172
  an interactive list (or pass `--workspace <id>`; `--split` defaults to `train`).
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "lql-cli"
7
- version = "0.6.0"
7
+ version = "0.7.0"
8
8
  description = "lql — CLI for the Liquid DataViewer platform"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.12"
@@ -0,0 +1 @@
1
+ __version__ = "0.7.0"
@@ -100,8 +100,17 @@ DataViewer workspace (you pick one interactively, or pass --workspace <id>;
100
100
  --split defaults to train) and reused on later previews (dedup by repo+split).
101
101
 
102
102
  Options: -c/--column (field(s) to treat as conversations; default auto-detect,
103
- repeatable), -n/--limit (page size when paging a platform dataset), --offset
104
- (start row index), --title, --hf, --split, --workspace, --profile, --api-url.
103
+ repeatable), -f/--filter (filter rows; see below), -n/--limit (page size when
104
+ paging a platform dataset), --offset (start row index), --title, --hf, --split,
105
+ --workspace, --profile, --api-url.
106
+
107
+ Filtering: -f/--filter "col<op>value" shows only matching rows — works on local
108
+ files and platform datasets (server-side for platform). Repeatable; filters AND
109
+ together; string compare is case-insensitive. Operators: = (eq), != (ne),
110
+ ~ (contains), >, <, >=, <=.
111
+
112
+ lql preview <dataset-id> -f "domain=telecom" -f "reward>=0.8"
113
+ lql preview data.jsonl -f "model~lfm"
105
114
 
106
115
  Navigation: two modes toggled with m — pager (one sample at a time; ←/→ or
107
116
  n/b switch samples, ↑/↓/j/k scroll) and scroll (all samples; n/b jump between
@@ -759,6 +759,67 @@ def _choose_workspace(client: ApiClient, tui_mod) -> Optional[str]:
759
759
  return choice
760
760
 
761
761
 
762
+ # --------------------------------------------------------------------------
763
+ # Row filtering (--filter "col<op>value")
764
+ # --------------------------------------------------------------------------
765
+
766
+ # Maps each CLI symbol to the platform filter API's operator name (the same
767
+ # names work server-side and locally). _parse_filters picks the earliest operator
768
+ # (longest on a tie), so list order doesn't affect correctness.
769
+ _FILTER_OPS = [(">=", "gte"), ("<=", "lte"), ("!=", "ne"), ("~", "contains"), ("=", "eq"), (">", "gt"), ("<", "lt")]
770
+ _NUMERIC_OPS = {"gt": lambda c, v: c > v, "lt": lambda c, v: c < v, "gte": lambda c, v: c >= v, "lte": lambda c, v: c <= v}
771
+
772
+
773
+ def _parse_filters(specs: Optional[List[str]]) -> List[tuple]:
774
+ """Parse ['col=value', 'reward>=0.5', 'name~kod'] → [(col, op, value), ...].
775
+
776
+ Splits on the EARLIEST operator (longest on a tie, so 'reward>=5' is gte not
777
+ gt), keeping operator chars in the value intact (e.g. 'q=a>b' → col 'q', value
778
+ 'a>b'). Rejects an empty column or value."""
779
+ out: List[tuple] = []
780
+ for spec in specs or []:
781
+ chosen = None # (index, symbol, op_name)
782
+ for sym, op in _FILTER_OPS:
783
+ i = spec.find(sym)
784
+ if i > 0 and (chosen is None or i < chosen[0] or (i == chosen[0] and len(sym) > len(chosen[1]))):
785
+ chosen = (i, sym, op)
786
+ if chosen is None:
787
+ print_error(
788
+ f"Invalid --filter '{spec}'. Use col=value, col!=value, col~text, or col>/</>=/<= N.",
789
+ "bad_filter",
790
+ )
791
+ raise typer.Exit(1)
792
+ i, sym, op = chosen
793
+ col, val = spec[:i].strip(), spec[i + len(sym):].strip()
794
+ if not col or not val:
795
+ print_error(f"Invalid --filter '{spec}': both a column and a value are required.", "bad_filter")
796
+ raise typer.Exit(1)
797
+ out.append((col, op, val))
798
+ return out
799
+
800
+
801
+ def _cell_matches(cell: object, op: str, val: str) -> bool:
802
+ if op == "contains":
803
+ return cell is not None and val.lower() in str(cell).lower()
804
+ if op in ("eq", "ne"):
805
+ equal = cell is not None and str(cell).strip().lower() == val.strip().lower()
806
+ return equal if op == "eq" else not equal
807
+ try:
808
+ return _NUMERIC_OPS[op](float(cell), float(val)) # gt/lt/gte/lte
809
+ except (TypeError, ValueError):
810
+ return False
811
+
812
+
813
+ def _row_matches(row: object, filters: List[tuple]) -> bool:
814
+ """Client-side predicate (local files). A non-dict row can't match a column
815
+ filter. All filters AND together."""
816
+ if not filters:
817
+ return True
818
+ if not isinstance(row, dict):
819
+ return False
820
+ return all(_cell_matches(row.get(col), op, val) for col, op, val in filters)
821
+
822
+
762
823
  # --------------------------------------------------------------------------
763
824
  # Command
764
825
  # --------------------------------------------------------------------------
@@ -772,6 +833,13 @@ def preview(
772
833
  ] = None,
773
834
  limit: Annotated[int, typer.Option("--limit", "-n", help="Page size when paging a platform dataset")] = 25,
774
835
  offset: Annotated[int, typer.Option("--offset", help="Start at this row index")] = 0,
836
+ filter_: Annotated[
837
+ Optional[List[str]],
838
+ typer.Option(
839
+ "--filter", "-f",
840
+ help="Filter rows: 'col=value', 'col!=value', 'col~text' (contains), or 'col>/</>=/<= N'. Repeatable (AND).",
841
+ ),
842
+ ] = None,
775
843
  title: Annotated[Optional[str], typer.Option("--title", help="Title shown in the viewer header")] = None,
776
844
  hf: Annotated[
777
845
  bool, typer.Option("--hf", help="Treat SOURCE as a HuggingFace repo (org/name); sync it to DataViewer, then view")
@@ -801,13 +869,20 @@ def preview(
801
869
  print_error("The terminal viewer requires 'textual'. Install it: pip install textual", "missing_textual")
802
870
  raise typer.Exit(1)
803
871
 
872
+ filters = _parse_filters(filter_)
804
873
  local_path = Path(source)
805
874
  is_local = (not hf) and local_path.exists() and local_path.is_file()
806
875
 
807
- # Local file → load whole, view immediately.
876
+ # Local file → load whole (filter client-side), view immediately.
808
877
  if is_local:
878
+ rows = _load_local(local_path)
879
+ if filters:
880
+ rows = [r for r in rows if _row_matches(r, filters)]
881
+ if not rows:
882
+ print_error("No rows match the filter(s).", "no_match")
883
+ raise typer.Exit(3)
809
884
  tui_mod.run(
810
- tui_mod.RowSource(initial=_load_local(local_path)),
885
+ tui_mod.RowSource(initial=rows),
811
886
  title or local_path.name,
812
887
  forced_cols=column or None,
813
888
  start_idx=max(0, offset),
@@ -834,11 +909,17 @@ def preview(
834
909
  view_title = title or f"dataset {source}"
835
910
 
836
911
  page_size = limit if limit and limit > 0 else 25
912
+ api_filters = [{"column": col, "operator": op, "value": val} for col, op, val in filters]
837
913
 
838
914
  def _fetch_page(off: int, lim: int) -> List[object]:
839
- data = client.get(
840
- f"/v1/datasets/{q(dataset_id)}/rows", params={"limit": str(lim), "offset": str(offset + off)}
841
- ).json()
915
+ params = {"limit": str(lim), "offset": str(offset + off)}
916
+ if api_filters:
917
+ # Server-side filtering via the same endpoint `eval samples` uses.
918
+ data = client.post(
919
+ f"/v1/datasets/{q(dataset_id)}/rows/filter", json={"filters": api_filters}, params=params
920
+ ).json()
921
+ else:
922
+ data = client.get(f"/v1/datasets/{q(dataset_id)}/rows", params=params).json()
842
923
  return _normalize_loaded(data)
843
924
 
844
925
  # Fetch the first page up front (with feedback) so the viewer opens already
@@ -857,8 +938,13 @@ def preview(
857
938
  if first:
858
939
  break
859
940
  if not first:
860
- msg = f"Dataset returned no rows for split '{split}'." if hf else "Dataset returned no rows."
861
- print_error(msg, "empty_dataset")
941
+ if filters:
942
+ msg, code = "No rows match the filter(s).", "no_match"
943
+ elif hf:
944
+ msg, code = f"Dataset returned no rows for split '{split}'.", "empty_dataset"
945
+ else:
946
+ msg, code = "Dataset returned no rows.", "empty_dataset"
947
+ print_error(msg, code)
862
948
  raise typer.Exit(3)
863
949
  row_source = tui_mod.RowSource(initial=first, fetch_page=_fetch_page, page_size=page_size)
864
950
  tui_mod.run(
@@ -185,7 +185,7 @@ wheels = [
185
185
 
186
186
  [[package]]
187
187
  name = "lql-cli"
188
- version = "0.6.0"
188
+ version = "0.7.0"
189
189
  source = { editable = "." }
190
190
  dependencies = [
191
191
  { name = "httpx" },
@@ -1 +0,0 @@
1
- __version__ = "0.6.0"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes