Syntax
Global Options
| Option | Short | Type | Default | Description |
|---|---|---|---|---|
--box TEXT | String | Lagerbox name or IP address | ||
--image IMAGE | String | lagerdata/gatewaypy3:v0.1.84 | Docker image to use | |
--env FOO=BAR | Multiple | Set environment variables for the script | ||
--passenv VAR | Multiple | Pass environment variables from current shell | ||
--kill | Flag | Terminate a running Python script | ||
--signal SIGNAL | Choice | SIGTERM | Signal to use with --kill | |
--download FILE | Multiple | Download files from box after script completes | ||
--allow-overwrite | Flag | Allow overwriting existing local files with --download | ||
--timeout SECONDS | Integer | 0 (none) | Maximum runtime in seconds | |
--detach | -d | Flag | Run in detached mode (background) | |
--port PORT | -p | Multiple | Forward ports to the Python process | |
--add-file FILE | Multiple | Add extra files to upload with script | ||
--help | Flag | Show help message and exit |
RUNNABLE- Python script file or directory to execute (required unless--killis used)ARGS- Additional arguments passed to the script
--kill: SIGINT, SIGQUIT, SIGABRT, SIGKILL, SIGUSR1, SIGUSR2, SIGTERM, SIGSTOP
Basic Usage
Environment Variables
Setting Variables
Auto-Injected Variables
The following environment variables are automatically available inside your script:| Variable | Description |
|---|---|
LAGER_OUTPUT_CHANNEL | File path for structured output (see Structured Output below) |
LAGER_PROCESS_ID | Unique UUID for this execution |
LAGER_RUNNABLE | Path to the script being executed |
LAGER_BOX | Box name (if --box was provided) |
File Downloads
Download files generated by your script after it completes:--allow-overwrite is set. Gzip-compressed files are automatically decompressed during download.
Detached Mode
Run scripts in the background without waiting for output:- The command returns immediately after the script starts
- No stdout/stderr is streamed back
- The script continues running on the box
- Use
--killto stop it later
Killing Running Scripts
Port Forwarding
Forward network ports from the box to your local machine:SRC_PORT[:DST_PORT][/PROTOCOL]
Timeout
Limit script execution time:- First, SIGTERM is sent (exit code 124)
- If the script doesn’t exit, SIGKILL is sent (exit code 137)
Structured Output
Scripts running on the box can send structured data back to the CLI using thelager.core.output() function. This uses a dedicated output channel (file descriptor 3) separate from stdout/stderr.
Box-Side API
| Encoder | ID | Use Case |
|---|---|---|
OutputEncoders.Raw | 1 | Binary data (images, files) |
OutputEncoders.Pickle | 2 | Python objects (default) |
OutputEncoders.JSON | 3 | JSON-serializable data |
OutputEncoders.YAML | 4 | YAML-serializable data |
Module Includes
If your script depends on local modules, configure includes in a.lager file in your project:
.lager file, then zips the script along with all include directories before uploading to the box.
test.py:
Additional Files
Upload extra files alongside your script:Exit Codes
| Exit Code | Meaning |
|---|---|
| 0 | Success |
| -1 | Failed to retrieve exit code from box |
| 124 | Script terminated by SIGTERM (timeout) |
| 137 | Script killed by SIGKILL (timeout, force) |
| Other | Script’s own exit code |
Examples
Hardware Test Script Example
Notes
- Default Docker image:
lagerdata/gatewaypy3:v0.1.84 - Use
--envfor script-specific configuration values - Use
--passenvfor secrets/tokens from your current shell --downloadretrieves files only after script completion (not during)- Port forwarding syntax:
SRC_PORT[:DST_PORT][/PROTOCOL] - After script execution, the hardware cache on the box is automatically cleared to release VISA connections
- Output is streamed in real time via a multiplexed HTTP protocol with keepalive (20-second interval)
pip Command
Run pip commands in the Python container on the box. Useful for installing packages that your scripts depend on.Syntax
Options
| Option | Description |
|---|---|
--box BOX | Lagerbox name or IP address |
--help | Show help message and exit |
Examples
Notes
- Runs pip in the Lager Python container, not on your local machine
- Installed packages persist across
lager pythoninvocations on the same box - All standard pip commands and arguments are supported

