Skip to content

Conversation

@gkorland
Copy link
Contributor

@gkorland gkorland commented Oct 2, 2025

Fix #271

Summary by CodeRabbit

  • New Features
    • Introduced official Python and TypeScript clients with token/cookie auth, timeouts, and streaming support for listing, managing, querying, and confirming schemas.
  • Documentation
    • Added comprehensive READMEs for both clients with installation, usage, and troubleshooting.
  • Tests
    • Added unit tests for Python and TypeScript clients; integrated client tests into CI.
  • Chores
    • Updated CI workflow and Makefile to install and test server and clients; expanded .gitignore entries.
  • Style
    • Adjusted ESLint configurations and minor TypeScript code cleanups to ignore unused underscored arguments.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 2, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Adds new Python and TypeScript clients with async HTTP/streaming support, documentation, configs, and tests. Updates Makefile and CI to install and test clients. Minor frontend TypeScript cleanups to unused variables and catches. Adjusts ESLint rules and gitignore entries.

Changes

Cohort / File(s) Summary
Python client package
clients/python/queryweaver_client/__init__.py, clients/python/queryweaver_client/client.py
New async HTTP client with streaming parsing and error handling; exposes QueryWeaverClient and APIError.
Python client packaging & docs
clients/python/setup.py, clients/python/Pipfile, clients/python/README.md
Adds packaging, dependency specs (aiohttp, pytest), Python 3.12, and usage docs.
Python client tests
clients/python/tests/test_client_basic.py
Adds pytest-asyncio tests with mocked aiohttp-like session and streaming paths.
TypeScript client core
clients/ts/src/client.ts, clients/ts/src/types.ts, clients/ts/src/index.ts
New TS HTTP client with streaming support, typed APIs, and exported surface.
TypeScript client project setup
clients/ts/package.json, clients/ts/tsconfig.json, clients/ts/.eslintrc.json, clients/ts/jest.config.js, clients/ts/.gitignore, clients/ts/README.md
Adds build/test/lint config, Jest + ts-jest, ESLint rules, dist ignore, and docs.
TypeScript client tests
clients/ts/tests/client.test.ts
Adds Jest tests for construction, URL building, and listSchemas.
CI and Makefile
.github/workflows/tests.yml, Makefile
Introduces client-tests job and make targets: install-server/clients, test-clients, install-playwright; updates test flows.
Frontend TS tweaks
app/ts/modules/graph_select.ts, app/ts/modules/left_toolbar.ts, app/ts/modules/messages.ts, app/ts/modules/modals.ts, app/ts/modules/tokens.ts
Removes unused params, switches to bare catch, minor signature/index removal; no logic changes.
Lint config updates
app/eslint.config.cjs, clients/ts/.eslintrc.json
Adds/updates no-unused-vars with argsIgnorePattern '^_' and TS-specific rules.
Repo ignore
.gitignore, clients/ts/.gitignore
Ignores Python \*.egg-info and TS /dist.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Dev as Developer App
  participant QC as QueryWeaverClient (Python/TS)
  participant HTTP as HTTP Server (QueryWeaver)

  Note over Dev,QC: Initialize client with baseUrl, optional apiToken
  Dev->>QC: listSchemas()
  QC->>HTTP: GET /graphs (Authorization?)
  HTTP-->>QC: 200 JSON {graphs:[...]}
  QC-->>Dev: string[]

  Dev->>QC: query(graphId, chatData)
  QC->>HTTP: POST /graphs/{id} (JSON body)
  rect rgba(200, 230, 255, 0.3)
    Note over QC,HTTP: Streaming response (NDJSON/chunked delimiter)
    HTTP-->>QC: chunk1 | ... | final event
    QC->>QC: Buffer, split by delimiter, parse JSON
  end
  QC-->>Dev: final event (object)

  Dev->>QC: connectDatabase(dbUrl)
  QC->>HTTP: POST /database (JSON)
  HTTP-->>QC: stream chunks
  QC-->>Dev: last parsed event

  alt Non-2xx
    HTTP-->>QC: Error status + JSON/text
    QC-->>Dev: throw APIError(status, response)
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • Staging #104 — Adds/modifies QueryWeaver client implementations; overlaps with new Python/TS clients here.
  • Staging #241 — Changes to app/ts/modules/graph_select.ts; same file edited in this PR.
  • initial e2e tests #35 — Updates CI workflow and Makefile targets; overlaps with tests.yml and Makefile changes here.

