Input and output fields
You declare each field the node reads and each field it writes, with a name and a type. A node may declare any number of input and output fields, and each is either required or optional. A field name must:- start with a letter and end with a letter or digit,
- contain only lowercase letters, digits, and underscores,
- be at most 128 characters,
- be unique across the pipeline.
The code
The code is an async function namedmain that the platform calls once per item with that item’s inputs. It takes one argument, the dictionary of input fields, and returns a dictionary of output fields. A new node starts from this skeleton:
review_text and writes an output field word_count looks like this:
- import
InputsandOutputsfrommain_types, - define a top-level function named
main, markedasync, - give
mainexactly one argument annotatedInputsand annotate its return asOutputs, - contain at least one
returnthat returns a value, - be valid, non-empty Python.
Runtime environment
The platform pins the runtime to Python 3.12 and installs nothing on top. The standard library is available. Whatever else the base runtime happens to contain is not part of the contract, so rely only on the standard library. The node has no option to add packages, and an import of a package that is not present raises, which fails the item. Each item runs on its own. Nothing the code stores during one item’s run is available to another.Environment variables
Use environment variables to pass fixed text or project secrets, such as an API key, to your code. An entry’s name must:- contain only uppercase letters, digits, and underscores, and not start with a digit,
- be unique within the node.
The check
The check, the Code Test card on the node, is a set of check cases you define while editing. Each case has a name and its own sample values for the input fields, and running it executes the code once against those samples and reports success or the error it produced. You may define any number of cases. A case’s run has the same 60-second and 10 MB ceilings as a run-time item, plus a stricter cap of its own: each sample input value and each value the case’s run returns is capped at 32 KB. Code whose fields approach the 1 MB run-time cap therefore cannot be exercised at full size in a case. Running the cases is not required to deploy. A node with no cases, or with a case that has not been run or is still running, gets a warning you can override at deploy. Any case that failed blocks the deploy, as does leaving the code empty.Limits
The run-time ceilings apply to every item, whether or not the node’s check cases passed. Sizes are measured on the JSON text of the values, in binary units (1 MB = 1,024 × 1,024 bytes). Keep the returned JSON comfortably below the 10 MB limit.
Related
- Pipeline nodes — how the Code node fits with the other node kinds
- Fields and data — field names, types, and how values are shaped
- Match node — route each item on a value your code derives
- Self-check — where check results land in the deploy gate
- Glossary — secret, field, and node defined briefly