REST Server¶
app ¶
FastAPI app factory wrapping BaseLinker.link as a REST endpoint.
The deployer constructs whatever BaseLinker
and EntitySource instances they need
(model paths, device, checkpoints, API keys, ...) and registers them by name
via create_app; the returned app is run
the normal way, e.g. uvicorn mymodule:app.
create_app ¶
create_app(
linkers: dict[str, BaseLinker],
sources: dict[str, EntitySource] | None = None,
) -> FastAPI
Build a FastAPI app exposing the given linkers/sources over REST.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
linkers
|
dict[str, BaseLinker]
|
Maps a name (used in the |
required |
sources
|
dict[str, EntitySource] | None
|
Maps a name to a ready-to-use |
None
|
Returns:
| Type | Description |
|---|---|
FastAPI
|
A FastAPI app with |
FastAPI
|
and |
Raises:
| Type | Description |
|---|---|
OptionalDependencyError
|
If |
Source code in src/linkingtk/server/app.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | |
schemas ¶
Pydantic request/response models for the REST server.
These mirror the plain dataclasses in linkingtk.core.entity and linkingtk.core.result so the API has a typed, OpenAPI-documented contract, with small converters to/from the real dataclasses used everywhere else in the library.
LinkRequestBody ¶
Bases: BaseModel
The JSON request part of a POST /link/{linker_name} call.
Exactly one of dataset2_entities (an inline target list) or
dataset2_source (the name of a pre-registered
EntitySource) must be set.
SchemaAlignmentResult ¶
graph_io ¶
Parse an uploaded supporting graph into a linkingtk.utils.graph.Graph.
Supports raw inline triples, any RDF serialization rdflib can auto-detect
(turtle, N-Triples, RDF/XML, JSON-LD, ...), and NetworkX's GraphML, GEXF,
and edge-list file formats. The result is handed to
BaseLinker.link as-is --
to_triples normalizes it from there, so
this module does no triple conversion of its own.
parse_graph ¶
parse_graph(data: bytes, fmt: str) -> Graph
Parse uploaded graph bytes into a linkingtk.utils.graph.Graph.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
bytes
|
The raw uploaded file/body content. |
required |
fmt
|
str
|
One of |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in src/linkingtk/server/graph_io.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | |