Word

python

A function whose code is a Python file of the project. It is a helper word: it is stored as an action, and is always code.

Example

TypeScript
export const churn = python('churn', {
  file: 'ml/churn.py',
  input: { team: link('teams') },
  output: object({ risk: number() }),
  access: role('staff'),
})

The file holds one run, which is handed the checked input as plain values and tent, and answers the output:

ml/churn.py
def run(input, tent):
    orders = tent.db().execute("select total from orders").fetchall()   # the rows of `rows`
    return {"risk": 0.2}

tent gives db(), call(name, input), file(id), folder (a folder of the call, for files it writes and answers), disk (a folder that outlasts calls and restarts), save_progress(value) and progress() inside a step, stopping(), say(value), log(message), and Fail, Error and Back. A print is a line of the log. Python runs in a program of its own beside the engine, in an environment made from the project's lock: run tent python lock after each change of packages. The program loads the file at its first call and keeps it loaded, and is ended when it stood idle for limits.pythonStopAfter; a new version runs in a new one.

Options

OptionMeans
option.python.fileThe Python file that holds the code.
option.python.inputThe fields that a call gives.
option.python.outputThe type of the answer.
option.python.accessWho may call it.
option.python.packagesThe packages the code needs.
option.python.filesMore files of the project that the code works with.
option.python.lockA lock of its own, for packages that cannot share the lock of the project.
option.python.rowsPlans whose rows reach Python as tables.
option.python.usesThe functions and the service calls that the Python code may call back.
option.python.limitsThe limits of a call.
option.python.gpuLets the Python program see the graphics cards of the computer.
option.python.atOnceHow many calls one loaded copy is handed at the same time.
option.python.workerThe kind of worker it runs on.
option.python.backgroundRuns it off the main thread.
option.python.batchGathers calls into one.
option.python.rememberKeeps the answers for the same input.
option.python.sendsWhether it sends data out.
option.python.changesThe builder's word on whether it changes anything.
option.python.callerGoneWhat becomes of the work when its caller is gone.
option.python.followWho may follow its runs from a page.
option.python.countByFor whom its calls are counted.
option.python.aboutOne sentence on what it is for.
option.python.dangerWhether AIs and MCP callers ask a person before it runs.
option.python.offerThe outside doors it is offered to.
option.python.deprecatedMarks it as going away, in the API description and in its answers.
option.python.systemGives it full access, with the reason.
option.python.wasIts old name, where it was renamed.

Returns

A function that answers a promise, called like an action.

Errors

code.T0010: it was called with no engine: nothing stands in the runtime slot.

code.T7119: the code raised an error, its Python program ended, or it passed its memory.

code.T7020: its lock is not there, or was made from other entries of packages.

code.T0016: the Python, the installer or a package could not be fetched, or a package file does not fit its lock.

code.T0008: the call took longer than limits.time.

code.T1014: an entry of packages holds an option or an address.

See also

topic.words, word.action