Suggested reviewers

  • Naseem77
  • galshubeli

Poem

A nibble of code, a hop through streams,
I buffered the bytes and followed the beams.
Python and TS, two carrots in tow,
Clients now speak in a silky flow.
CI drums roll, Makefile sings—
QueryWeaver hums on twitching springs. 🐇✨

Pre-merge checks and finishing touches

❌ Failed checks
Check name Status Explanation Resolution
Description Check ⚠️ Warning Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues Check ⚠️ Warning The PR implements the Python client library as specified in Issue #271 by providing a fully functional QueryWeaverClient with authentication, REST methods, streaming support, setup configuration, documentation, tests, and CI integration, thus satisfying the primary requirement to wrap the REST API. No further action required as the Python client implementation satisfies all listed requirements.
Out of Scope Changes Check ⚠️ Warning This PR also introduces substantial unrelated changes—including TypeScript client code, CI workflow updates, Makefile targets, ESLint configuration, and modifications to frontend TypeScript modules—that are outside the scope of Issue #271’s goal to build only a Python client. Separate the non-Python-client modifications into distinct pull requests so that Issue #271 remains focused solely on delivering the Python client implementation.
Docstring Coverage ⚠️ Warning Docstring coverage is 61.54% which is insufficient. The required threshold is 80.00%. You can run `@coderabbitai generate docstrings` to improve docstring coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Title Check ✅ Passed The title succinctly summarizes the central change of introducing REST‐based remote clients, aligning with the added Python and TypeScript client libraries and related integrations in this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gkorland gkorland changed the base branch from main to staging October 2, 2025 09:16
@github-actions
Copy link

github-actions bot commented Oct 2, 2025

Dependency Review

The following issues were found:

  • ✅ 0 vulnerable package(s)
  • ✅ 0 package(s) with incompatible licenses
  • ✅ 0 package(s) with invalid SPDX license definitions
  • ⚠️ 5 package(s) with unknown licenses.
  • ⚠️ 1 packages with OpenSSF Scorecard issues.

View full job summary

@gkorland gkorland changed the title Remote client Remote Python client Oct 2, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a new asynchronous Python client for QueryWeaver and refactors server-side graph/database routes into core modules, aligning responsibilities and improving maintainability. It also bumps several dependencies and adjusts streaming behavior to be more consistent.

  • Add Python aiohttp-based client with basic tests and README
  • Refactor graph/database logic into api/core (text2sql, schema_loader, errors) and update routes to use these abstractions
  • Update package versions, Dockerfile build deps, and minor frontend/TS fix

Reviewed Changes

Copilot reviewed 5 out of 8 changed files in this pull request and generated 12 comments.

