-
Notifications
You must be signed in to change notification settings - Fork 0
feat: LangChain tools for Hotdata managed databases #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
eddietejeda
wants to merge
8
commits into
main
Choose a base branch
from
feat/managed-database-tools
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
e292d01
feat: add LangChain tools for Hotdata managed databases
eddietejeda dd0eee5
merge: align with remote main bootstrap
eddietejeda f48fb0f
ci: add PyPI publish workflow on version tags
eddietejeda 1a63370
chore: pin explicit hotdata>=0.2.0 dependency
eddietejeda ca1e96e
ci: add standardized release script and automation
eddietejeda 5efa8de
ci: add pytest workflow and demo notebook smoke tests
eddietejeda 9dc9bc6
fix: rewrite changelog updater for Keep a Changelog format
eddietejeda 1275ae5
test: fix changelog unit test imports in CI
eddietejeda File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| name: Check release metadata | ||
|
|
||
| on: | ||
| pull_request: | ||
| paths: | ||
| - 'pyproject.toml' | ||
| - 'CHANGELOG.md' | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| check: | ||
| name: Verify changelog matches version bump | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6 | ||
| with: | ||
| python-version: '3.12' | ||
|
|
||
| - name: Check release metadata | ||
| run: python scripts/check-release.py |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| name: CI | ||
|
|
||
| on: | ||
| push: | ||
| branches: ["main", "master"] | ||
| pull_request: | ||
|
|
||
| concurrency: | ||
| group: ci-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| test: | ||
| name: Test (Python 3.12) | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | ||
|
|
||
| - uses: astral-sh/setup-uv@d4b2f3b6ecc6e67c4457f6d3e41ec42d3d0fcb86 # v6 | ||
| with: | ||
| enable-cache: true | ||
|
|
||
| - name: Set up Python | ||
| run: uv python install 3.12 | ||
|
|
||
| - name: Install dependencies | ||
| run: uv sync --locked | ||
|
|
||
| - name: Test | ||
| run: uv run pytest -v | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| name: Publish to PyPI | ||
|
|
||
| on: | ||
| push: | ||
| tags: | ||
| - 'v[0-9]*' | ||
|
|
||
| concurrency: | ||
| group: pypi-publish-${{ github.ref_name }} | ||
| cancel-in-progress: false | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| build: | ||
| name: Build distribution | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | ||
|
|
||
| - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6 | ||
| with: | ||
| python-version: '3.12' | ||
|
|
||
| - name: Install build tooling | ||
| run: python -m pip install --upgrade build twine | ||
|
|
||
| - name: Verify tag matches pyproject version | ||
| run: | | ||
| if [[ ! "$GITHUB_REF_NAME" =~ ^v[0-9] ]]; then | ||
| echo "Release tag '$GITHUB_REF_NAME' must start with 'v' followed by a digit (e.g. v1.0.0)" >&2 | ||
| exit 1 | ||
| fi | ||
| tag="${GITHUB_REF_NAME#v}" | ||
| pkg_version=$(python -c "import tomllib,pathlib; print(tomllib.loads(pathlib.Path('pyproject.toml').read_text())['project']['version'])") | ||
| if [ "$tag" != "$pkg_version" ]; then | ||
| echo "Release tag ($tag) does not match pyproject.toml version ($pkg_version)" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| - name: Build sdist and wheel | ||
| run: python -m build | ||
|
|
||
| - name: Check distribution metadata | ||
| run: python -m twine check --strict dist/* | ||
|
|
||
| - uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5 | ||
| with: | ||
| name: dist | ||
| path: dist/ | ||
|
|
||
| publish: | ||
| name: Publish to PyPI | ||
| needs: build | ||
| runs-on: ubuntu-latest | ||
| environment: | ||
| name: pypi | ||
| url: https://pypi.org/p/hotdata-langchain | ||
| permissions: | ||
| id-token: write | ||
| steps: | ||
| - uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5 | ||
| with: | ||
| name: dist | ||
| path: dist/ | ||
|
|
||
| - name: Publish via Trusted Publishing | ||
| uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0 |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| name: GitHub Release | ||
|
|
||
| on: | ||
| push: | ||
| tags: | ||
| - 'v[0-9]*' | ||
|
|
||
| permissions: | ||
| contents: write | ||
|
|
||
| jobs: | ||
| release: | ||
| name: Create GitHub Release | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | ||
|
|
||
| - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6 | ||
| with: | ||
| python-version: '3.12' | ||
|
|
||
| - name: Read package metadata | ||
| id: meta | ||
| run: | | ||
| pkg_name=$(python -c "import tomllib,pathlib; print(tomllib.loads(pathlib.Path('pyproject.toml').read_text())['project']['name'])") | ||
| pkg_version="${GITHUB_REF_NAME#v}" | ||
| echo "name=${pkg_name}" >> "$GITHUB_OUTPUT" | ||
| echo "version=${pkg_version}" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Extract changelog notes | ||
| id: notes | ||
| run: | | ||
| set -euo pipefail | ||
| version="${GITHUB_REF_NAME#v}" | ||
| if [[ -f CHANGELOG.md ]]; then | ||
| body="$(python scripts/extract-changelog.py "$version")" | ||
| else | ||
| body="Release ${version}." | ||
| fi | ||
| delimiter="EOF_${RANDOM}_${RANDOM}" | ||
| { | ||
| echo "body<<${delimiter}" | ||
| echo "$body" | ||
| echo "${delimiter}" | ||
| } >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Create GitHub Release | ||
| uses: softprops/action-gh-release@1e812e8210a4a8a0b23075e5795f2a4e2b2a0b7 # v2.2.2 | ||
| with: | ||
| tag_name: ${{ github.ref_name }} | ||
| name: ${{ steps.meta.outputs.name }} ${{ steps.meta.outputs.version }} | ||
| body: ${{ steps.notes.outputs.body }} | ||
| generate_release_notes: false | ||
| make_latest: true |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| # Python | ||
| __pycache__/ | ||
| *.py[cod] | ||
| *$py.class | ||
| *.so | ||
|
|
||
| # Virtual environments | ||
| .env | ||
| .venv | ||
| env/ | ||
| venv/ | ||
|
|
||
| # Testing | ||
| .pytest_cache/ | ||
| .coverage | ||
| htmlcov/ | ||
|
|
||
| # Packaging | ||
| *.egg-info/ | ||
| dist/ | ||
| build/ | ||
|
|
||
| .DS_Store |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| # Changelog | ||
|
|
||
| All notable changes to this project will be documented in this file. | ||
|
|
||
| The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), | ||
| and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
|
||
| ## [Unreleased] | ||
|
|
||
| ## [0.1.0] - 2026-05-19 | ||
|
|
||
| ### Added | ||
|
|
||
| - Initial release with LangChain tools for Hotdata managed databases. |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,60 @@ | ||
| # hotdata-langchain | ||
| LangChain tools for Hotdata runtime | ||
|
|
||
| LangChain tools for [Hotdata](https://hotdata.dev), built on **hotdata-runtime**. | ||
|
|
||
| ## Features | ||
|
|
||
| - **SQL tool** — run workspace SQL and return JSON rows for agents | ||
| - **Managed database tools** — list, create, and load parquet into Hotdata-owned catalogs (replaces legacy dataset uploads) | ||
|
|
||
| ## Install | ||
|
|
||
| ```bash | ||
| pip install hotdata-langchain | ||
| ``` | ||
|
|
||
| Requires `HOTDATA_API_KEY`. Optionally set `HOTDATA_WORKSPACE`, `HOTDATA_API_URL`, or `HOTDATA_SANDBOX`. | ||
|
|
||
| ## Usage | ||
|
|
||
| ```python | ||
| import hotdata_langchain as hl | ||
|
|
||
| client = hl.from_env() | ||
| tools = hl.make_hotdata_tools(client) | ||
|
|
||
| for tool in tools: | ||
| print(tool.name, tool.description) | ||
| ``` | ||
|
|
||
| Managed database example: | ||
|
|
||
| ```python | ||
| tools = {tool.name: tool for tool in hl.make_hotdata_tools(client)} | ||
|
|
||
| tools["hotdata_create_managed_database"].invoke( | ||
| {"name": "sales", "schema_name": "public", "tables": "orders"} | ||
| ) | ||
|
|
||
| tools["hotdata_load_managed_table"].invoke( | ||
| { | ||
| "database": "sales", | ||
| "table": "orders", | ||
| "file": "/path/to/orders.parquet", | ||
| } | ||
| ) | ||
| ``` | ||
|
|
||
| ## Examples | ||
|
|
||
| ```bash | ||
| uv run python examples/langchain_basic.py | ||
| uv run python examples/langchain_managed_db.py | ||
| ``` | ||
|
|
||
| ## Development | ||
|
|
||
| ```bash | ||
| uv sync --locked | ||
| uv run pytest | ||
| ``` |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| # Releasing | ||
|
|
||
| Every release uses `./scripts/release.sh`. Do not bump versions, tag, or create GitHub Releases manually. | ||
|
|
||
| ## One-time setup | ||
|
|
||
| - Install [GitHub CLI](https://cli.github.com/) (`gh`) and authenticate. | ||
| - Ensure PyPI [trusted publishing](https://docs.pypi.org/trusted-publishers/) is configured for this repo (`publish.yml` uses the `pypi` GitHub environment). | ||
|
|
||
| ## Release steps | ||
|
|
||
| 1. Add user-facing notes under `## [Unreleased]` in `CHANGELOG.md`. | ||
| 2. Prepare the release PR: | ||
|
|
||
| ```bash | ||
| ./scripts/release.sh prepare patch # or minor | major | 1.2.3 | ||
| ``` | ||
|
|
||
| 3. Merge the PR after CI passes (including the changelog check). | ||
| 4. Publish from a clean default branch checkout: | ||
|
|
||
| ```bash | ||
| git checkout main # or master for hotdata-marimo | ||
| git pull | ||
| ./scripts/release.sh publish | ||
| ``` | ||
|
|
||
| ## What happens automatically | ||
|
|
||
| Pushing a `vX.Y.Z` tag triggers two workflows: | ||
|
|
||
| | Workflow | Purpose | | ||
| |----------|---------| | ||
| | `publish.yml` | Build wheel/sdist and publish to PyPI | | ||
| | `release.yml` | Create the GitHub Release with notes from `CHANGELOG.md` | | ||
|
|
||
| ## Enforcement | ||
|
|
||
| - **PR check** (`check-release.yml`): if `pyproject.toml` version changes, `CHANGELOG.md` must contain a matching `## [X.Y.Z]` section. | ||
| - **Tag check** (`publish.yml`): the tag (without `v`) must match `[project].version` in `pyproject.toml`. | ||
| - **Publish guard** (`release.sh publish`): refuses to tag if the changelog section is missing. | ||
|
|
||
| Together, these make it hard to ship a version without changelog notes or a GitHub Release. |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| """Minimal LangChain tool usage with hotdata-langchain.""" | ||
|
|
||
| import hotdata_langchain as hl | ||
|
|
||
|
|
||
| def main() -> None: | ||
| client = hl.from_env() | ||
| tools = hl.make_hotdata_tools(client) | ||
| by_name = {tool.name: tool for tool in tools} | ||
|
|
||
| sql_tool = by_name["hotdata_execute_sql"] | ||
| print(sql_tool.invoke({"sql": "SELECT 1 AS ok"})) | ||
|
|
||
| list_tool = by_name["hotdata_list_managed_databases"] | ||
| print(list_tool.invoke({})) | ||
|
|
||
| client.close() | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| """Managed database tools for LangChain agents.""" | ||
|
|
||
| import hotdata_langchain as hl | ||
|
|
||
|
|
||
| def main() -> None: | ||
| client = hl.from_env() | ||
| tools = hl.make_hotdata_tools(client) | ||
| by_name = {tool.name: tool for tool in tools} | ||
|
|
||
| create = by_name["hotdata_create_managed_database"] | ||
| print( | ||
| create.invoke( | ||
| { | ||
| "name": "demo_sales", | ||
| "schema_name": "public", | ||
| "tables": "orders\ncustomers", | ||
| } | ||
| ) | ||
| ) | ||
|
|
||
| load = by_name["hotdata_load_managed_table"] | ||
| print( | ||
| load.invoke( | ||
| { | ||
| "database": "demo_sales", | ||
| "table": "orders", | ||
| "file": "/path/to/orders.parquet", | ||
| "schema_name": "public", | ||
| } | ||
| ) | ||
| ) | ||
|
|
||
| client.close() | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() |
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
pyproject.tomldeclaresrequires-python = ">=3.10", but CI only exercises Python 3.12. The code uses 3.10+ generic syntax (list[str] | None) underfrom __future__ import annotations, so it should work on 3.10/3.11, but nothing here verifies those versions stay green. Consider astrategy.matrix.python-version: ['3.10', '3.11', '3.12']so a regression at the lower bounds is caught before users hit it. (not blocking)