-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create a Ray Cluster SDK upgrade scenarios
- Loading branch information
1 parent
db25cd3
commit 65ed743
Showing
7 changed files
with
548 additions
and
42 deletions.
There are no files selected for viewing
This file contains 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 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 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 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,46 @@ | ||
import sys | ||
|
||
from time import sleep | ||
|
||
from torchx.specs.api import AppState, is_terminal | ||
|
||
from codeflare_sdk.cluster.cluster import get_cluster | ||
from codeflare_sdk.job.jobs import DDPJobDefinition | ||
|
||
namespace = sys.argv[1] | ||
|
||
cluster = get_cluster("mnist", namespace) | ||
|
||
cluster.details() | ||
|
||
jobdef = DDPJobDefinition( | ||
name="mnist", | ||
script="mnist.py", | ||
scheduler_args={"requirements": "requirements.txt"}, | ||
) | ||
job = jobdef.submit(cluster) | ||
|
||
done = False | ||
time = 0 | ||
timeout = 900 | ||
while not done: | ||
status = job.status() | ||
if is_terminal(status.state): | ||
break | ||
if not done: | ||
print(status) | ||
if timeout and time >= timeout: | ||
raise TimeoutError(f"job has timed out after waiting {timeout}s") | ||
sleep(5) | ||
time += 5 | ||
|
||
print(f"Job has completed: {status.state}") | ||
|
||
print(job.logs()) | ||
|
||
cluster.down() | ||
|
||
if not status.state == AppState.SUCCEEDED: | ||
exit(1) | ||
else: | ||
exit(0) |
This file contains 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,52 @@ | ||
import sys | ||
import os | ||
|
||
from time import sleep | ||
|
||
from codeflare_sdk.cluster.cluster import Cluster, ClusterConfiguration | ||
|
||
namespace = sys.argv[1] | ||
ray_image = os.getenv("RAY_IMAGE") | ||
host = os.getenv("CLUSTER_HOSTNAME") | ||
|
||
ingress_options = {} | ||
if host is not None: | ||
ingress_options = { | ||
"ingresses": [ | ||
{ | ||
"ingressName": "ray-dashboard", | ||
"port": 8265, | ||
"pathType": "Prefix", | ||
"path": "/", | ||
"host": host, | ||
}, | ||
] | ||
} | ||
|
||
cluster = Cluster( | ||
ClusterConfiguration( | ||
name="mnist", | ||
namespace=namespace, | ||
num_workers=1, | ||
head_cpus="500m", | ||
head_memory=2, | ||
min_cpus="500m", | ||
max_cpus=1, | ||
min_memory=1, | ||
max_memory=2, | ||
num_gpus=0, | ||
instascale=False, | ||
image=ray_image, | ||
ingress_options=ingress_options, | ||
) | ||
) | ||
|
||
cluster.up() | ||
|
||
cluster.status() | ||
|
||
cluster.wait_ready() | ||
|
||
cluster.status() | ||
|
||
cluster.details() |
This file contains 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.