From 59f0668a3b866950431870abeb0f16ce5e0c65b1 Mon Sep 17 00:00:00 2001 From: Arda Tekin <2003arda2003@gmail.com> Date: Fri, 20 Nov 2026 01:27:40 +0200 Subject: [PATCH] feat: add [server] extra and localhost web UI (tablassert serve) --- .github/workflows/ci.yml | 2 +- .github/workflows/security.yml | 2 +- CHANGELOG.md | 1 + CONTRIBUTING.md | 8 +- Makefile | 2 +- README.md | 3 +- docs/cli.md | 21 +- docs/index.md | 2 +- docs/installation.md | 4 +- llms.txt | 7 +- pyproject.toml | 4 + scripts/vulture_whitelist.py | 4 + src/tablassert/cli.py | 26 +++ src/tablassert/extras.py | 2 + src/tablassert/server.py | 357 ++++++++++++++++++++++++++++++++ tests/test_docs_cli_coverage.py | 2 + tests/test_extras.py | 4 +- tests/test_server.py | 101 +++++++++ uv.lock | 122 ++++++++--- 19 files changed, 629 insertions(+), 45 deletions(-) create mode 100644 src/tablassert/server.py create mode 100644 tests/test_server.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 340ca406..41957c36 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,7 +22,7 @@ concurrency: env: # The Python-syncing jobs install this EXACT set, so they share one warm uv cache instead # of racing to save mutually-useless ones. See the `ci` group in pyproject.toml. - SYNC_ARGS: --no-default-groups --group ci --extra cli --extra qc --extra log + SYNC_ARGS: --no-default-groups --group ci --extra cli --extra qc --extra log --extra server jobs: # Release gate: a pyproject.toml push that does not change project.version (a dependency diff --git a/.github/workflows/security.yml b/.github/workflows/security.yml index e31eb732..7cb2ca85 100644 --- a/.github/workflows/security.yml +++ b/.github/workflows/security.yml @@ -19,7 +19,7 @@ concurrency: env: # Keep in sync with SYNC_ARGS in ci.yml so this workflow restores the same warm uv cache. - SYNC_ARGS: --no-default-groups --group ci --extra cli --extra qc --extra log + SYNC_ARGS: --no-default-groups --group ci --extra cli --extra qc --extra log --extra server jobs: secrets: diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a64043d..5bd0dca9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ All notable changes to this project are documented in this file. ### Added +- **Localhost Web UI (`tablassert serve`) behind the optional `[server]` extra.** Installs `fastapi` and `uvicorn`, binds strictly to loopback (`127.0.0.1` by default), walks users through source selection, column mapping, provenance, and RIG metadata, validates inline against `Section`/`Graph`, emits plain editable YAML, and streams `build-kg` progress. ([#261](https://github.com/SkyeAv/Tablassert/issues/261)) - **NDJSON (JSONL) is a fifth table source kind.** `kind: ndjson` scans newline-delimited JSON lazily with `pl.scan_ndjson` and renames its columns positionally to `column_1..` in first-seen key order, matching the `parquet` reader contract so `method: column` encodings keep using Excel-style letters. Ragged records scan missing keys as nulls instead of dropping rows; an empty file fails fast with a coded `ndjson-empty` error instead of polars' opaque `Cannot infer NDJSON types` compute error. ([#283](https://github.com/SkyeAv/Tablassert/pull/283), [#262](https://github.com/SkyeAv/Tablassert/issues/262)) - **Every pull request must carry a new changelog entry.** A stdlib-only `scripts/check_changelog.py` requires at least one new bullet under the `## Unreleased` heading of `CHANGELOG.md` relative to the pull request's merge base, failing with remediation guidance when whitespace, subheadings, or released-history edits are the only additions; a CI job runs it on every pull request including forks, release-bump and dependency-bump pull requests are exempt by their `chore(release):` / `chore(deps):` title or commit subject, documentation-only pull requests (every changed path is markdown or under `docs/`) are exempt via `--exempt-docs-only`, and a pre-push hook mirrors the same check locally. ([#284](https://github.com/SkyeAv/Tablassert/pull/284), [#282](https://github.com/SkyeAv/Tablassert/issues/282)) - **Arrow IPC (Feather v2) is a fourth table source kind.** `kind: ipc` scans a `.arrow` file lazily with `pl.scan_ipc` and renames its columns positionally to `column_1..` in schema order, matching the `parquet` reader contract so `method: column` encodings keep using Excel-style letters. Only IPC file layout is supported; a stream-layout file fails fast with a coded `ipc-stream-unsupported` error naming the conversion fix instead of polars' opaque `InvalidFooter` compute error. ([#281](https://github.com/SkyeAv/Tablassert/pull/281), [#264](https://github.com/SkyeAv/Tablassert/issues/264)) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5d19a975..71bf63db 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -14,12 +14,12 @@ Thank you for helping make Tablassert reliable. Reliability here includes the de ```bash git clone https://github.com/SkyeAv/Tablassert.git cd Tablassert -uv sync --group dev --extra cli --extra qc --extra log +uv sync --group dev --extra cli --extra qc --extra log --extra server uv run maturin develop --manifest-path rust/Cargo.toml uv run tablassert --help ``` -`uv sync --group dev --extra cli --extra qc --extra log` installs the development tools plus the CLI runtime, optional QC runtime, and loguru logging. `maturin develop` builds the PyO3 extension from `rust/` and installs it into the uv-managed environment. +`uv sync --group dev --extra cli --extra qc --extra log --extra server` installs the development tools plus the CLI runtime, optional QC runtime, and loguru logging. `maturin develop` builds the PyO3 extension from `rust/` and installs it into the uv-managed environment. Shortcut: @@ -49,7 +49,7 @@ The `Makefile` is intentionally small and mirrors the underlying commands: | Target | Runs | | --- | --- | -| `make setup` | `uv sync --group dev --extra cli --extra qc --extra log` and debug `maturin develop` | +| `make setup` | `uv sync --group dev --extra cli --extra qc --extra log --extra server` and debug `maturin develop` | | `make dev` | Debug editable extension build | | `make build` | Release editable extension build | | `make test` | Python tests with coverage | @@ -118,7 +118,7 @@ What the gates cover: - **Ruff linting and formatting.** The current tree enforces core pycodestyle/pyflakes safety checks plus stale-suppression detection. It also enforces an expanded rule set covering common bug patterns (bugbear), simplifications, Python-version upgrades, pytest style, import order, and comprehensions. Treat `uv run ruff check .` and `uv run ruff format --check .` as the stable interface rather than relying on individual rule codes. - **Pyright.** Type checking runs through `uv run pyright`; the project is tightening this as a strict-inference ratchet over time. -- **Python tests.** The suite is offline and runs in parallel by default via [pytest-xdist](https://pypi.org/project/pytest-xdist/) (`-n auto` in `pyproject.toml`'s addopts, which also enable `--cov` so coverage is reported inline); Disable parallelism for a single serial run with `pytest -n 0`. CI installs the `ci` dependency group with the `cli`, `qc`, and `log` extras (`--no-default-groups --group ci --extra cli --extra qc --extra log`) and runs the suite as a single job rather than sharding it across a matrix of runners: most of a run is fixed overhead (interpreter start, imports, xdist worker spin-up, coverage init) rather than test execution, so splitting the suite would cost more in per-runner setup than it recovers. +- **Python tests.** The suite is offline and runs in parallel by default via [pytest-xdist](https://pypi.org/project/pytest-xdist/) (`-n auto` in `pyproject.toml`'s addopts, which also enable `--cov` so coverage is reported inline); Disable parallelism for a single serial run with `pytest -n 0`. CI installs the `ci` dependency group with the `cli`, `qc`, `log`, and `server` extras (`--no-default-groups --group ci --extra cli --extra qc --extra log --extra server`) and runs the suite as a single job rather than sharding it across a matrix of runners: most of a run is fixed overhead (interpreter start, imports, xdist worker spin-up, coverage init) rather than test execution, so splitting the suite would cost more in per-runner setup than it recovers. - **Rust tests.** `cargo test --manifest-path rust/Cargo.toml` runs the extension's Rust unit tests. - **Rust style and lints.** `cargo fmt --check` enforces formatting; clippy runs all targets with warnings denied. - **Dead code.** `uv run vulture` finds unused Python functions, methods, classes, and attributes that ruff and pyright cannot see; its scope and suppressions live in `[tool.vulture]` and `scripts/vulture_whitelist.py` (names used dynamically, like config-vocabulary enum members and pydantic fields). `uv run deptry .` finds unused declared dependencies and imports that only work through a transitive dependency; its ignores live in `[tool.deptry]`. On the Rust side, clippy already denies `dead_code`, and cargo-machete (CI `rust` job and pre-push hook, no local install required) rejects unused crate dependencies. diff --git a/Makefile b/Makefile index 28b6fbaf..71124abe 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ # Install Python dev dependencies, CLI/QC/log extras, and the editable Rust extension. setup: - uv sync --group dev --extra cli --extra qc --extra log + uv sync --group dev --extra cli --extra qc --extra log --extra server uv run maturin develop --manifest-path rust/Cargo.toml # Build and install the Rust extension in release mode for local performance checks. diff --git a/README.md b/README.md index da8bb8bd..1a489f09 100644 --- a/README.md +++ b/README.md @@ -154,6 +154,7 @@ Python API to your project. Other extras are opt-in: | `aria2` | bundled aria2c downloader, used automatically by `build-fullmap` when installed (Linux/Windows wheels only) | `pip install "tablassert[aria2]"` | | `qc` | four-stage QC audit (exact match, fuzzy match, abbreviation expansion, and SapBERT embeddings) | `pip install "tablassert[qc]"` | | `log` | loguru-backed file/progress logging (rotation, enqueue) | `pip install "tablassert[log]"` | +| `server` | localhost web UI for YAML-free config authoring and builds (`tablassert serve`) | `pip install "tablassert[server]"` | Reaching a feature whose extra is missing never produces a bare `ModuleNotFoundError`: the failure names the missing package and the install command that fixes it. QC is opt-in at build time @@ -191,7 +192,7 @@ no LazyFrame setup or NLP preprocessing required. See the ## Developing ```bash -uv sync --group dev --extra cli --extra qc --extra log +uv sync --group dev --extra cli --extra qc --extra log --extra server uv run maturin develop --manifest-path rust/Cargo.toml make check ``` diff --git a/docs/cli.md b/docs/cli.md index f92989b8..28fc4fdf 100644 --- a/docs/cli.md +++ b/docs/cli.md @@ -2,7 +2,7 @@ Tablassert extracts knowledge assertions from tabular data into KGX NDJSON. The `tablassert` app requires the `[cli]` extra (`pip install "tablassert[cli]"` or `uv tool install "tablassert[cli]"`) and -exposes **five subcommands**: `build-fullmap`, `build-kg`, `quick-map`, `validate`, +exposes **six subcommands**: `build-fullmap`, `build-kg`, `quick-map`, `serve`, `validate`, and `validate-kgx`, plus an app-level `--version` flag. Run `tablassert --help` (or ` --help`) for the live surface. @@ -13,6 +13,7 @@ for the live surface. | [`build-fullmap`](#build-fullmap) | Build the embedded fullmap redb used for entity resolution | | [`build-kg`](#build-kg) | Build a KGX NDJSON knowledge graph from a YAML configuration | | [`quick-map`](#quick-map) | Show what fullmap entity resolution does with one or more terms | +| [`serve`](#serve) | Start the localhost-only Web UI for YAML-free config authoring and builds | | [`validate`](#validate) | Validate a graph or table configuration without executing it | | [`validate-kgx`](#validate-kgx) | Validate built KGX NDJSON against the Biolink Model and the Translator registry | @@ -357,6 +358,24 @@ once a model release drops the requirement. --- +## serve + +Start a localhost-only Web UI (`[server]` extra) to author `tables/table.yaml` and `graph.yaml` +without writing YAML by hand, run inline `validate`, and stream `build-kg`. + +```bash +tablassert serve +tablassert serve --port 9000 --output-dir ./my-project +``` + +| Option | Type | Required | Default | Description | +| --- | --- | --- | --- | --- | +| `--host` | String | No | `127.0.0.1` | Loopback interface to bind (`127.0.0.1`, `localhost`, or `::1`) | +| `--port`, `-p` | Integer | No | `8765` | TCP port to listen on | +| `--output-dir`, `-o` | Path | No | `.` | Directory where generated `graph.yaml` and `tables/table.yaml` are written | + +--- + ## Typical workflow 1. Author a table config, then a graph config that references it. diff --git a/docs/index.md b/docs/index.md index ae64a6d9..7c457096 100644 --- a/docs/index.md +++ b/docs/index.md @@ -32,7 +32,7 @@ expectations. ### How-to guides -- **[CLI Reference](cli.md)**: every command and flag: `build-kg`, `build-fullmap`, `validate`, +- **[CLI Reference](cli.md)**: every command and flag: `build-kg`, `build-fullmap`, `serve`, `validate`, `validate-kgx`, `quick-map` - **[Fullmap](fullmap.md)**: obtain and build the entity-resolution database diff --git a/docs/installation.md b/docs/installation.md index e7f83b35..a84a035c 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -38,6 +38,7 @@ uv tool install "tablassert[cli]" # or: pip install "tablassert[cli]" | `aria2` | Bundled aria2c downloader, used automatically by `build-fullmap` when installed (Linux/Windows wheels only) | `aria2==0.0.1b0` (imports as `aria2c`, bundles aria2c) | | `qc` | QC runtime (exact match, fuzzy match, abbreviation expansion, then a SapBERT embedding audit) | `scikit-learn`, `sentence-transformers` (`torch` + `numpy` arrive transitively; `rapidfuzz` is a core dependency) | | `log` | loguru-backed file/progress logging (rotation, enqueue) | `loguru` | +| `server` | Localhost web UI for YAML-free config authoring and builds (`tablassert serve`) | `fastapi`, `uvicorn` | Install any extra the same way: `uv tool install "tablassert[]"` or `pip install "tablassert[]"`, and combine them as `"tablassert[cli,qc]"`. Wheels ship for @@ -72,6 +73,7 @@ fails, not a failure report): | `tablassert` | `[cli]` | Before importing the command application, so a base Python-API install reports the exact install command instead of a bare module error | | `build-kg --qc` | `[qc]` | Before the build starts: the QC audit runs at the very end of the build, so a late failure would cost the entire entity-resolution pass | | `build-fullmap` | `[aria2]` | Before the first download, to pick the downloader: bundled aria2c when the extra is installed, Python downloader otherwise (announced on stderr and logged either way; never a missing-extra failure) | +| `serve` | `[server]` | Before starting the localhost web server | A partially installed extra names every package it is still missing, so installing them is one step rather than a retry loop. Library calls that reach an optional import directly (for example @@ -101,7 +103,7 @@ Editable install plus the development tools; needs `uv` and a Rust toolchain. ```bash git clone https://github.com/SkyeAv/Tablassert.git cd Tablassert -uv sync --group dev --extra cli --extra qc --extra log +uv sync --group dev --extra cli --extra qc --extra log --extra server uv run maturin develop --manifest-path rust/Cargo.toml uv run tablassert --help ``` diff --git a/llms.txt b/llms.txt index 3091f560..79835988 100644 --- a/llms.txt +++ b/llms.txt @@ -9,8 +9,8 @@ Current CLI behavior queries an embedded redb database whose primary file is `fu ## Quickstart - [README](README.md): high-level overview, install snippets, and one-command graph build. - [Documentation Site Home](docs/index.md): docs landing page and navigation context. -- [Installation Guide](docs/installation.md): three install paths (PyPI, GitHub main, development from source), platform and Rust-toolchain notes, and the missing-extra behavior. Optional extras: `cli`, `rt`, `aria2`, `qc`, and `log`. -- [CLI Reference](docs/cli.md): the five commands (`build-fullmap`, `build-kg`, `quick-map`, `validate`, and `validate-kgx`) plus the app-level `--version` flag. +- [Installation Guide](docs/installation.md): three install paths (PyPI, GitHub main, development from source), platform and Rust-toolchain notes, and the missing-extra behavior. Optional extras: `cli`, `rt`, `aria2`, `qc`, `log`, and `server`. +- [CLI Reference](docs/cli.md): the six commands (`build-fullmap`, `build-kg`, `quick-map`, `serve`, `validate`, and `validate-kgx`) plus the app-level `--version` flag. - [Tutorial](docs/tutorial.md): first end-to-end run from CSV input to KGX NDJSON output. ## YAML Authoring @@ -35,7 +35,7 @@ Current CLI behavior queries an embedded redb database whose primary file is `fu ## Contributor Development - [Contributing Guide](CONTRIBUTING.md): setup, style conventions, checks, and PR expectations. - [Development](docs/development.md): docs-site contributor setup and the local `uv run mkdocs build --strict` docs gate. -- [Project Metadata](pyproject.toml): dependencies, tooling config, and CLI entrypoint. Optional extras: `cli`, `rt`, `aria2`, `qc`, and `log`. +- [Project Metadata](pyproject.toml): dependencies, tooling config, and CLI entrypoint. Optional extras: `cli`, `rt`, `aria2`, `qc`, `log`, and `server`. - [Tests](tests/): pytest coverage and fixtures. - [MkDocs Configuration](mkdocs.yml): docs navigation and published pages. - [GitHub Workflows](.github/workflows/): `ci.yml` runs lint, format, type, dead-code (vulture, deptry), test, rust (clippy, machete), and mkdocs checks when a release changes the project version or on manual dispatch; `docs.yml` builds and deploys MkDocs; `pipy.yml` checks the project version, builds sdist and wheel artifacts, and publishes to PyPI; `tag-version.yml` tags changed project versions; `paper.yml` tests the JOSS paper compile and uploads the PDF artifact; `security.yml` scans commits for leaked secrets with gitleaks and audits dependencies against advisory databases with pip-audit and cargo-audit for the Rust lockfile. @@ -59,6 +59,7 @@ Current CLI behavior queries an embedded redb database whose primary file is `fu - [Quality Control](src/tablassert/qc.py): exact, fuzzy, abbreviation, and SapBERT validation stages. - [RIG Helpers](src/tablassert/rig.py): Resource Ingest Guide normalization and serialization helpers. - [Run Cache](src/tablassert/runcache.py): content-addressed op digests, worth-caching guards, the shared-prefix planner, and the ephemeral run cache. +- [Localhost Web UI Server](src/tablassert/server.py): FastAPI/Uvicorn localhost-only web UI (`tablassert serve`) for YAML-free config authoring, validation, and build streaming. - [Graph Study](src/tablassert/study.py): assertions over final KGX NDJSON. - [Utilities](src/tablassert/utils.py): hashing, storage path constants, and filesystem helpers. - [Package Init](src/tablassert/__init__.py): public package import surface and compiled-extension bootstrap. diff --git a/pyproject.toml b/pyproject.toml index 7a4e2e90..ad4dfe02 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -98,6 +98,10 @@ qc = [ log = [ "loguru>=0.7.3", ] +server = [ + "fastapi>=0.115.0", + "uvicorn>=0.34.0", +] [dependency-groups] test = [ diff --git a/scripts/vulture_whitelist.py b/scripts/vulture_whitelist.py index 2d7b3485..fc1dc6d8 100644 --- a/scripts/vulture_whitelist.py +++ b/scripts/vulture_whitelist.py @@ -20,6 +20,7 @@ from typing import Any +from tablassert.cli import serve from tablassert.enums import ContentCategories, DataFormats, FillMethods, IngestCategories, ModelingCategories, ProvisionMechanisms, SourceStatuses from tablassert.models import ( RIGFilteredContent, @@ -105,3 +106,6 @@ RIGFutureModelingConsideration.consideration RIGSupportingDataSourceInfo.terms_of_use_info RIGProvenanceInfo.artifacts + +# cli.py: Cyclopts subcommand registered by @APP.command decorator. +serve diff --git a/src/tablassert/cli.py b/src/tablassert/cli.py index 2fc798b2..c2339f08 100644 --- a/src/tablassert/cli.py +++ b/src/tablassert/cli.py @@ -987,6 +987,32 @@ def validate( run(3, validate_pipeline, configuration_file) +@APP.command(name="serve") +def serve( + host: Annotated[str, cyclopts.Parameter(name=["--host"])] = "127.0.0.1", + port: Annotated[int, cyclopts.Parameter(name=["--port", "-p"])] = 8765, + output_dir: Annotated[Path, cyclopts.Parameter(name=["--output-dir", "-o"])] = Path("."), +) -> None: + """Start the localhost-only Web UI for YAML-free config authoring and builds. + + Requires the ``[server]`` extra (``fastapi`` and ``uvicorn``). Binds to localhost + only (``127.0.0.1``, ``localhost``, or ``::1``) with no remote exposure. + + Args: + host: Loopback interface to bind (default: ``127.0.0.1``). + port: TCP port to listen on (default: ``8765``). + output_dir: Directory where generated ``graph.yaml`` and ``tables/table.yaml`` are written. + """ + extras.require("server", required_by="tablassert serve") + if host not in {"127.0.0.1", "localhost", "::1"}: + print(f"tablassert serve: refusing non-localhost host {host!r}; bind to 127.0.0.1, localhost, or ::1.", file=sys.stderr) + raise SystemExit(1) + + from tablassert.server import run_server + + run_server(host=host, port=port, output_dir=output_dir) + + def _print_kgx_section(label: str, section: dict[str, Any], path: Path) -> None: """Print one ``validate-kgx`` per-file section (shared by the plain and ``--prune`` paths).""" if section["missing"]: diff --git a/src/tablassert/extras.py b/src/tablassert/extras.py index 07261825..88bad36a 100644 --- a/src/tablassert/extras.py +++ b/src/tablassert/extras.py @@ -34,6 +34,7 @@ "aria2": {"aria2c": "aria2"}, "qc": {"sklearn": "scikit-learn", "sentence_transformers": "sentence-transformers"}, "log": {"loguru": "loguru"}, + "server": {"fastapi": "fastapi", "uvicorn": "uvicorn"}, } # Import name -> owning extra, derived so the two can never drift apart. @@ -46,6 +47,7 @@ "aria2": "the bundled aria2c downloader (used automatically by build-fullmap when installed)", "qc": "the QC audit", "log": "file and progress logging", + "server": "the localhost web UI (`tablassert serve`)", } diff --git a/src/tablassert/server.py b/src/tablassert/server.py new file mode 100644 index 00000000..eb131d11 --- /dev/null +++ b/src/tablassert/server.py @@ -0,0 +1,357 @@ +"""Localhost-only Web UI for YAML-free Tablassert config authoring and builds.""" + +from __future__ import annotations + +import json +import queue +import threading +from io import StringIO +from pathlib import Path +from typing import Any + +import yaml +from pydantic import ValidationError + +from tablassert import extras, ingests +from tablassert.enums import IngestCategories, SourceStatuses +from tablassert.errors import flatten_pydantic_error +from tablassert.models import Graph, Section + +_INDEX_HTML: str = """ + + + + + Tablassert Local Builder + + + +
+
+