Show a summary per file
File Description
server.json Bump server and package versions; adjust name casing.
clients/python/queryweaver_client/* New async Python client and package metadata.
clients/python/tests/test_client_basic.py New tests for the Python client.
clients/python/README.md Usage and development instructions for the client.
clients/python/Pipfile Pipenv setup for the client (aiohttp, pytest-asyncio).
clients/python/setup.py Packaging metadata for the client (install_requires, extras).
app/ts/modules/graphs.ts Minor boolean cast fix for demo graph detection.
app/package.json Dev dependency bumps (esbuild, eslint, TS ESLint).
api/routes/graphs.py Route layer refactored to call core text2sql/schema_loader functions.
api/routes/database.py Route now delegates to core schema_loader.load_database.
api/core/text2sql.py New core module: query, schema retrieval, destructive ops, refresh, delete.
api/core/schema_loader.py New core module: database connection streaming and listing databases.
api/core/errors.py New custom exception classes.
api/core/init.py Export core symbols for convenience.
Pipfile Bump backend dependency versions.
Dockerfile Add build-essential and clean up apt usage.
CODE_OF_CONDUCT.md Add project Code of Conduct.
.github/wordlist.txt Update wordlist for spellcheck.
Files not reviewed (1)
  • app/package-lock.json: Language not supported

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@gkorland
Copy link
Contributor Author

gkorland commented Oct 2, 2025

@CodeRabbit review

@gkorland
Copy link
Contributor Author

gkorland commented Oct 2, 2025

/review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 2, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@gkorland gkorland requested a review from Copilot October 2, 2025 18:48
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 24 out of 27 changed files in this pull request and generated 6 comments.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

♻️ Duplicate comments (1)
clients/python/queryweaver_client/client.py (1)

69-71: Don’t close caller-owned sessions

__aexit__ closes the session unconditionally, so external sessions handed in by the caller get torn down unexpectedly. Track ownership and only close sessions the client created itself.

-    async def __aexit__(self, exc_type, exc_val, exc_tb):
-        if self._session and not self._session.closed:
-            await self._session.close()
+    async def __aexit__(self, exc_type, exc_val, exc_tb):
+        if self._owns_session and self._session and not self._session.closed:
+            await self._session.close()
🧹 Nitpick comments (3)
app/ts/modules/left_toolbar.ts (1)

33-35: Consider logging the error for debugging.

The bare catch block suppresses any error that occurs during the initial setOpen call. While the fallback to setOpen(true) is safe, logging the error would aid debugging if media query matching fails unexpectedly.

Apply this diff to add error logging:

-    } catch {
+    } catch (err) {
+        console.warn('Media query matching failed, defaulting to open:', err);
         setOpen(true);
     }
clients/python/Pipfile (1)

14-15: Loosen Python version constraint
In clients/python/Pipfile (lines 14–15), python_version is set to "3.12", but no 3.12-only syntax (e.g., PEP 695 generics) is used. Unless you require 3.12, consider broadening support to Python 3.8+.

clients/python/README.md (1)

107-107: Optional: Consistent horizontal rule style.

For consistency with line 97, consider using the same horizontal rule style (-----------------------) instead of (-----------).

Apply this diff:

-## Want more?
------------
+## Want more?
+-----------------------
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 63608c5 and 72a580e.

⛔ Files ignored due to path filters (2)
  • clients/python/Pipfile.lock is excluded by !**/*.lock
  • clients/ts/package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (25)
  • .github/workflows/tests.yml (5 hunks)
  • .gitignore (2 hunks)
  • Makefile (3 hunks)
  • app/eslint.config.cjs (1 hunks)
  • app/ts/modules/graph_select.ts (1 hunks)
  • app/ts/modules/left_toolbar.ts (2 hunks)
  • app/ts/modules/messages.ts (1 hunks)
  • app/ts/modules/modals.ts (1 hunks)
  • app/ts/modules/tokens.ts (1 hunks)
  • clients/python/Pipfile (1 hunks)
  • clients/python/README.md (1 hunks)
  • clients/python/queryweaver_client/__init__.py (1 hunks)
  • clients/python/queryweaver_client/client.py (1 hunks)
  • clients/python/setup.py (1 hunks)
  • clients/python/tests/test_client_basic.py (1 hunks)
  • clients/ts/.eslintrc.json (1 hunks)
  • clients/ts/.gitignore (1 hunks)
  • clients/ts/README.md (1 hunks)
  • clients/ts/jest.config.js (1 hunks)
  • clients/ts/package.json (1 hunks)
  • clients/ts/src/client.ts (1 hunks)
  • clients/ts/src/index.ts (1 hunks)
  • clients/ts/src/types.ts (1 hunks)
  • clients/ts/tests/client.test.ts (1 hunks)
  • clients/ts/tsconfig.json (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-09-02T15:24:21.682Z
Learnt from: CR
PR: FalkorDB/QueryWeaver#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-02T15:24:21.682Z
Learning: Applies to tests/e2e/test_*.py : E2E test files should be placed under tests/e2e/test_*.py for Playwright runs

Applied to files:

  • .github/workflows/tests.yml
🪛 checkmake (0.2.2)
Makefile

[warning] 1-1: Missing required phony target "all"

(minphony)

🪛 markdownlint-cli2 (0.18.1)
clients/python/README.md

107-107: Horizontal rule style
Expected: -----------------------; Actual: -----------

(MD035, hr-style)

🪛 Ruff (0.13.2)
clients/python/tests/test_client_basic.py

46-46: Avoid specifying long messages outside the exception class

(TRY003)


75-75: Unused method argument: url

(ARG002)


75-75: Unused method argument: timeout

(ARG002)


87-87: Unused method argument: json

(ARG002)


87-87: Unused method argument: timeout

(ARG002)


117-117: Unused method argument: url

(ARG002)


117-117: Unused method argument: timeout

(ARG002)


183-183: Unused method argument: url

(ARG002)


183-183: Unused method argument: timeout

(ARG002)


197-197: Possible hardcoded password assigned to argument: "api_token"

(S106)

clients/python/queryweaver_client/client.py

83-83: Avoid specifying long messages outside the exception class

(TRY003)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: e2e-tests
  • GitHub Check: e2e-tests
🔇 Additional comments (19)
app/ts/modules/tokens.ts (1)

141-141: LGTM: Unused error variable removed.

Dropping the unused err parameter is a valid cleanup that aligns with modern JavaScript/TypeScript best practices. The error handling behavior remains unchanged.

clients/ts/.gitignore (1)

1-1: LGTM!

Standard practice to exclude the TypeScript build output directory from version control.

.gitignore (1)

4-4: LGTM!

Appropriate addition to prevent Python egg-info metadata (generated during packaging) from being committed.

app/ts/modules/modals.ts (1)

270-270: LGTM!

Removing the explicit this type annotation relaxes TypeScript strictness while preserving runtime behavior, as this is still correctly bound by addEventListener.

app/ts/modules/left_toolbar.ts (1)

57-57: LGTM!

Removing the unused event parameter aligns with the ESLint configuration (argsIgnorePattern: '^_') and improves code clarity.

app/ts/modules/messages.ts (1)

77-77: LGTM!

Removing the unused index parameter improves clarity and aligns with the project's ESLint configuration.

clients/python/Pipfile (1)

1-15: LGTM overall!

The Pipfile appropriately declares runtime dependencies (aiohttp), an editable local package, and testing dependencies (pytest, pytest-asyncio) consistent with the new async Python client implementation.

app/eslint.config.cjs (1)

23-23: LGTM!

Adding argsIgnorePattern: '^_' to the no-unused-vars rule is a standard practice that allows developers to explicitly mark unused parameters with a leading underscore, improving code clarity while maintaining linter hygiene. This aligns with the TypeScript client ESLint configuration.

clients/ts/package.json (3)

1-36: LGTM overall!

The package.json establishes a well-structured TypeScript client package with appropriate metadata, entry points, scripts, and development tooling. The structure aligns with the new client implementation and test coverage introduced in the PR.


33-35: Confirm Node ≥18 requirement
Client code uses native fetch and AbortSignal.timeout, which are only supported in Node 18+. Keeping "engines": {"node": ">=18.0.0"} is correct.


32-32: No external runtime dependencies found
All imports and require calls in clients/ts/src are relative; the dependencies field may safely remain empty.

clients/ts/.eslintrc.json (1)

1-23: LGTM!

The ESLint configuration is well-structured and appropriate for a TypeScript client project. The rule allowing unused parameters prefixed with _ aligns with the callback naming conventions used elsewhere in the codebase.

clients/python/setup.py (1)

1-52: LGTM!

The package configuration is complete and correct. The runtime dependency on aiohttp and development extras including pytest-asyncio properly support the async client implementation and test suite.

app/ts/modules/graph_select.ts (1)

25-25: LGTM!

The callback parameter rename to _ correctly signals intentionally unused parameters and aligns with the ESLint convention introduced in the TypeScript client configuration.

clients/ts/tsconfig.json (1)

1-28: LGTM!

The TypeScript configuration is comprehensive and follows best practices. Strict type checking, declaration generation, and proper include/exclude patterns provide a solid foundation for the client library.

clients/ts/jest.config.js (1)

1-15: LGTM!

The Jest configuration is well-structured for a TypeScript project. The coverage collection settings and test patterns are appropriate for the client library test suite.

Makefile (1)

1-90: Well-structured modularization of build targets.

The new targets (install-server, install-clients, test-clients) properly separate server and client dependency management and testing, improving the development workflow and CI integration.

.github/workflows/tests.yml (2)

40-42: LGTM!

The workflow consolidation to use Makefile targets (install-server, test-unit, install-playwright, test-e2e) improves maintainability and aligns with the modularized build system.

Also applies to: 52-52, 85-91, 107-107


121-148: Well-structured client testing job.

The new client-tests job properly sets up both Python 3.11 and Node.js 18 environments and runs client tests independently from server tests, providing good separation of concerns.

@gkorland gkorland changed the title Remote Python client Remote client Oct 2, 2025
@gkorland gkorland changed the title Remote client Add Remote clients over REST Oct 2, 2025
@gkorland gkorland requested review from Copilot October 3, 2025 10:56
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 24 out of 27 changed files in this pull request and generated 3 comments.

"api-client"
],
"author": "QueryWeaver Team",
"license": "MIT",
Copy link

