Repository navigation
feat(scope): add claudescope-py Python client wrapping the CLI - #27
Merged
Merged
Conversation
Lets users go straight from a query to a pandas.DataFrame instead of
shelling out to the ClaudeScope CLI and hand-parsing JSON themselves.
import claudescope as scope
session = scope.load("/path/to/log.wpilog")
df = session.query("stats avg(BatteryVoltage) by Subsystem")
Wraps the CLI binary via subprocess (reuses its daemon auto-start
logic) rather than talking to the daemon HTTP API directly. Covers
load/connect/sessions, query (-> DataFrame), query_multi (union ->
tagged DataFrame with attrs["errors"]; comparison -> dict of
DataFrame/ClaudeScopeError per session), and the remaining
get/range/find-bool/find-threshold/stats/set/disconnect commands.
Unwraps the CLI's double-encoded error payload (writeErrorAndExit
wraps a failed daemon request's own JSON error body in another
{error, code} envelope) so callers see a clean message/code instead
of a raw JSON blob.
Verified end-to-end against a real built binary and a synthetic
.wpilog (query, timechart, find-bool, stats, query_multi union and
comparison modes, and the error path).
rylero
marked this pull request as ready for review
July 6, 2026 06:56
rylero
added a commit
that referenced
this pull request
Jul 6, 2026
…python client SKILL.md hadn't been updated for #27 (claudescope-py) or #28 (--follow/search-fields), and this branch adds --format csv/parquet on top -- the agent-facing guide was missing all four. Documents: - search-fields command - --format csv/parquet output for query/query-multi --union true - query --follow true live streaming (NDJSON, incompatible with --format/--out) - the claudescope-py Python client, recommended over --format for Python consumers since it builds a DataFrame directly Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
rylero
added a commit
that referenced
this pull request
Jul 6, 2026
* feat(scope): add --format csv to query/query-multi CSV output lets query results feed pandas.read_csv() directly without a JSON parsing round-trip. Columns are the union of all row keys, sorted alphabetically with Timestamp pinned first for determinism across heterogeneous rows (e.g. stats/timechart by group). query-multi requires --union true since comparison mode isn't row-shaped. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * feat(scope): add --format parquet, fix CSV bool dtype Parquet preserves native bool/float64/string types and true nulls for missing columns, unlike CSV which must stringify everything. Column type per field is inferred from non-nil values (bool/float64/ string), falling back to a stringified UTF8 column on any mix so the writer never errors on unexpected value shapes. Also fix CSV output to write bools as "True"/"False" instead of Go's lowercase "true"/"false" -- pandas.read_csv's C parser only recognizes the capitalized form as boolean, otherwise the column comes back as object dtype. Adds github.com/parquet-go/parquet-go as a new dependency. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * docs(scope): update SKILL.md for csv/parquet, follow, search-fields, python client SKILL.md hadn't been updated for #27 (claudescope-py) or #28 (--follow/search-fields), and this branch adds --format csv/parquet on top -- the agent-facing guide was missing all four. Documents: - search-fields command - --format csv/parquet output for query/query-multi --union true - query --follow true live streaming (NDJSON, incompatible with --format/--out) - the claudescope-py Python client, recommended over --format for Python consumers since it builds a DataFrame directly Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * fix(scope): stop parquet writer from nulling falsy values Found via end-to-end testing against a real .wpilog and pandas (not just Go-side round-trip tests): rowsToParquet wrote rows via GenericWriter's map/reflect path (w.Write([]map[string]any{...})), whose isNullValue check (parquet-go's column_buffer_reflect.go) treats any Go zero value -- false, 0.0, "" -- as equivalent to an absent key for Optional columns. A real Enabled=false or a sensor reading of exactly 0.0 was silently coming back as a Parquet null (NaN/None in pandas), which is a correctness bug that would corrupt real telemetry data on release. Fix: build parquet.Row values manually with explicit definition levels (1 = present, 0 = null) via schema.Lookup for each column's index, bypassing the reflect path entirely. Verified against real pandas: false/0.0/"" now round-trip as themselves, while genuinely missing columns (e.g. an unmatched lookup join) still round-trip as null. Added a regression test. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
python/package (claudescope-py) wrapping theClaudeScopeCLI so users getsession.query(spl) -> pandas.DataFrameinstead of shelling out and hand-parsing JSON.subprocess(reuses its daemon auto-start logic incli/client.go) rather than duplicating session/daemon lifecycle logic against the HTTP API directly — seepython/README.mdfor the tradeoff.load/connect/sessions,query→ DataFrame,query_multi(union mode → one tagged DataFrame withdf.attrs["errors"]; comparison mode →dict[session_id, DataFrame | ClaudeScopeError]), plusget/range/find_bool/find_threshold/stats/set/disconnect.main.go'swriteErrorAndExitwraps a failed daemon request's own JSON error body in another{error, code}envelope) so callers get a clean message/code instead of a raw JSON blob — found and fixed this while doing end-to-end verification.Test plan
pytest(14 tests, mocked subprocess) — all pass.wpilog:query,timechart,find_bool,stats,query_multi(union + comparison), and the error path (missing field) all verified against the real binary, not just mocks🤖 Generated with Claude Code