Skip to content

Python (python-script@v1) ​

Run Python that needs packages, network access, the filesystem, or environment variables, with action-owned Python and optional requirements.

For data transforms that need none of these, use the built-in js.run step. It runs in an embedded sandbox and needs no Python download.

  • Repository: dagucloud/python-script
  • Runtime owned by the action: astral-sh/uv@0.11.14 through action tools; default Python 3.13.9

Contributions are welcome. The repository is public, so improvements, bug reports, and pull requests can go to dagucloud/python-script.

Example ​

yaml
steps:
  - id: compute
    action: python-script@v1
    with:
      input:
        version: "2.3.4"
        services: ["api", "worker", "scheduler"]
      requirements:
        - packaging==25.0
      script: |
        from packaging.version import Version

        version = Version(input["version"])

        return {
            "major": version.major,
            "serviceCount": len(input["services"]),
        }

  - id: print
    run: echo "result=${steps.compute.outputs.result}"
    depends: compute

script is a Python async function body. return publishes result, and await works directly. The action exposes input, params, and env.

The requirements field is optional. When present, each entry is passed to uv run --with, so pin dependencies for reproducible runs.

Inputs ​

FieldDescription
scriptRequired. Python async function body to run.
inputJSON-compatible value exposed to the script as input.
requirementsRequirement specifiers installed for the script. Defaults to [].
envExtra environment variables for the script process, as a string map.
timeoutSecondsTimeout for the script process in seconds, from 1 to 300. Defaults to 30.
pythonVersionExact Python version used by uv, such as 3.13.9. Defaults to 3.13.9.

Outputs ​

FieldDescription
oktrue when the script completed successfully.
resultJSON-compatible value returned by the script.
stdoutText written to stdout with print() or other stdout writes.
stderrText written to stderr by the script process.
durationMsWrapper-measured duration in milliseconds.
pythonVersionPython version used by the script process.
errorError object when the script fails.

Dagu is open source under the GNU General Public License v3.0.