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

2
with:
3
image: bash:5
4
args: ["echo", "hello", "world"]
Copied!
The Gradient Action called [email protected] allows you to use an arbitrary Docker container image (in this case the lightweight bash container image) and pass arguments directly to it.

script

2
with:
3
script: |-
4
echo 'hello world'
5
echo $RANDOM
6
image: bash:5
Copied!
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 character 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 its PATH.

git-checkout

1
outputs:
2
repo:
3
type: volume
5
with:
6
url: https://github.com/user/my-public-repo
7
ref: 46aa59d6ecc3720ffe2454a6d9d360e6ce75acce # Optional git ref
8
path: /outputs/repo # Optional, defaults to exactly one output volume or dataset
Copied!
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 /outputs/<output-name> (in this case, /outputs/repo), and subsequent jobs that specify the checkout job's volume as an input can also access the repository files as read-only at /inputs/<input-name>.
1
inputs:
2
repo: checkout-job.outputs.repo
4
with:
5
image: busybox
6
args: ['ls', '/inputs/repo']
Copied!
Note: To clone a private repository, add your username as a parameter, set a Gradient secret with a GitHub access token value, and add a password parameter:
1
outputs:
2
repo:
3
type: volume
5
with:
6
url: https://github.com/user/my-private-repo
7
username: paperspace
8
password: secret:MY_SECRET_NAME
Copied!
You can also use path to pick an output target:
1
outputs:
2
repo:
3
type: volume
4
ds:
5
type: dataset
6
with:
7
ref: my-dataset
9
with:
10
url: https://github.com/user/my-public-repo
11
ref: 46aa59d6ecc3720ffe2454a6d9d360e6ce75acce # Optional git ref
12
path: /outputs/repo/subfolder
Copied!

s3-download

1
outputs:
2
s3:
3
type: volume
5
with:
6
url: s3://bucket/path/
7
access-key: MYACCESSKEY
8
secret-access-key: secret:MY_SECRET_NAME
Copied!
The [email protected] Gradient Action copies the contents of an Amazon S3 bucket into an output (in this example, the volume is named s3). Subsequent jobs that specify an input that reference the s3-download job's volume output 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), endpoint (for non-AWS buckets), and path (to disambiguate target outputs or to download to a subfolder).

model-create

1
inputs:
2
model:
3
type: dataset
4
with:
5
ref: dsr8k5qzn401lb5:klfoyy9 # Example dataset ref
6
outputs:
7
model-id:
8
type: string
9
uses: create-[email protected]
10
with:
11
name: my-model-name
12
type: Tensorflow # Tensorflow, ONNX, or Custom
Copied!
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.
Last modified 15d ago