Copilot AI Oct 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

License is MIT here, but the Python client's setup.py classifier declares AGPLv3. Please align licenses between clients (and the repository) to avoid confusion, or clarify the intended license for each client.

Suggested change
"license": "MIT",
"license": "AGPL-3.0",

Copilot uses AI. Check for mistakes.
classifiers=[
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"License :: OSI Approved :: GNU Affero General Public License v3",
Copy link

Copilot AI Oct 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This declares AGPLv3, while the TypeScript client declares MIT in package.json and README; please reconcile the license across client packages to ensure consistency.

Suggested change
"License :: OSI Approved :: GNU Affero General Public License v3",
"License :: OSI Approved :: MIT License",

Copilot uses AI. Check for mistakes.
Comment on lines +16 to +19
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"types": ["node", "jest"]
},
Copy link

Copilot AI Oct 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Including jest types in the main tsconfig can leak test globals into the library build. Consider moving Jest types to a dedicated test tsconfig (e.g., tsconfig.spec.json) or configuring ts-jest to supply them, and keep the production build free of test-only types.

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 24 out of 27 changed files in this pull request and generated 3 comments.

return self

async def __aexit__(self, exc_type, exc_val, exc_tb):
if self._session and not self._session.closed:
Copy link

Copilot AI Oct 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will close a user-provided session on exit. Since you track ownership with _owns_session, only close the session if it was created by the client (self._owns_session is True). Suggested fix: check self._owns_session before closing.

Suggested change
if self._session and not self._session.closed:
if self._owns_session and self._session and not self._session.closed:

Copilot uses AI. Check for mistakes.
Comment on lines +44 to +51
this.defaultHeaders = {
'Accept': 'application/json',
'Content-Type': 'application/json',
};

if (this.apiToken) {
this.defaultHeaders['Authorization'] = `Bearer ${this.apiToken}`;
}
Copy link

Copilot AI Oct 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting Content-Type: application/json on all requests (including GET) can trigger unnecessary CORS preflight requests in browsers and increase latency. Consider removing Content-Type from defaultHeaders and only setting it on requests with a body (e.g., POST), or constructing headers per call.

Copilot uses AI. Check for mistakes.
Comment on lines +25 to +28
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"License :: OSI Approved :: GNU Affero General Public License v3",
"Programming Language :: Python :: 3",
Copy link

Copilot AI Oct 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Python client declares AGPLv3 in its classifiers, while the TypeScript client package.json uses MIT. Please confirm and align the license across clients (and include the correct license file if needed) to avoid confusion for users.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Build a python client that wraps the REST API

2 participants