Get started with lmpy

Use lmpy from LMScript without a separate Python, R or Docker installation. The compiler resolves the released host and its schema from the native host declaration.

Overview

A complete lmpy program declares a host, checks its numerical answer, and prints selected result values.

1. Create a checked program

Declare the host, calculate a value, and check it against a known answer.

if (!file_exists("build")) { mkdir("build"); }
p = _lmcode_ cli="lmpy" install="github:lmctl-ai/lmpy@latest";
let q = dist("norm").ppf(0.975);
out.close("normal quantile", q, 1.959963984540054, 0.00000000000001);
out.put("quantile", q);
end _lmcode_
r = run_lmcode(p);
require(r.ok, json_stringify(r));
println("97.5% standard normal quantile: " + str(r.result.values.quantile));

2. Run the program

Save the file as normal-quantile.lms and run it with lmscript. The first run may download the release binary for your operating system and processor.

lmscript normal-quantile.lms

3. Check the result

97.5% standard normal quantile: 1.959963984540054

A successful run prints the checked result. A failed out.close or out.check assertion makes run_lmcode return ok false with a message that identifies the check, and require stops the program.

See the normal quantile example for a complete runnable source and preview.

Run provider sessions

Use an lmctl build that supports autorun; check with lmctl help autorun before running these commands.

Start a solo provider session or a trio using the linked examples. The trio passes the Lead's assignment to a Coder, sends the Coder's result to a Reviewer, then returns both to the Lead.

lmctl autorun https://lmctl.com/tools/lmpy/lmpy_solo.lms
lmctl autorun https://lmctl.com/tools/lmpy/lmpy_trio.lms

Read the solo script or read the trio script.