Skip to content

Deploy a script as a worker and run it on platform

Goal: run a shared Python script on the platform, on a schedule, on events or on demand, so it keeps running when no browser is open; then follow its runs and the writes it made.

Prerequisites

  • Signed in as an admin: only admins deploy, redeploy, undeploy and run on platform (v1). Everyone else sees the deployment and the runs.
  • The script is shared on the active context and written in Python (Share a script and use a template). It reaches the platform only through vf.
  • The context has the platform secret scripts-api-key (the runner's credential) and the worker registry has the ScriptRunner; any secret the script reads (vf.secret("…")) is a platform secret (Config > Secrets).

Steps

  1. Open Infra > Scripts, pick the script under Shared on <context> and open its Runs tab. It says not deployed.
  2. Deploy… shows the plan of the script as stored (save your edits first):

    The deploy dialog: the hash, the writes, the starts and the overlap

    • Code: the hash of its code and form. Any later change of them needs a new approval.
    • Writes: every write it may make. These are approved now, for every run: no one is asked again, also on a protected context (the dialog names it in red). A script that calls the kill switch cannot be deployed.
    • Starts: tick On a schedule and enter e.g. @every 5m (or a 6-field cron expression), and/or On events with the input topics and the input replay after a move. On demand is always possible.
    • Overlap: skip or queue; there is no default. Timeout: 600 s unless you change it (at most 3600).
    • Secrets: a platform secret for each secret the script reads.
    • Deploy. The script is locked, and the Runs tab shows the deployment and the state ready once the runner has loaded (the first load may take a minute).
    • Run on platform… asks for the script's form, then starts the run in the worker. It shows at the top of the runs as running and streams its output. You may close the page: the run goes on, and its outcome is there when you come back. Cancel run stops a running run.

    The Runs tab of the deployed script with an on-demand run

  3. Infra > Changes lists the script's writes in your change log, marked by script <NAME>; the link opens the run.

  4. Changed the script? The Runs tab says approval-needed and no run starts. Redeploy… shows the new plan, with the writes added and dropped; confirm it.
  5. Undeploy deletes its runner and trigger. The runs stay listed; the script stays locked.

What you should see

  • The deployment's group (script-<name>, managed by script:<NAME>) on Infra > Topology and Workers, with the runner and its trigger.
  • Each scheduled, event and on-demand run on the Runs tab, newest first, with its outcome, output and writes.

Troubleshooting

Symptom Cause and fix
the script X changed since the plan: review the new plan Someone saved the script while the dialog was open. The dialog shows the plan of the stored script now: read it and confirm again.
overlap is required / input replay is required Choose them: neither has a default, because skipping loses a start and queueing delays the next.
the worker registry has no ScriptRunner This app's registry is older than the ScriptRunner: update the app.
State load-failed The runner could not load, e.g. a secret reference that does not exist (scripts-api-key or a mapped secret). Check Config > Secrets, then redeploy.
State approval-needed The stored code or form changed since the approval: redeploy.
State stuck A run did not end when it was canceled (it blocks in synchronous code): stop and start the runner on Workers.
A run refused with a write not approved The script wrote something the plan did not list (e.g. through an alias of vf): change the script so the call is visible, and redeploy.
Run on platform answers busy Another run is going and the overlap is skip: wait for it or cancel it.

Gaps until access-control

The runner's key (scripts) grants every call: its gate, the approved writes, is the only limit. A deployed script runs unsandboxed in the Runtime's pod, which is why only admins deploy. A hidden script's runner, group and run topic are visible to every API-key holder.

Reference: Scripts, Script workers, the script worker routes, the ScriptRunner.