Skip to content

Commit b6706d9

Browse files
author
Raunak Bhagat
authored
[FEAT] Add ability to run arbitrary command on a set working directory (Eventual-Inc#3404)
# Overview - this PR will add the ability to run some arbitrary command on the ray cluster that the workflow has booted up - the working directory can be specified (defaults to `.github/assets`) - the command can be specified (must be provided; furthermore, empty strings will result in a failure of the workflow)
1 parent 5dce4fb commit b6706d9

File tree

3 files changed

+43
-2
lines changed

3 files changed

+43
-2
lines changed

.github/workflows/run-cluster.yaml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,22 @@ on:
55
inputs:
66
daft_version:
77
type: string
8-
description: The wheel artifact to use
8+
description: The version of daft to install
99
required: false
1010
python_version:
1111
type: string
1212
description: The version of python to use
1313
required: false
1414
default: "3.9"
15+
command:
16+
type: string
17+
description: The command to run on the cluster
18+
required: true
19+
working_dir:
20+
type: string
21+
description: The working directory to submit to the cluster
22+
required: false
23+
default: .github/working-dir
1524

1625
jobs:
1726
run-command:
@@ -65,7 +74,11 @@ jobs:
6574
- name: Submit job to ray cluster
6675
run: |
6776
source .venv/bin/activate
68-
ray job submit --address http://localhost:8265 -- python -c "print('Hello, world!')"
77+
if [[ -z '${{ inputs.command }}' ]]; then
78+
echo 'Invalid command submitted; command cannot be empty'
79+
exit 1
80+
fi
81+
ray job submit --working-dir ${{ inputs.working_dir }} --address http://localhost:8265 -- ${{ inputs.command }}
6982
- name: Spin down ray cluster
7083
if: always()
7184
run: |

.github/working-dir/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Working dir for submission
2+
3+
This an example of a working directory which can be included inside of runs of the ray-cluster in a GitHub Actions workflow.
4+
5+
## Usage
6+
7+
In order to submit your own script, create a file in this directory, add+commit+push it to GitHub, and submit a GitHub Actions workflow request by specifying the path to this directory and a python command to execute the file.
8+
9+
## Example
10+
11+
First create the file:
12+
13+
```bash
14+
touch .github/working-dir/my_script.py
15+
echo "print('Hello, world!')" >> .github/working-dir/my_script.py
16+
```
17+
18+
Then submit the request to execute the workflow to run this file on a ray-cluster.
19+
You can either do this via the GitHub Actions UI or by running the GitHub CLI:
20+
21+
```bash
22+
gh workflow run run-cluster.yaml --ref $MY_BRANCH -f command="python my_script.py"
23+
```

.github/working-dir/simple.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import daft
2+
3+
df = daft.from_pydict({"nums": [1, 2, 3]})
4+
df = df.with_column("result", daft.col("nums").cbrt()).collect()
5+
df.show()

0 commit comments

Comments
 (0)