Repository navigation
A shared runtime for user code: transforms today, analyses next #3
Replies: 2 comments
|
Summary of a conversation with Andres on where this lands, so it is on record here. What the three modes need
So the service is more than "run this function": it needs jobs, sessions, and a way to hand user code a scoped credential for HFS. Where it runs
OwnershipA third service, owned by neither HIE nor the product, that both consume. Two things HIE needs from it
The part that still needs design is the credential: how the service gives user code a token scoped to one tenant to read HFS and HTS during a batch job. |
|
The runtime now has a home: https://github.com/HeliosSoftware/python-runtime. This is the contract HIE honours today with its local Python worker, written down so the service can offer the same thing and HIE only changes transport. What a transform isA Python module that defines
The helpers a transform may import from The wire today: JSON lines over stdin/stdout
{"id": 1, "record": {...}, "context": {"feed": "lab-results", "file": "labs.csv", "line": 2}}{"id": 1, "resources": [{"resourceType": "Observation", ...}]}
{"id": 1, "error": {"kind": "data", "message": "value 'alto' is not a number"}}
{"id": 1, "error": {"kind": "transform", "message": "KeyError: 'unit'", "trace": "..."}}
What the service would exposeThe same thing over HTTP, batched, is enough for HIE:
Errors of the service (down, timeout, a 5xx) are transient for HIE: the records wait and are retried, and the outage alert names the runtime. Only a reply with On HIE's side this becomes one setting: Not HIE's concernHow the code is isolated (gVisor, Firecracker, Kubernetes), how long a batch job may run, sessions for a workbook, and the credential user code gets to read HFS/HTS: the service decides, as discussed above. HIE's transforms are short, stateless, and never talk to HFS themselves. |
Uh oh!
There was an error while loading. Please reload this page.
Two parts of the platform run code that users write: the integration engine runs transforms (Python today), and the analytics application runs analyses and compute steps (Python today, with SQL and possibly JavaScript mentioned as later). Both need the same thing: a place to run a program that is not ours, on data that is sensitive, without letting it take down the host or reach anything it should not. This discussion is for deciding whether that place is one shared service, and what it is built on.
What the engine needs from it
The engine's contract with a transform is small and already defined: one request per record (
{"id", "record", "context"}), one reply ({"id", "resources"}or{"id", "error": {"kind", "message"}}), JSON per line. Today the engine starts one long-lived Python process per feed and talks to it over stdin and stdout. The contract does not say where the process runs, so the runtime can change underneath it. What the engine needs from any runtime:The options
Two things are the same whichever is chosen. First, the contract (JSON per record, batched) and the registry (named, versioned transforms) belong to the shared service, not to each caller. Second, the service should offer the two deployment variants the rest of the platform offers: run it yourself (containers, or Firecracker where KVM is available) and run it managed (Lambda), behind one API.
A proposal to react to
POST /runwith a transform version and a batch of inputs, returning one output per input;POST /tryfor dry runs; the registry of versions behind it. The engine'sTransformertrait gets an implementation that calls it, next to the subprocess one.Questions
Related: the engine's transform contract and
Transformertrait are in #1 (decision 3 ofdocs/decisions.md).All reactions