Skip to content

Commit 93aa81b

Browse files
carsonmhopenshift-merge-robot
authored andcommitted
add and implement option to not generate appwrapper in a Cluster
1 parent 91a46c9 commit 93aa81b

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

Diff for: src/codeflare_sdk/cluster/cluster.py

+14-7
Original file line numberDiff line numberDiff line change
@@ -50,21 +50,25 @@ class Cluster:
5050

5151
torchx_scheduler = "ray"
5252

53-
def __init__(self, config: ClusterConfiguration):
53+
def __init__(self, config: ClusterConfiguration, generate_app_wrapper: bool = True):
5454
"""
5555
Create the resource cluster object by passing in a ClusterConfiguration
5656
(defined in the config sub-module). An AppWrapper will then be generated
5757
based off of the configured resources to represent the desired cluster
5858
request.
5959
"""
6060
self.config = config
61-
self.app_wrapper_yaml = self.create_app_wrapper()
62-
self.app_wrapper_name = self.app_wrapper_yaml.split(".")[0]
61+
self.app_wrapper_yaml = None
62+
self.app_wrapper_name = None
63+
64+
if generate_app_wrapper:
65+
self.app_wrapper_yaml = self.create_app_wrapper()
66+
self.app_wrapper_name = self.app_wrapper_yaml.split(".")[0]
6367

6468
def create_app_wrapper(self):
6569
"""
66-
Called upon cluster object creation, creates an AppWrapper yaml based on
67-
the specifications of the ClusterConfiguration.
70+
Called upon cluster object creation if generate_app_wrapper is True, creates an AppWrapper yaml
71+
based on the specifications of the ClusterConfiguration.
6872
"""
6973

7074
if self.config.namespace is None:
@@ -115,6 +119,9 @@ def up(self):
115119
Applies the AppWrapper yaml, pushing the resource request onto
116120
the MCAD queue.
117121
"""
122+
if self.app_wrapper_yaml is None:
123+
print("Error putting up RayCluster: AppWrapper yaml not generated")
124+
return
118125
namespace = self.config.namespace
119126
try:
120127
config_check()
@@ -145,7 +152,7 @@ def down(self):
145152
version="v1beta1",
146153
namespace=namespace,
147154
plural="appwrappers",
148-
name=self.app_wrapper_name,
155+
name=self.config.name,
149156
)
150157
except Exception as e: # pragma: no cover
151158
return _kube_api_error_handling(e)
@@ -346,7 +353,7 @@ def from_k8_cluster_object(rc):
346353
]["image"],
347354
local_interactive=local_interactive,
348355
)
349-
return Cluster(cluster_config)
356+
return Cluster(cluster_config, False)
350357

351358
def from_definition_yaml(yaml_path):
352359
try:

Diff for: tests/unit_test.py

-1
Original file line numberDiff line numberDiff line change
@@ -2656,7 +2656,6 @@ def test_cleanup():
26562656
os.remove("unit-test-default-cluster.yaml")
26572657
os.remove("test.yaml")
26582658
os.remove("raytest2.yaml")
2659-
os.remove("quicktest.yaml")
26602659
os.remove("tls-cluster-namespace/ca.crt")
26612660
os.remove("tls-cluster-namespace/tls.crt")
26622661
os.remove("tls-cluster-namespace/tls.key")

0 commit comments

Comments
 (0)