-
Notifications
You must be signed in to change notification settings - Fork 623
Feature/cron scheduling rayjob 2426 #3836
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
andrewsykim
merged 36 commits into
ray-project:master
from
DW-Han:feature/cron-scheduling-rayjob-2426
Jul 30, 2025
Merged
Changes from 15 commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
3c6a9da
init cron sheduling for ray jobs, transferring for local dev
DW-Han 0d986a9
initial cron scheduling for ray jobs
DW-Han acdc061
Delete ray-operator/controllers/ray/utils/cron_helpers.go
DW-Han b4330c9
updating dependencies
DW-Han f7da0f3
Delete ray-operator/test/e2e/rayjob_scheduling_test.go
DW-Han 1a87974
Merge branch 'ray-project:master' into feature/cron-scheduling-rayjob…
DW-Han d2f294c
unit tests and cleaning up scheduling
DW-Han 9b4db80
adding cluster delete option and cleaning code
DW-Han d6f0076
cleaning
DW-Han b6b3989
cleaning and adding schedule util unit tests
DW-Han e449c92
cleaning up comment
DW-Han d6a2bfc
seperate case for scheduling
DW-Han d369a93
cleaning doc string
DW-Han 7a9f462
updating api.md
DW-Han c06bbed
cleaning up scheduling state, controller, etc.
DW-Han 6da9226
integration tests
DW-Han 93adf7c
cleaning controller
DW-Han 8055fa7
cleaning and lint
DW-Han 23f5e28
deepcopy function
DW-Han 1a032b9
working integration tests and cleaning
DW-Han 95cd767
making tests more air tight
DW-Han 5f176a3
making tests more air tight
DW-Han c86ea08
cleaning tests
DW-Han 05c47c7
cleaning rayjob controller
DW-Han f679491
cleaning test
DW-Han 90c5236
Merge branch 'ray-project:master' into feature/cron-scheduling-rayjob…
DW-Han 226113f
cleaning test
DW-Han 75cf551
returning to scheduled state
DW-Han baa17d6
cleaning test and controller
DW-Han 4e03d82
cleaning
DW-Han 00932b8
no cluster creation at start of schedule and cleaning tests
DW-Han 26fe74f
cleaning schedule distance function and other cleaning
DW-Han f5f26fa
cleaning comments
DW-Han c88ee44
cleaning
DW-Han 2a57524
clean commit
DW-Han e4c2a3e
commiting changes
DW-Han File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
apiVersion: ray.io/v1 | ||
kind: RayJob | ||
metadata: | ||
name: rayjob-schedule | ||
spec: | ||
# schedule specifires a cron scheduling string telling the rayjob when to start schedule and run new jobs | ||
# Here it runs at every 5 minutes of every hour of every day of every week of every year | ||
schedule: "*/5 * * * *" | ||
|
||
entrypoint: python /home/ray/samples/sample_code.py | ||
|
||
# shutdownAfterJobFinishes specifies whether the RayCluster should be deleted after the RayJob finishes. Default is false. | ||
# NOTE that the expected behavior with schedule is that the cluster will be deleted and recreated at each schedule if set to true, and it will keep using the same cluster otherwise | ||
shutdownAfterJobFinishes: true | ||
|
||
runtimeEnvYAML: | | ||
pip: | ||
- requests==2.26.0 | ||
- pendulum==2.1.2 | ||
env_vars: | ||
counter_name: "test_counter" | ||
|
||
|
||
rayClusterSpec: | ||
rayVersion: '2.46.0' | ||
headGroupSpec: | ||
rayStartParams: {} | ||
template: | ||
spec: | ||
containers: | ||
- name: ray-head | ||
image: rayproject/ray:2.46.0 | ||
ports: | ||
- containerPort: 6379 | ||
name: gcs-server | ||
- containerPort: 8265 | ||
name: dashboard | ||
- containerPort: 10001 | ||
name: client | ||
resources: | ||
limits: | ||
cpu: "1" | ||
requests: | ||
cpu: "200m" | ||
volumeMounts: | ||
- mountPath: /home/ray/samples | ||
name: code-sample | ||
volumes: | ||
- name: code-sample | ||
configMap: | ||
name: ray-job-code-sample | ||
items: | ||
- key: sample_code.py | ||
path: sample_code.py | ||
workerGroupSpecs: | ||
- replicas: 1 | ||
minReplicas: 1 | ||
maxReplicas: 5 | ||
groupName: small-group | ||
rayStartParams: {} | ||
template: | ||
spec: | ||
containers: | ||
- name: ray-worker | ||
image: rayproject/ray:2.46.0 | ||
resources: | ||
limits: | ||
cpu: "1" | ||
requests: | ||
cpu: "200m" | ||
# SubmitterPodTemplate is the template for the pod that will run the `ray job submit` command against the RayCluster. | ||
# If SubmitterPodTemplate is specified, the first container is assumed to be the submitter container. | ||
# submitterPodTemplate: | ||
# spec: | ||
# restartPolicy: Never | ||
# containers: | ||
# - name: my-custom-rayjob-submitter-pod | ||
# image: rayproject/ray:2.46.0 | ||
# # If Command is not specified, the correct command will be supplied at runtime using the RayJob spec `entrypoint` field. | ||
# # Specifying Command is not recommended. | ||
# # command: ["sh", "-c", "ray job submit --address=http://$RAY_DASHBOARD_ADDRESS --submission-id=$RAY_JOB_SUBMISSION_ID -- echo hello world"] | ||
|
||
|
||
######################Ray code sample################################# | ||
# this sample is from https://docs.ray.io/en/latest/cluster/job-submission.html#quick-start-example | ||
# it is mounted into the container and executed to show the Ray job at work | ||
--- | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: ray-job-code-sample | ||
data: | ||
sample_code.py: | | ||
import ray | ||
import os | ||
import requests | ||
|
||
ray.init() | ||
|
||
@ray.remote | ||
class Counter: | ||
def __init__(self): | ||
# Used to verify runtimeEnv | ||
self.name = os.getenv("counter_name") | ||
assert self.name == "test_counter" | ||
self.counter = 0 | ||
|
||
def inc(self): | ||
self.counter += 1 | ||
|
||
def get_counter(self): | ||
return "{} got {}".format(self.name, self.counter) | ||
|
||
counter = Counter.remote() | ||
|
||
for _ in range(5): | ||
ray.get(counter.inc.remote()) | ||
print(ray.get(counter.get_counter.remote())) | ||
|
||
# Verify that the correct runtime env was used for the job. | ||
assert requests.__version__ == "2.26.0" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.