-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
152 lines (146 loc) · 6.49 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
name: 'Coiled Run'
description: 'GitHub Action to run CLI jobs on VM via Coiled'
author: 'Coiled'
branding:
icon: 'command'
color: 'blue'
inputs:
command:
description: "Command to run on VM."
required: true
name:
description: "Run name. This identifier controls whether `coiled run` invocations are dispatched to the same cloud VM or not. Use the same name to run multiple commands on the same VM. Defaults to a unique name with no VM reuse."
required: false
workspace:
description: "Coiled workspace (uses default workspace if not specified)."
required: false
software:
description: "Software environment name to use. If neither software nor container is specified, all the currently-installed Python packages are replicated on the VM using package sync."
required: false
container:
description: "Container image to use. If neither software nor container is specified, all the currently-installed Python packages are replicated on the VM using package sync."
required: false
vm-type:
description: "VM type to use. Specify multiple types separated by spaces to provide multiple options."
required: false
gpu:
description: "Have a GPU available."
required: false
region:
description: "The cloud provider region in which to run the notebook."
required: false
disk-size:
description: "Use larger-than-default disk on VM, specified in GiB."
required: false
keepalive:
description: "Keep your VM running for the specified time, even after your command completes. In seconds (``60``) unless you specify units (``3m`` for 3 minutes). Default to shutdown immediately after the command finishes."
required: false
file:
description: "Local files required to run command. Can be either individual file or entire directory. Multiple values can be specified, by separating with spaces (``foo.txt my-subdir/``)."
required: false
env:
description: "Environment variables securely transmitted to run command environment. Format is ``KEY=val``, multiple vars can be specified by separating with spaces."
required: false
subdomain:
description: "Custom subdomain for the VM hostname."
required: false
allow-ssh-from:
description: "IP address or CIDR from which connections to port 22 (SSH) are open; can also be specified as 'everyone' (0.0.0.0/0) or 'me' (automatically determines public IP detected for your local client). Note that ``coiled run`` relies on SSH connection for executing commands on VM. [default: me]"
required: false
port:
description: "Open extra ports in network firewall for inbound connections (multiple ports can be set by separating them with spaces)."
required: false
interactive:
description: "Open an interactive session, e.g., ``coiled run --interactive bash`` or ``coiled run --interactive python``."
required: false
detach:
description: "Start the run in the background, don't wait for the results."
required: false
sync:
description: "Sync files between local working directory and ``/scratch/synced``."
required: false
root:
description: "Act as root in Docker container."
required: false
forward-gcp-adc:
description: "Forward long-lived Google Cloud Application Default Credentials to VM for data access."
required: false
tag:
description: "Tags. Format is ``KEY=val``, multiple vars can be set by separating with spaces."
required: false
sync-ignore:
description: "Paths to not sync when using ``sync``."
required: false
mount-bucket:
description: "S3 or GCS bucket(s) to mount as volumes."
required: false
runs:
using: 'composite'
steps:
- name: Check if command is set
shell: bash
env:
INPUT_COMMAND: ${{ inputs.command }}
run: |
if [[ -z "$INPUT_COMMAND" ]]; then
echo "Command is required."
exit 1
fi
- uses: actions/checkout@v4
- name: Install conda environment
uses: mamba-org/setup-micromamba@v1
env:
PYTHON_VERSION: 3.12
COILED_VERSION: 1.45.0
with:
cache-downloads-key: coiled-run-downloads-${{ runner.arch }}-${{ env.PYTHON_VERSION }}-${{ env.COILED_VERSION }}
cache-environment-key: coiled-run-env-${{ runner.arch }}-${{ env.PYTHON_VERSION }}-${{ env.COILED_VERSION }}
generate-run-shell: false
environment-name: coiled-run
create-args: >-
python=${{ env.PYTHON_VERSION }}
coiled=${{ env.COILED_VERSION }}
- name: Run coiled run
shell: bash
env:
INPUT_COMMAND: ${{ inputs.command }}
INPUT_NAME: ${{ inputs.name }}
INPUT_WORKSPACE: ${{ inputs.workspace }}
INPUT_SOFTWARE: ${{ inputs.software }}
INPUT_CONTAINER: ${{ inputs.container }}
INPUT_VM_TYPE: ${{ inputs.vm-type }}
INPUT_GPU: ${{ inputs.gpu }}
INPUT_REGION: ${{ inputs.region }}
INPUT_DISK-SIZE: ${{ inputs.disk-size }}
INPUT_KEEPALIVE: ${{ inputs.keepalive }}
INPUT_FILE: ${{ inputs.file }}
INPUT_ENV: ${{ inputs.env }}
INPUT_SUBDOMAIN: ${{ inputs.subdomain }}
INPUT_ALLOW_SSH_FROM: ${{ inputs.allow-ssh-from }}
INPUT_PORT: ${{ inputs.port }}
INPUT_INTERACTIVE: ${{ inputs.interactive }}
INPUT_DETACH: ${{ inputs.detach }}
INPUT_SYNC: ${{ inputs.sync }}
INPUT_ROOT: ${{ inputs.root }}
INPUT_FORWARD_GCP_ADC: ${{ inputs.forward-gcp-adc }}
INPUT_TAG: ${{ inputs.tag }}
INPUT_SYNC_IGNORE: ${{ inputs.sync-ignore }}
INPUT_MOUNT_BUCKET: ${{ inputs.mount-bucket }}
run: |
args=()
for input in name workspace software container vm-type gpu region disk-size keepalive file env subdomain allow-ssh-from port interactive detach sync root forward-gcp-adc tag sync-ignore mount-bucket; do
var_name="INPUT_${input^^}" # Convert input to uppercase
var_name=$(echo "$var_name" | tr '-' '_') # Replace '-' with '_'
value="${!var_name}" # Use variable indirection to get the value
if [[ -n "$value" ]]; then
# Handle multiple values for certain inputs
if [[ "$input" == "name" ]] || [[ "$input" == "vm-type" ]] || [[ "$input" == "env" ]] || [[ "$input" == "port" ]] || [[ "$input" == "tag" ]]; then
for val in $value; do
args+=("--$input" "$val")
done
else
args+=("--$input" "$value")
fi
fi
done
micromamba run -n coiled-run coiled run "${INPUT_COMMAND}" "${args[@]}"