annotate README.md @ 12:ba73d8ba81dc default tip

refactor
author drewp@bigasterisk.com
date Mon, 18 Mar 2024 16:51:44 -0700
parents b72f4ba1345d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
db1ee14b922d a little more to get presubmit working
drewp@bigasterisk.com
parents:
diff changeset
1 # rdferry
db1ee14b922d a little more to get presubmit working
drewp@bigasterisk.com
parents:
diff changeset
2
9
b72f4ba1345d design notes
drewp@bigasterisk.com
parents: 1
diff changeset
3 A library for python and typescript.
b72f4ba1345d design notes
drewp@bigasterisk.com
parents: 1
diff changeset
4
b72f4ba1345d design notes
drewp@bigasterisk.com
parents: 1
diff changeset
5 (Rewrites/replaces my rdfdb and patchablegraph projects)
b72f4ba1345d design notes
drewp@bigasterisk.com
parents: 1
diff changeset
6
b72f4ba1345d design notes
drewp@bigasterisk.com
parents: 1
diff changeset
7 Goals:
b72f4ba1345d design notes
drewp@bigasterisk.com
parents: 1
diff changeset
8
b72f4ba1345d design notes
drewp@bigasterisk.com
parents: 1
diff changeset
9 - ferry graphs of RDF statements between disk/server/browser
b72f4ba1345d design notes
drewp@bigasterisk.com
parents: 1
diff changeset
10 - keep them in sync
b72f4ba1345d design notes
drewp@bigasterisk.com
parents: 1
diff changeset
11 - use starlette, uvicorn, rdflib in python
b72f4ba1345d design notes
drewp@bigasterisk.com
parents: 1
diff changeset
12 - use N3.js in typescript
b72f4ba1345d design notes
drewp@bigasterisk.com
parents: 1
diff changeset
13
b72f4ba1345d design notes
drewp@bigasterisk.com
parents: 1
diff changeset
14 Throughout this doc, 'graph' means PatchableGraph, a class that holds an rdflib.ConjuntiveGraph and edits it only through patches. A patch is a set of
b72f4ba1345d design notes
drewp@bigasterisk.com
parents: 1
diff changeset
15 statements to delete and a set to add (in one operation).
b72f4ba1345d design notes
drewp@bigasterisk.com
parents: 1
diff changeset
16
b72f4ba1345d design notes
drewp@bigasterisk.com
parents: 1
diff changeset
17 ## API plans to turn into tested examples
b72f4ba1345d design notes
drewp@bigasterisk.com
parents: 1
diff changeset
18
b72f4ba1345d design notes
drewp@bigasterisk.com
parents: 1
diff changeset
19 Each of these items should be a one-liner to set up.
b72f4ba1345d design notes
drewp@bigasterisk.com
parents: 1
diff changeset
20
b72f4ba1345d design notes
drewp@bigasterisk.com
parents: 1
diff changeset
21 - server boilerplate with metrics and auto index page:
b72f4ba1345d design notes
drewp@bigasterisk.com
parents: 1
diff changeset
22 - `svr = StarletteServer()`
b72f4ba1345d design notes
drewp@bigasterisk.com
parents: 1
diff changeset
23 - `svr.serve() # if caller hasn't routed '/', serve auto index`
b72f4ba1345d design notes
drewp@bigasterisk.com
parents: 1
diff changeset
24
b72f4ba1345d design notes
drewp@bigasterisk.com
parents: 1
diff changeset
25 ### py
b72f4ba1345d design notes
drewp@bigasterisk.com
parents: 1
diff changeset
26
b72f4ba1345d design notes
drewp@bigasterisk.com
parents: 1
diff changeset
27 - SSE -> graph
b72f4ba1345d design notes
drewp@bigasterisk.com
parents: 1
diff changeset
28 - `graph = GraphSseClient(url1)`
b72f4ba1345d design notes
drewp@bigasterisk.com
parents: 1
diff changeset
29 - `await graph.finishFirstRead()`
b72f4ba1345d design notes
drewp@bigasterisk.com
parents: 1
diff changeset
30 - graph -> simple served text (StaticGraph)
b72f4ba1345d design notes
drewp@bigasterisk.com
parents: 1
diff changeset
31 - (part of addGraphRoutes)
b72f4ba1345d design notes
drewp@bigasterisk.com
parents: 1
diff changeset
32 - graph -> SSE (GraphEvents)
b72f4ba1345d design notes
drewp@bigasterisk.com
parents: 1
diff changeset
33 - `svr.addGraphRoutes('name1', graph1)`
b72f4ba1345d design notes
drewp@bigasterisk.com
parents: 1
diff changeset
34 - graph -> sparql -> table
b72f4ba1345d design notes
drewp@bigasterisk.com
parents: 1
diff changeset
35 - k8s json -> graph
b72f4ba1345d design notes
drewp@bigasterisk.com
parents: 1
diff changeset
36 - `graph = K8sRead(type='Deploy', ns='default', name='deploy1', watch=True)`
b72f4ba1345d design notes
drewp@bigasterisk.com
parents: 1
diff changeset
37 - but break this into json-fetch and jsonld-convert
b72f4ba1345d design notes
drewp@bigasterisk.com
parents: 1
diff changeset
38 - mqtt json/etc -> graph
b72f4ba1345d design notes
drewp@bigasterisk.com
parents: 1
diff changeset
39 - csv -> graph
b72f4ba1345d design notes
drewp@bigasterisk.com
parents: 1
diff changeset
40 - `graph = FromCsv(r: csvReader)`
b72f4ba1345d design notes
drewp@bigasterisk.com
parents: 1
diff changeset
41 - file -> graph -> file
b72f4ba1345d design notes
drewp@bigasterisk.com
parents: 1
diff changeset
42 - `graph = WatchFile(file: Path)`
b72f4ba1345d design notes
drewp@bigasterisk.com
parents: 1
diff changeset
43 - `await graph.finishFirstRead()`
b72f4ba1345d design notes
drewp@bigasterisk.com
parents: 1
diff changeset
44 - `graph = WatchTree(top: Path)`
b72f4ba1345d design notes
drewp@bigasterisk.com
parents: 1
diff changeset
45 - `await graph.finishFirstRead()`
b72f4ba1345d design notes
drewp@bigasterisk.com
parents: 1
diff changeset
46 - multiple graphs -> readonlygraphaggregate (collector)
b72f4ba1345d design notes
drewp@bigasterisk.com
parents: 1
diff changeset
47 - `graph = PatchableAggregate([graph])`
b72f4ba1345d design notes
drewp@bigasterisk.com
parents: 1
diff changeset
48 - http request -> statement(s) (rdf_over_http.py)
b72f4ba1345d design notes
drewp@bigasterisk.com
parents: 1
diff changeset
49 - `def handler1(stmt, requests): ...`
b72f4ba1345d design notes
drewp@bigasterisk.com
parents: 1
diff changeset
50 - `svr.addRdfStatementRoute('/path1', handler1)`
b72f4ba1345d design notes
drewp@bigasterisk.com
parents: 1
diff changeset
51 - `def handler2(graph, requests): ...`
b72f4ba1345d design notes
drewp@bigasterisk.com
parents: 1
diff changeset
52 - `svr.addGraphInputRoute('/path2', handler2)`
b72f4ba1345d design notes
drewp@bigasterisk.com
parents: 1
diff changeset
53
b72f4ba1345d design notes
drewp@bigasterisk.com
parents: 1
diff changeset
54 ### js
b72f4ba1345d design notes
drewp@bigasterisk.com
parents: 1
diff changeset
55
b72f4ba1345d design notes
drewp@bigasterisk.com
parents: 1
diff changeset
56 - SSE -> graph
b72f4ba1345d design notes
drewp@bigasterisk.com
parents: 1
diff changeset
57 - new GraphSseClient(url1) (graphSseClient.graph: N3.Store)