Gradient Actions

Gradient Actions are composable building blocks for creating reproducible machine learning workflows. Actions use the uses and with syntax to specify how a job step executes.

container

with:
image: bash:5
args: ["echo", "hello", "world"]

In this basic example, the Gradient action called [email protected] allows us to pick an arbitrary docker container (in this case the lightweight bash container) and pass arguments directly to it.

script

with:
script: |-
echo 'hello world'
echo $RANDOM
image: bash:5

If you want to run multiple commands, the [email protected] action allows you to pass a script in a literal-style HereDoc denoted by |-. The pipe will preserve newlines and the dash will remove extra newlines after the block.

Note: The image you provide will need to have bash available in it's PATH.

git-checkout

inputs:
repo:
type: volume
with:
url: https://github.com/user/my-public-repo
ref: 46aa59d6ecc3720ffe2454a6d9d360e6ce75acce #optional git ref

In this example, the Gradient action [email protected] clones the public GitHub URL https://github.com/user/my-public-repo at ref 46aa... into a volume named repo. The cloned files are accessible at inputs/<input-name> (in this case, inputs/repo), and subsequent jobs that specify a volume input can also access the repository files at inputs/<input-name>.

Note: to clone a private repository, add your username as an action parameter, set a Gradient secret with a GitHub access token value, and add a password parameter (example below).

inputs:
repo:
type: volume
with:
url: https://github.com/user/my-private-repo
username: paperspace
password: secret:MY_SECRET_NAME

s3-download

inputs:
s3:
type: volume
with:
url: s3://bucket/path/
access-key: MYACCESSKEY
secret-access-key: secret:MY_SECRET_NAME

The [email protected] Gradient action copies the contents of an s3 bucket into a volume (in this example, the volume is named s3). Subsequent jobs that specify an input of type: volume can access the downloaded files within that job at inputs/<input-name>.

Note: access-key and secret-access-key are required parameters, and the latter must be a Gradient secret. Optional parameters include region (for AWS buckets) and endpoint (for non-AWS buckets).

model-create

inputs:
model:
type: dataset
with:
ref: dsr8k5qzn401lb5:klfoyy9 # Example dataset ref
outputs:
model-id:
type: string
uses: create-[email protected]
with:
name: my-model-name
type: Tensorflow # Tensorflow, ONNX, or Custom

In this example, the [email protected] action takes a dataset input named model and outputs a string ID (named model-id) that references a Gradient model. With this reference, the created model can be tested, edited, or deployed in future jobs.