Learn

Contents

Where data comes from and where it goes

A program reads data from inputs and writes its results to outputs. An input is written the same way whatever gives it its data, reading = input("reading", t : 4): stored data that already exists (a table, a file, a database), data made on request at each point the program asks (an AI model, a web API), or rows given over time while the program runs (sent by another program, replayed from a file, or a clock's ticks). The deployment says which each input is, never the program. The same program runs in two places: in the playground, where everything you give it lives in the browser page, and in a deployment, the elucid8 command on your computer or server, where data comes from files and other programs. This page takes stored inputs, inputs answered on demand, inputs given rows over time and outputs in turn, and says what each looks like in the playground, where inputs and outputs are on the Data In/Out tab, and in a deployment.

A program may read any number of inputs and have any number of outputs, in the playground and in a deployment.

Stored inputs

Stored data already exists, and the program reads it: a table, a file, a database. Such data is often called a data source. In a program it is an input, reading = input("reading", t : 4): it is read from the channel "reading", and names its dimensions and how far each goes (inf for data with no end); input("rate"), naming none, is one value. Where the data comes from is not in the program: in the playground it is the input's card, in a deployment its entry in deploy.json.

-- Stored data: four readings, each with its time; t = 2 has no row.
reading = input("reading", t : 4)
clicks = input("clicks", t : 4)
-- table reading = t,value,ts; 0,3,1000; 1,1,2000; 3,1,4000
-- table clicks = t,value; 0,5; 3,2
-- fill clicks = 0
-- expect reading[t = 1] = 1, at time 2000 ms
-- expect reading[t = 2] = error missing: input reading has no data at this point
-- expect clicks[t = 1] = 0
-- expect clicks[t = 3] = 2

Open in playground

In the playgroundIn a deployment
Where the data isin the page: a table you type or paste, Load file… (CSV or JSON lines, up to 5 MB, read in the page), a formula over the coordinates, or an example's built-in dataa file per input: CSV, JSON lines, or an Apache Parquet or Arrow file as pandas, Polars and DuckDB write them (Data files); or a program that serves the rows through the connector protocol (a database, an API)
When it changesyou edit it and press Update: a new versiona new file, or several files listed as versions of one input; under elucid8 serve, advance brings a new version, or rows appended to the last one (The long-running service)

Inputs answered on demand

Some data is made on request: at each point the program asks an outside program, such as an AI model or a web API, and the answer is data stamped with the time it arrived. Such a program is often called a data service. In a program it is an input too, asked by navigation: echo = input("echo", n : inf) is over a dimension n, and echo[n = reading] asks it, at each t, for its answer at n = reading. Only the deployment says that echo is answered on demand:

-- Answered on demand: echo answers with what it is asked; slow_echo takes too long.
reading = input("reading", t : 4)
echo = input("echo", n : inf)
answer = echo[n = reading]
slow_echo = input("slow_echo", n : inf)
slow = slow_echo[n = reading]
-- table reading = t,value,ts; 0,3,1000; 1,1,2000; 2,4,3000; 3,1,4000
-- service echo: answers formula x1; takes 5 ms; deadline 20 ms
-- service slow_echo: answers formula x1; takes 30 ms; deadline 20 ms
-- expect answer[t = 1] = 1, at time 2005 ms
-- expect slow[t = 1] = error late from slow_echo[n = 1]: late (2030 ms > deadline 2020 ms), at time 2020 ms

Open in playground

The playground makes no network calls, so the programs that answer its inputs stand in for real ones. A simulated program answers a sum, a score or a formula, optionally with a delay and a failure rate (a sum, a mean or the largest of the coordinates it is asked at; a score from 0 to 100; a formula over them). In the playground a new one answers the sum of its inputs after 5 ms and never fails; in deploy.json it is {"builtin": "simulated", …}, its latencyMs must be given (0 answers at once), and it never fails unless failRate is set.

In the playgroundIn a deployment
What answerssum_service (adds the coordinates it is asked at, after the delay on its card) and simulated programs you set on an input's card; no network callsthe same built-ins (sum_service, simulated, anomaly_detector), a recording of earlier answers replayed, or a real program you run, through the input protocol (Command reference), which may call an AI model or an API
Its settingson its card: Takes and Deadline, and under More settings failures, retries and reuseits entry in deploy.json: deadlineMs, retry and reuse

Inputs given rows over time

A program kept running by elucid8 serve takes new data while it runs, and answers every question with the data it has so far (The long-running service). An input with no end along t holds what has arrived:

-- Readings that keep arriving, and the mean of the last five.
reading = input("reading", t : inf)
avg5 = mean reading over (t : #t - 4 .. #t) end
-- table reading = t,value; 0,0; 1,2; 2,4; 3,6; 4,8; 5,10; 6,12
-- expect avg5[t = 0] = 0
-- expect avg5[t = 6] = 8

Open in playground

Its rows can arrive in three ways, each set in the input's entry in deploy.json; the program is the same whichever it is:

With the readings in history.csv and this deploy.json:

{
  "format": "elucid8-deploy/2",
  "inputs": { "reading": { "from": { "builtin": "replay", "file": "history.csv", "every": "1s" } } }
}

elucid8 check says what the input is given:

input "reading": history.csv replayed: one t's rows every 1000 ms, 6 coordinates in order; over t (whole numbers); a missing point is missing data (eod past the last row along t); elucid8 serve gives it its rows over time, elucid8 run cannot read it
In the playgroundIn a deployment
How rows arrivethe data you give the input, all at once; ◀ ▶ and Play step through themelucid8 serve: rows sent by another program, a replay of a file, or a clock

Outputs

An output writes a value as records: one row per point, a column per dimension and one for the value (and its timestamp). A program names its outputs itself, as equations, output("channel") = e, one value each:

-- The readings and their running total, written out together.
reading = input("reading", t : 4)
total = reading fby.t (total + next.t reading)
output("readings") = reading
output("total") = total
-- table reading = t,value,ts; 0,3,1000; 1,1,2000; 2,4,3000; 3,1,4000
-- expect output "readings" over t = 0..3
-- expect output "total" over t = 0..3
-- expect total[t = 3] = 9, at time 4000 ms

Open in playground

With the readings in reading.csv (the program's four rows, each with its ts) and this configuration, which writes the two channels side by side:

{
  "format": "elucid8-deploy/2",
  "inputs": { "reading": { "from": "reading.csv" } },
  "outputs": { "readings-report.csv": {"channels": ["readings", "total"]} }
}

./elucid8 run plan.json --config deploy.json writes readings-report.csv:

t,readings_value,readings_kind,readings_message,total_value,total_kind,total_message
0,3,value,,3,value,
1,1,value,,4,value,
2,4,value,,8,value,
3,1,value,,9,value,

Each value's column holds its data alone, so a spreadsheet or pandas reads it as numbers; its kind (value, eod, or error and the error's kind) and an error's message are beside it (Columns named after their channel).

A CSV file has no timestamps unless asked: with "timestamps": true (or --timestamps), each value's follows its message, t,readings_value,readings_kind,readings_message,readings_ts,total_value,…. The other formats carry them unless asked not to (Timestamps in files). The same two channels as an Apache Parquet file, which pandas, Polars and DuckDB read:

"outputs": { "archive.parquet": {"channels": ["readings", "total"]} }
In the playgroundIn a deployment
Where it goeseach output has a card in the Outputs section of Data In/Out (Add output there writes its equation into the program); Download results on the card saves the records as a file (CSV or JSON lines; an output in another format downloads as either), at most 100,000 records; where the page cannot save a file, Copy resultsa file written by elucid8 run (CSV, JSON lines, frames, Arrow, .npz or Parquet), or a program that takes the records (a database, a webhook) through the connector protocol
When it is writtenwhen you press Download resultseach elucid8 run; under elucid8 serve, a subscription to an output sends a program only the records that changed when new data arrives

Two stored inputs, one answered on demand, and four outputs

Here a program reads two stored inputs, asks one input answered on demand, and names four output channels:

-- Orders: prices and quantities, their value, and a score for each, asked on demand.
price = input("price", i : 3)
qty = input("qty", i : 3)
amount = price * qty
scorer = input("scorer", n : inf)
score = scorer[n = amount]
output("prices") = price
output("quantities") = qty
output("amount") = amount
output("scores") = score
-- table price = i,value; 0,2.5; 1,4; 2,10
-- table qty = i,value; 0,4; 1,3; 2,1
-- service scorer: answers formula x1 / 10; takes 5 ms; deadline 50 ms
-- expect amount[i = 1] = 12
-- expect score[i = 1] = 1.2, at time 5 ms
-- expect output "prices" over i = 0..2
-- expect output "quantities" over i = 0..2
-- expect output "amount" over i = 0..2
-- expect output "scores" over i = 0..2

Open in playground

With "orders.csv": {"channels": ["prices", "quantities", "amount"]} and "scores": {"format": "jsonl"} in its outputs, elucid8 run writes orders.csv and scores.jsonl beside deploy.json.

From the playground to a deployment

The playground's Download turns a saved program into a deployment, a folder that ./elucid8 run plan.json --config deploy.json runs with the playground's answers (Deploy tutorial):

Then swap what stands in for the real thing, one entry at a time: a file for the latest data, a program for a database or an API, a real program for the simulated one, a replay or a clock for data that should arrive over time, a database for an output file (Connecting eLucid8 to your data). The program does not change.

Which to use when

You have…UseFor example
data that exists whether or not the program asksa stored inputsensor readings, prices, purchases, the weather as observed
a value someone computes on request, at the point the program asksan input answered on demanda fraud score from an AI model, a translation, the weather forecast now, from an API
the same data, saveda stored inputyesterday's forecasts, saved to a file, read again and versioned
data that keeps arrivingan input given rows over time, under elucid8 servereadings sent by a sensor's script, a day's file replayed a row a second, a clock's ticks
a table with a column per fielda stored input read with "wide"a spreadsheet's export, t,temperature,humidity
results to keep or pass onan output (with "skip": "eod" to write only what there is, "wide" for a column per field)a training table for a model, alerts into a database, a webhook for each change

Read on