Tablassert Local Builder

+

Localhost-only wizard to generate schema-valid YAML, run validate, and stream build-kg.

+
+ +
+

1. Source

+
+ + + + + + +
+
+ +
+

2. Column Mapping & Provenance

+
+ + + + + + + +
+
+ +
+

3. Graph & RIG Metadata

+
+ + + + + + + + + + +
+
+ +
+
+ + +
+

+
+

tables/table.yaml

+

graph.yaml

+
+

Build Output

+

+    
+
+ + + +""" + + +def _split_csv(raw: Any) -> list[str]: + if isinstance(raw, list): + return [str(x).strip() for x in raw if str(x).strip()] + return [part.strip() for part in str(raw or "").split(",") if part.strip()] + + +def _dump_yaml_str(data: object) -> str: + buf = StringIO() + yaml.safe_dump(data, buf, sort_keys=False, default_flow_style=False, allow_unicode=True, width=120) + return buf.getvalue() + + +def build_configs_from_payload(payload: dict[str, Any], *, table_rel_path: str = "tables/table.yaml") -> tuple[dict[str, Any], dict[str, Any]]: + """Build plain ``table.yaml`` and ``graph.yaml`` dicts from a Web UI JSON payload.""" + src_in: dict[str, Any] = dict(payload.get("source") or {}) + stmt_in: dict[str, Any] = dict(payload.get("statement") or {}) + prov_in: dict[str, Any] = dict(payload.get("provenance") or {}) + graph_in: dict[str, Any] = dict(payload.get("graph") or {}) + + kind: str = str(src_in.get("kind", "text")) + urls: list[str] = [str(u) for u in (src_in.get("url") or []) if str(u).strip()] + source_block: dict[str, Any] = {"kind": kind, "local": str(src_in.get("local", "")), "url": urls} + if kind == "text": + source_block["delimiter"] = str(src_in.get("delimiter", ",")) + elif kind == "excel": + source_block["sheet"] = str(src_in.get("sheet", "Sheet1")) + if src_in.get("row_slice_start") is not None and kind in {"text", "excel"}: + source_block["row_slice"] = [int(src_in["row_slice_start"]), "auto"] + + subj: dict[str, Any] = {"method": "column", "encoding": str(stmt_in.get("subject_column", "A"))} + subj_prio: list[str] = _split_csv(stmt_in.get("subject_prioritize")) + if subj_prio: + subj["prioritize"] = subj_prio + + obj: dict[str, Any] = {"method": "column", "encoding": str(stmt_in.get("object_column", "B"))} + obj_prio: list[str] = _split_csv(stmt_in.get("object_prioritize")) + if obj_prio: + obj["prioritize"] = obj_prio + + table_cfg: dict[str, Any] = { + "template": { + "source": source_block, + "statement": {"subject": subj, "predicate": str(stmt_in.get("predicate", "associated_with")), "object": obj}, + "provenance": {"repo": str(prov_in.get("repo", "PMID")), "publication": str(prov_in.get("publication", ""))}, + }, + "sections": [{}], + } + + graph_name: str = str(graph_in.get("name", "my-kg")) + graph_cfg: dict[str, Any] = { + "name": graph_name, + "version": str(graph_in.get("version", "0.1.0")), + "tables": [table_rel_path], + "fullmap": str(graph_in.get("fullmap", ".fullmap")), + "rig": { + "source_info": { + "infores_id": str(graph_in.get("infores_id", "infores:tablassert-draft")), + "name": graph_name, + "description": str(graph_in.get("description", "Knowledge graph built with Tablassert")), + "terms_of_use_info": {"license_name": str(graph_in.get("license_name", "CC0 1.0 Universal"))}, + "data_access_locations": [str(graph_in.get("data_access_url", "https://example.org/data"))], + "source_status": SourceStatuses.UNKNOWN.value, + }, + "ingest_info": { + "ingest_categories": [IngestCategories.TRANSLATOR_KNOWLEDGE_CREATOR.value], + "utility": str(graph_in.get("description", "Knowledge graph built with Tablassert")), + "scope": "Generated via tablassert serve UI", + }, + "provenance_info": {"contributions": [str(graph_in.get("contribution", "Curator - modeling"))]}, + "artifact_base_url": str(graph_in.get("artifact_base_url", "https://example.org/kg")), + "artifact_base_path": str(graph_in.get("artifact_base_path", "./output")), + }, + } + return table_cfg, graph_cfg + + +def validate_payload(payload: dict[str, Any]) -> dict[str, Any]: + """Generate YAML strings and validate them against ``Section`` and ``Graph``.""" + table_cfg, graph_cfg = build_configs_from_payload(payload) + errors: list[str] = [] + try: + Section.model_validate(table_cfg["template"]) + except ValidationError as exc: + errors.append(flatten_pydantic_error(exc)) + try: + Graph.model_validate(graph_cfg) + except ValidationError as exc: + errors.append(flatten_pydantic_error(exc)) + + return {"valid": not errors, "errors": errors, "table_yaml": _dump_yaml_str(table_cfg), "graph_yaml": _dump_yaml_str(graph_cfg)} + + +def write_configs(output_dir: Path, table_cfg: dict[str, Any], graph_cfg: dict[str, Any]) -> tuple[Path, Path]: + """Write validated plain YAML configs under ``output_dir``.""" + tables_dir: Path = output_dir / "tables" + tables_dir.mkdir(parents=True, exist_ok=True) + table_path: Path = tables_dir / "table.yaml" + graph_path: Path = output_dir / "graph.yaml" + ingests.to_yaml(table_path, table_cfg) + ingests.to_yaml(graph_path, graph_cfg) + return table_path, graph_path + + +def create_app(output_dir: Path = Path(".")) -> Any: + """Create the FastAPI application for the localhost Web UI.""" + extras.require("server", required_by="tablassert serve") + from fastapi import FastAPI # pyright: ignore[reportMissingImports] + from fastapi.responses import HTMLResponse, StreamingResponse # pyright: ignore[reportMissingImports] + + app = FastAPI(title="Tablassert Local Builder", docs_url=None, redoc_url=None) + + def index() -> str: + return _INDEX_HTML + + def api_validate(payload: dict[str, Any]) -> dict[str, Any]: + return validate_payload(payload) + + def api_build(payload: dict[str, Any]) -> Any: + result: dict[str, Any] = validate_payload(payload) + if not result["valid"]: + + def _err_stream() -> Any: + yield json.dumps({"event": "error", "errors": result["errors"]}) + "\n" + + return StreamingResponse(_err_stream(), media_type="application/x-ndjson", status_code=400) + + table_cfg, graph_cfg = build_configs_from_payload(payload) + _, graph_path = write_configs(output_dir, table_cfg, graph_cfg) + + from tablassert.cli import PipelineProgress, build_pipeline + + q: queue.Queue[str | None] = queue.Queue() + + def _worker() -> None: + try: + q.put(json.dumps({"event": "started", "graph": str(graph_path)}) + "\n") + build_pipeline(graph_path, PipelineProgress(total_stages=6)) + q.put(json.dumps({"event": "done", "graph": str(graph_path)}) + "\n") + except Exception as exc: + q.put(json.dumps({"event": "error", "detail": str(exc)}) + "\n") + finally: + q.put(None) + + threading.Thread(target=_worker, daemon=True).start() + + def _stream() -> Any: + while True: + item: str | None = q.get() + if item is None: + break + yield item + + return StreamingResponse(_stream(), media_type="application/x-ndjson") + + app.add_api_route("/", index, methods=["GET"], response_class=HTMLResponse) + app.add_api_route("/api/validate", api_validate, methods=["POST"]) + app.add_api_route("/api/build", api_build, methods=["POST"]) + return app + + +def run_server(*, host: str = "127.0.0.1", port: int = 8765, output_dir: Path = Path(".")) -> None: + """Start the localhost-only Uvicorn server for ``tablassert serve``.""" + extras.require("server", required_by="tablassert serve") + import uvicorn # pyright: ignore[reportMissingImports] + + app = create_app(output_dir=output_dir) + uvicorn.run(app, host=host, port=port, log_level="info") diff --git a/tests/test_docs_cli_coverage.py b/tests/test_docs_cli_coverage.py index 6c802d6a..58e46128 100644 --- a/tests/test_docs_cli_coverage.py +++ b/tests/test_docs_cli_coverage.py @@ -24,6 +24,7 @@ "build-fullmap": ("cli.md", "fullmap.md"), "build-kg": ("cli.md",), "quick-map": ("cli.md", "fullmap.md"), + "serve": ("cli.md",), "validate": ("cli.md",), "validate-kgx": ("cli.md",), } @@ -31,6 +32,7 @@ "build-fullmap": ("cli.md", "fullmap.md"), "build-kg": ("cli.md",), "quick-map": ("cli.md", "fullmap.md"), + "serve": ("cli.md",), "validate": ("cli.md",), "validate-kgx": ("cli.md",), } diff --git a/tests/test_extras.py b/tests/test_extras.py index 074c73be..e59c27a3 100644 --- a/tests/test_extras.py +++ b/tests/test_extras.py @@ -40,7 +40,7 @@ def test_registry_covers_every_declared_extra() -> None: assert set(extras.EXTRA_PACKAGES) == declared - {"rt"} -@pytest.mark.parametrize("extra", ["cli", "qc", "aria2", "log"]) +@pytest.mark.parametrize("extra", ["cli", "qc", "aria2", "log", "server"]) def test_registered_packages_are_actually_shipped_by_their_extra(extra: str) -> None: """Each import name maps to a distribution that its extra really installs. @@ -65,6 +65,8 @@ def test_module_lookup_is_derived_and_unambiguous() -> None: assert extras.EXTRA_FOR_MODULE["sklearn"] == "qc" assert extras.EXTRA_FOR_MODULE["sentence_transformers"] == "qc" assert extras.EXTRA_FOR_MODULE["loguru"] == "log" + assert extras.EXTRA_FOR_MODULE["fastapi"] == "server" + assert extras.EXTRA_FOR_MODULE["uvicorn"] == "server" assert len(extras.EXTRA_FOR_MODULE) == sum(len(packages) for packages in extras.EXTRA_PACKAGES.values()) diff --git a/tests/test_server.py b/tests/test_server.py new file mode 100644 index 00000000..7467bea0 --- /dev/null +++ b/tests/test_server.py @@ -0,0 +1,101 @@ +from __future__ import annotations + +import json +from pathlib import Path +from typing import Any + +import pytest + +from tablassert import extras, server +from tablassert.cli import APP +from tablassert.errors import MissingExtraError + + +def _sample_payload(data_path: Path) -> dict[str, Any]: + return { + "source": {"kind": "text", "local": str(data_path), "url": ["https://example.org/data.tsv"], "delimiter": "\t", "row_slice_start": 1}, + "statement": { + "subject_column": "A", + "subject_prioritize": "Gene", + "predicate": "associated_with", + "object_column": "B", + "object_prioritize": "Disease", + }, + "provenance": {"repo": "PMID", "publication": "12345678"}, + "graph": { + "name": "ui-kg", + "version": "0.1.0", + "fullmap": ".fullmap", + "infores_id": "infores:tablassert-draft", + "description": "UI generated KG", + "license_name": "CC0 1.0 Universal", + "data_access_url": "https://example.org/data.tsv", + "contribution": "Curator - modeling", + "artifact_base_url": "https://example.org/kg", + "artifact_base_path": "./output", + }, + } + + +def test_serve_requires_server_extra(monkeypatch: pytest.MonkeyPatch) -> None: + monkeypatch.setattr(extras, "find_spec", lambda name: None) + with pytest.raises(MissingExtraError, match="fastapi"): + APP(["serve"], exit_on_error=False, result_action="return_value") + + +def test_serve_refuses_non_localhost_bind(monkeypatch: pytest.MonkeyPatch) -> None: + monkeypatch.setattr(extras, "require", lambda *a, **_kw: None) + with pytest.raises(SystemExit) as exc: + APP(["serve", "--host", "0.0.0.0"], exit_on_error=False, result_action="return_value") + assert exc.value.code == 1 + + +def test_server_payload_validates_and_round_trips_cli_validate(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None: + data_path: Path = tmp_path / "data.tsv" + data_path.write_text("a\tb\nBRCA1\tTP53\n", encoding="utf-8") + + result: dict[str, Any] = server.validate_payload(_sample_payload(data_path)) + assert result["valid"] is True + assert result["errors"] == [] + + table_cfg, graph_cfg = server.build_configs_from_payload(_sample_payload(data_path)) + _, graph_path = server.write_configs(tmp_path, table_cfg, graph_cfg) + monkeypatch.chdir(tmp_path) + APP(["validate", str(graph_path), "--schema", "graph"], exit_on_error=False, result_action="return_value") + + +def test_server_payload_reports_validation_errors(tmp_path: Path) -> None: + payload: dict[str, Any] = _sample_payload(tmp_path / "data.tsv") + payload["graph"]["infores_id"] = "not-an-infores" + result: dict[str, Any] = server.validate_payload(payload) + assert result["valid"] is False + assert any("infores" in err.lower() for err in result["errors"]) + + +def test_server_routes_when_fastapi_installed(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None: + pytest.importorskip("fastapi") + pytest.importorskip("httpx") + from fastapi.testclient import TestClient # pyright: ignore[reportMissingImports] + + from tablassert import cli + + called: list[Path] = [] + monkeypatch.setattr(cli, "build_pipeline", lambda graph_path, _progress: called.append(graph_path)) + + app = server.create_app(output_dir=tmp_path) + client = TestClient(app) + + home = client.get("/") + assert home.status_code == 200 + assert "Tablassert Local Builder" in home.text + + payload = _sample_payload(tmp_path / "data.tsv") + val_resp = client.post("/api/validate", json=payload) + assert val_resp.status_code == 200 + assert val_resp.json()["valid"] is True + + build_resp = client.post("/api/build", json=payload) + assert build_resp.status_code == 200 + events = [json.loads(line) for line in build_resp.text.splitlines() if line.strip()] + assert events[-1]["event"] == "done" + assert called == [tmp_path / "graph.yaml"] diff --git a/uv.lock b/uv.lock index 9cb3ad61..be443be8 100644 --- a/uv.lock +++ b/uv.lock @@ -1,5 +1,5 @@ version = 1 -revision = 5 +revision = 3 requires-python = ">=3.11" resolution-markers = [ "python_full_version >= '3.14' and platform_machine != 's390x' and sys_platform == 'win32'", @@ -409,7 +409,7 @@ name = "cuda-bindings" version = "13.2.0" source = { registry = "https://pypi.org/simple" } dependencies = [ - { name = "cuda-pathfinder" }, + { name = "cuda-pathfinder", marker = "sys_platform != 'emscripten' and sys_platform != 'win32'" }, ] wheels = [ { url = "https://files.pythonhosted.org/packages/e0/a9/3a8241c6e19483ac1f1dcf5c10238205dcb8a6e9d0d4d4709240dff28ff4/cuda_bindings-13.2.0-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:721104c603f059780d287969be3d194a18d0cc3b713ed9049065a1107706759d", size = 5730273, upload-time = "2026-03-11T00:12:37.18Z" }, @@ -442,40 +442,40 @@ wheels = [ [package.optional-dependencies] cublas = [ - { name = "nvidia-cublas", version = "13.4.1.3", source = { registry = "https://pypi.org/simple" }, marker = "platform_machine == 'aarch64' or platform_machine == 'x86_64'" }, - { name = "nvidia-cuda-nvrtc", marker = "platform_machine == 'aarch64' or platform_machine == 'x86_64'" }, + { name = "nvidia-cublas", version = "13.4.1.3", source = { registry = "https://pypi.org/simple" }, marker = "(platform_machine == 'aarch64' and sys_platform == 'linux') or (platform_machine == 'x86_64' and sys_platform == 'linux')" }, + { name = "nvidia-cuda-nvrtc", marker = "(platform_machine == 'aarch64' and sys_platform == 'linux') or (platform_machine == 'x86_64' and sys_platform == 'linux')" }, ] cudart = [ - { name = "nvidia-cuda-runtime", marker = "platform_machine == 'aarch64' or platform_machine == 'x86_64'" }, + { name = "nvidia-cuda-runtime", marker = "(platform_machine == 'aarch64' and sys_platform == 'linux') or (platform_machine == 'x86_64' and sys_platform == 'linux')" }, ] cufft = [ - { name = "nvidia-cufft", marker = "platform_machine == 'aarch64' or platform_machine == 'x86_64'" }, - { name = "nvidia-nvjitlink", marker = "platform_machine == 'aarch64' or platform_machine == 'x86_64'" }, + { name = "nvidia-cufft", marker = "(platform_machine == 'aarch64' and sys_platform == 'linux') or (platform_machine == 'x86_64' and sys_platform == 'linux')" }, + { name = "nvidia-nvjitlink", marker = "(platform_machine == 'aarch64' and sys_platform == 'linux') or (platform_machine == 'x86_64' and sys_platform == 'linux')" }, ] cufile = [ - { name = "nvidia-cufile", marker = "platform_machine == 'aarch64' or platform_machine == 'x86_64'" }, + { name = "nvidia-cufile", marker = "(platform_machine == 'aarch64' and sys_platform == 'linux') or (platform_machine == 'x86_64' and sys_platform == 'linux')" }, ] cupti = [ - { name = "nvidia-cuda-cupti", marker = "platform_machine == 'aarch64' or platform_machine == 'x86_64'" }, + { name = "nvidia-cuda-cupti", marker = "(platform_machine == 'aarch64' and sys_platform == 'linux') or (platform_machine == 'x86_64' and sys_platform == 'linux')" }, ] cusolver = [ - { name = "nvidia-cublas", version = "13.4.1.3", source = { registry = "https://pypi.org/simple" }, marker = "platform_machine == 'aarch64' or platform_machine == 'x86_64'" }, - { name = "nvidia-cusolver", marker = "platform_machine == 'aarch64' or platform_machine == 'x86_64'" }, - { name = "nvidia-cusparse", marker = "platform_machine == 'aarch64' or platform_machine == 'x86_64'" }, - { name = "nvidia-nvjitlink", marker = "platform_machine == 'aarch64' or platform_machine == 'x86_64'" }, + { name = "nvidia-cublas", version = "13.4.1.3", source = { registry = "https://pypi.org/simple" }, marker = "(platform_machine == 'aarch64' and sys_platform == 'linux') or (platform_machine == 'x86_64' and sys_platform == 'linux')" }, + { name = "nvidia-cusolver", marker = "(platform_machine == 'aarch64' and sys_platform == 'linux') or (platform_machine == 'x86_64' and sys_platform == 'linux')" }, + { name = "nvidia-cusparse", marker = "(platform_machine == 'aarch64' and sys_platform == 'linux') or (platform_machine == 'x86_64' and sys_platform == 'linux')" }, + { name = "nvidia-nvjitlink", marker = "(platform_machine == 'aarch64' and sys_platform == 'linux') or (platform_machine == 'x86_64' and sys_platform == 'linux')" }, ] cusparse = [ - { name = "nvidia-cusparse", marker = "platform_machine == 'aarch64' or platform_machine == 'x86_64'" }, - { name = "nvidia-nvjitlink", marker = "platform_machine == 'aarch64' or platform_machine == 'x86_64'" }, + { name = "nvidia-cusparse", marker = "(platform_machine == 'aarch64' and sys_platform == 'linux') or (platform_machine == 'x86_64' and sys_platform == 'linux')" }, + { name = "nvidia-nvjitlink", marker = "(platform_machine == 'aarch64' and sys_platform == 'linux') or (platform_machine == 'x86_64' and sys_platform == 'linux')" }, ] nvjitlink = [ - { name = "nvidia-nvjitlink", marker = "platform_machine == 'aarch64' or platform_machine == 'x86_64'" }, + { name = "nvidia-nvjitlink", marker = "(platform_machine == 'aarch64' and sys_platform == 'linux') or (platform_machine == 'x86_64' and sys_platform == 'linux')" }, ] nvrtc = [ - { name = "nvidia-cuda-nvrtc", marker = "platform_machine == 'aarch64' or platform_machine == 'x86_64'" }, + { name = "nvidia-cuda-nvrtc", marker = "(platform_machine == 'aarch64' and sys_platform == 'linux') or (platform_machine == 'x86_64' and sys_platform == 'linux')" }, ] nvtx = [ - { name = "nvidia-nvtx", marker = "platform_machine == 'aarch64' or platform_machine == 'x86_64'" }, + { name = "nvidia-nvtx", marker = "(platform_machine == 'aarch64' and sys_platform == 'linux') or (platform_machine == 'x86_64' and sys_platform == 'linux')" }, ] [[package]] @@ -585,6 +585,24 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/ab/84/02fc1827e8cdded4aa65baef11296a9bbe595c474f0d6d758af082d849fd/execnet-2.1.2-py3-none-any.whl", hash = "sha256:67fba928dd5a544b783f6056f449e5e3931a5c378b128bc18501f7ea79e296ec", size = 40708, upload-time = "2025-11-12T09:56:36.333Z" }, ] +[[package]] +name = "fastapi" +version = "0.165.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "annotated-doc" }, + { name = "anyio" }, + { name = "opentelemetry-api" }, + { name = "pydantic" }, + { name = "starlette" }, + { name = "typing-extensions" }, + { name = "typing-inspection" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/27/f9/e7820ef181026fea100bde02d811445bf8e883362d7092b6928767147056/fastapi-0.165.0.tar.gz", hash = "sha256:dd94d4128319c1e1d50535ab023ab698f850a4d2822f0e181747b46f4ff3c0ab", size = 557984, upload-time = "2026-11-18T19:15:37.076Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/c4/c1/3b74c030262a1b38b1fee180f80b4007bbc11c9ac12028cb18c7bcecaec9/fastapi-0.165.0-py3-none-any.whl", hash = "sha256:896f48462042bb4f162147eb8fac7e858753dc1f486765709baf105d70e4fc5b", size = 159475, upload-time = "2026-11-18T19:15:35.345Z" }, +] + [[package]] name = "fastexcel" version = "0.21.0" @@ -685,8 +703,8 @@ name = "httpcore2" version = "2.16.0" source = { registry = "https://pypi.org/simple" } dependencies = [ - { name = "h11" }, - { name = "truststore" }, + { name = "h11", marker = "sys_platform != 'emscripten'" }, + { name = "truststore", marker = "sys_platform != 'emscripten'" }, ] sdist = { url = "https://files.pythonhosted.org/packages/c0/61/afa9d6b7452f9eca73f73d45324eb0bb52f098fd5e6049bf6b8263be9b4e/httpcore2-2.16.0.tar.gz", hash = "sha256:c72cd0413563b17e1cd8354677dff887466f8ec2551679759e93126534428643", size = 69886, upload-time = "2026-10-21T07:09:45.31Z" } wheels = [ @@ -1216,7 +1234,7 @@ resolution-markers = [ "python_full_version < '3.12' and platform_machine != 's390x' and sys_platform != 'emscripten' and sys_platform != 'win32'", ] dependencies = [ - { name = "nvidia-cuda-nvrtc" }, + { name = "nvidia-cuda-nvrtc", marker = "platform_machine != 's390x' and sys_platform != 'emscripten' and sys_platform != 'win32'" }, ] wheels = [ { url = "https://files.pythonhosted.org/packages/d0/a0/5cd9d4b08a8320f7ca150ee0d66c97e98092922e338336cb4b62da7500c3/nvidia_cublas-13.4.1.3-py3-none-manylinux_2_27_aarch64.whl", hash = "sha256:4eb1472bf92b741e7cf24da7978dde251b58ddec2092d9f6a04f3623eb4e9a15", size = 513048232, upload-time = "2026-07-16T09:45:07.751Z" }, @@ -1264,8 +1282,8 @@ name = "nvidia-cudnn-cu13" version = "9.26.0.51" source = { registry = "https://pypi.org/simple" } dependencies = [ - { name = "nvidia-cublas", version = "13.1.0.3", source = { registry = "https://pypi.org/simple" }, marker = "platform_machine == 's390x'" }, - { name = "nvidia-cublas", version = "13.4.1.3", source = { registry = "https://pypi.org/simple" }, marker = "platform_machine != 's390x'" }, + { name = "nvidia-cublas", version = "13.1.0.3", source = { registry = "https://pypi.org/simple" }, marker = "platform_machine == 's390x' and sys_platform != 'emscripten' and sys_platform != 'win32'" }, + { name = "nvidia-cublas", version = "13.4.1.3", source = { registry = "https://pypi.org/simple" }, marker = "platform_machine != 's390x' and sys_platform != 'emscripten' and sys_platform != 'win32'" }, ] wheels = [ { url = "https://files.pythonhosted.org/packages/c5/1c/01e1dd3dec6ffe0baaff7e722b8946d867353d05a01301f128f1730fde0b/nvidia_cudnn_cu13-9.26.0.51-py3-none-manylinux_2_27_aarch64.whl", hash = "sha256:8e5b4f5eccff721416f70ecf4353172fc4d5cdd8ca869fe6f983a4a5b0147b20", size = 595329497, upload-time = "2026-09-10T16:45:39.945Z" }, @@ -1277,7 +1295,7 @@ name = "nvidia-cufft" version = "12.2.0.57" source = { registry = "https://pypi.org/simple" } dependencies = [ - { name = "nvidia-nvjitlink" }, + { name = "nvidia-nvjitlink", marker = "platform_machine != 's390x' and sys_platform != 'emscripten' and sys_platform != 'win32'" }, ] wheels = [ { url = "https://files.pythonhosted.org/packages/07/8d/f650e6d527f9d22b5ded906c000eaebb037721c06d4ecd906df62f300979/nvidia_cufft-12.2.0.57-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:1ed438568ae1088ba2c25789d10205d4104b8b140b7bd942e39a787947a0fb74", size = 218244742, upload-time = "2026-07-16T09:47:08.76Z" }, @@ -1298,9 +1316,9 @@ name = "nvidia-cusolver" version = "12.2.0.11" source = { registry = "https://pypi.org/simple" } dependencies = [ - { name = "nvidia-cublas", version = "13.4.1.3", source = { registry = "https://pypi.org/simple" } }, - { name = "nvidia-cusparse" }, - { name = "nvidia-nvjitlink" }, + { name = "nvidia-cublas", version = "13.4.1.3", source = { registry = "https://pypi.org/simple" }, marker = "platform_machine != 's390x' and sys_platform != 'emscripten' and sys_platform != 'win32'" }, + { name = "nvidia-cusparse", marker = "platform_machine != 's390x' and sys_platform != 'emscripten' and sys_platform != 'win32'" }, + { name = "nvidia-nvjitlink", marker = "platform_machine != 's390x' and sys_platform != 'emscripten' and sys_platform != 'win32'" }, ] wheels = [ { url = "https://files.pythonhosted.org/packages/60/df/9e6b603f1d64040ce3e076e9bce1b78e2d588d0aabc9783f351cecd861ab/nvidia_cusolver-12.2.0.11-py3-none-manylinux_2_27_aarch64.whl", hash = "sha256:8be097fca28de6be0990ab216ee9b804dd51077e1d1d83acf6c9850650bdc64d", size = 250383075, upload-time = "2026-07-16T09:50:16.355Z" }, @@ -1312,7 +1330,7 @@ name = "nvidia-cusparse" version = "12.7.10.12" source = { registry = "https://pypi.org/simple" } dependencies = [ - { name = "nvidia-nvjitlink" }, + { name = "nvidia-nvjitlink", marker = "platform_machine != 's390x' and sys_platform != 'emscripten' and sys_platform != 'win32'" }, ] wheels = [ { url = "https://files.pythonhosted.org/packages/60/35/abbd278fb6d039fcfb5175efa10a21007a11878bec59920d84854b47d766/nvidia_cusparse-12.7.10.12-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:597eff2cd83e3ab1d1e3a0dce9c9c879d77cf64ec2659bfdb5af6a5d02e7aaa9", size = 169043093, upload-time = "2026-07-16T09:51:37.058Z" }, @@ -1351,7 +1369,7 @@ name = "nvidia-nvshmem-cu13" version = "3.7.2" source = { registry = "https://pypi.org/simple" } dependencies = [ - { name = "nvidia-cuda-cccl" }, + { name = "nvidia-cuda-cccl", marker = "sys_platform != 'emscripten' and sys_platform != 'win32'" }, ] wheels = [ { url = "https://files.pythonhosted.org/packages/81/11/1767ef120299972822a43aceffbc81ac813aad2089d817e36e4e12aa4c9c/nvidia_nvshmem_cu13-3.7.2-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:0e748308b9e0a8a8d81859353f3e6c98fbe85a85f652a915a2ba60149a0bd124", size = 135174619, upload-time = "2026-07-17T19:24:15.404Z" }, @@ -1379,6 +1397,18 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/c0/da/977ded879c29cbd04de313843e76868e6e13408a94ed6b987245dc7c8506/openpyxl-3.1.5-py2.py3-none-any.whl", hash = "sha256:5282c12b107bffeef825f4617dc029afaf41d0ea60823bbb665ef3079dc79de2", size = 250910, upload-time = "2024-06-28T14:03:41.161Z" }, ] +[[package]] +name = "opentelemetry-api" +version = "1.45.2" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "typing-extensions" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/19/14/cf3a6b6448849656e1e5f4e2101f3988dc6789724050096aba1bc5ccf592/opentelemetry_api-1.45.2.tar.gz", hash = "sha256:d7b0008e21e5fd61cbe7a7f34ca3b6905a78ab677d9bc395e299359c75cda6b4", size = 73277, upload-time = "2026-10-29T17:29:37.888Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/a9/2d/610db864d7513158cebb8f36cc88e67e73bd6c7aa1905ef18d89e1281c81/opentelemetry_api-1.45.2-py3-none-any.whl", hash = "sha256:2cbd737377e710ee740d261c94e93fa0f08e6d037c18f17513cc0a2d94479a34", size = 60335, upload-time = "2026-10-29T17:29:06.955Z" }, +] + [[package]] name = "packaging" version = "26.3" @@ -2566,6 +2596,19 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/b7/ce/149a00dd41f10bc29e5921b496af8b574d8413afcd5e30dfa0ed46c2cc5e/six-1.17.0-py2.py3-none-any.whl", hash = "sha256:4721f391ed90541fddacab5acf947aa0d3dc7d27b2e1e8eda2be8970586c3274", size = 11050, upload-time = "2024-12-04T17:35:26.475Z" }, ] +[[package]] +name = "starlette" +version = "1.10.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "anyio" }, + { name = "typing-extensions", marker = "python_full_version < '3.13'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/48/bb/3d8757f21e9a53d9035c9eb039a777047139a16bfdbedfc7a58241c3d914/starlette-1.10.0.tar.gz", hash = "sha256:b8399098d4c1e3522734f7235dc79b1fc967f96cf139c81e0fa30479e0685f9b", size = 2734356, upload-time = "2026-10-24T15:04:12.342Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/88/2e/947cfe02def9371c07cd5bf5b6b61c829e9aecb9904db02a66cfafbc1eec/starlette-1.10.0-py3-none-any.whl", hash = "sha256:478c0ab3b4ced6e82719849c118fa406f0278a3499c1a898cd15cd31bdc38ce4", size = 80571, upload-time = "2026-10-24T15:04:10.371Z" }, +] + [[package]] name = "sympy" version = "1.14.0" @@ -2611,6 +2654,10 @@ qc = [ rt = [ { name = "polars", extra = ["rtcompat"] }, ] +server = [ + { name = "fastapi" }, + { name = "uvicorn" }, +] [package.dev-dependencies] ci = [ @@ -2657,6 +2704,7 @@ requires-dist = [ { name = "aria2", marker = "extra == 'aria2'", specifier = "==0.0.1b0" }, { name = "biolink-model", specifier = ">=4.4.6" }, { name = "cyclopts", marker = "extra == 'cli'", specifier = ">=1.0.0" }, + { name = "fastapi", marker = "extra == 'server'", specifier = ">=0.115.0" }, { name = "fastexcel", specifier = ">=0.21.0" }, { name = "linkml-runtime", specifier = ">=1.11" }, { name = "loguru", marker = "extra == 'log'", specifier = ">=0.7.3" }, @@ -2669,8 +2717,9 @@ requires-dist = [ { name = "rich", marker = "extra == 'cli'", specifier = ">=13.0.0" }, { name = "scikit-learn", marker = "extra == 'qc'", specifier = ">=1.8.0" }, { name = "sentence-transformers", marker = "extra == 'qc'", specifier = ">=5.3.0" }, + { name = "uvicorn", marker = "extra == 'server'", specifier = ">=0.34.0" }, ] -provides-extras = ["cli", "rt", "aria2", "qc", "log"] +provides-extras = ["cli", "rt", "aria2", "qc", "log", "server"] [package.metadata.requires-dev] ci = [ @@ -2959,6 +3008,19 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/92/9d/c4e665119135114480843e7ab388fa94d8480650450e6f8e26b70d323a4c/urllib3-2.8.0-py3-none-any.whl", hash = "sha256:0cf3cae568d36aa9576b28dfb35f11328f1cb974ca7647d9475ebb86c75ac6e3", size = 135717, upload-time = "2026-09-15T19:29:34.577Z" }, ] +[[package]] +name = "uvicorn" +version = "0.54.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "click" }, + { name = "h11" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/da/34/30e9280707135d2cfc589dfff3cb796bd07a3aeb1a3e415ba09dd89d7bb4/uvicorn-0.54.0.tar.gz", hash = "sha256:a2e33cbfaa0306f8e6b0c13e0cb89d7d7a2da3e62b90c66e18c33d9807b28620", size = 112283, upload-time = "2026-09-25T06:52:37.601Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/38/0c/b54a4fdd7f90a3af8b02ebc9ce6712c2c208b7926a2f7bad95c33ebbe943/uvicorn-0.54.0-py3-none-any.whl", hash = "sha256:505bdb0f318731d45f1f712071fc781a8981f6847a31c902c9f5e652d4f67faf", size = 87427, upload-time = "2026-09-25T06:52:35.829Z" }, +] + [[package]] name = "virtualenv" version = "21.15.8"