-
Notifications
You must be signed in to change notification settings - Fork 597
Expand file tree
/
Copy pathray-job-submission-sdk.yml
More file actions
55 lines (52 loc) · 1.92 KB
/
ray-job-submission-sdk.yml
File metadata and controls
55 lines (52 loc) · 1.92 KB
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
apiVersion: tekton.dev/v1
kind: Task
metadata:
name: ray-job-submission-sdk
labels:
app.kubernetes.io/version: "0.3"
annotations:
tekton.dev/pipelines.minVersion: '0.26.0'
tekton.dev/categories: "Developer+Tools"
tekton.dev/tags: ray, ai, python, cluster
tekton.dev/displayName: "Ray Job Submit"
tekton.dev/platforms: "linux/amd64"
spec:
description: "Submit a Python job (inline or file) to a RayCluster"
workspaces:
- name: source
description: "Workspace containing Python files to run on Ray"
params:
- name: rayAddress
description: "Ray head address (e.g., http://raycluster-kuberay-head-svc:8265)"
default: "http://raycluster-kuberay-head-svc:8265"
- name: entrypoint
description: "Python command. Can be inline (-c '...') or a file (script.py)"
default: "python -c \"import ray; ray.init(); print(ray.cluster_resources())\""
- name: workingDir
description: "Working directory inside workspace (sent to Ray as --working-dir)"
default: "."
results:
- name: jobId
description: Ray Job ID
- name: jobStatus
description: Final job status
steps:
- name: submit
image: rayproject/ray:latest
workingDir: /workspace/source
script: |
#!/bin/sh
set -e
echo "Submitting Ray job to $(params.rayAddress)..."
ray job submit \
--address $(params.rayAddress) \
--working-dir $(params.workingDir) \
-- $(params.entrypoint) | tee /tmp/ray-output.log
# Extract Job ID
job_id=$(grep -oE "Job '[^']+'" /tmp/ray-output.log | head -n1 | sed "s/Job '\(.*\)'/\1/")
echo "Detected Job ID: $job_id"
echo -n "$job_id" > $(results.jobId.path)
# Get final status
status=$(ray job status "$job_id" --address $(params.rayAddress) | tail -n1)
echo "Final Job Status: $status"
echo -n "$status" > $(results.jobStatus.path)