Skip to content

add and implement option to not generate appwrapper in a Cluster #295

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
merged 3 commits into from
Aug 10, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions src/codeflare_sdk/cluster/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,25 @@ class Cluster:

torchx_scheduler = "ray"

def __init__(self, config: ClusterConfiguration):
def __init__(self, config: ClusterConfiguration, generate_app_wrapper: bool = True):
"""
Create the resource cluster object by passing in a ClusterConfiguration
(defined in the config sub-module). An AppWrapper will then be generated
based off of the configured resources to represent the desired cluster
request.
"""
self.config = config
self.app_wrapper_yaml = self.create_app_wrapper()
self.app_wrapper_name = self.app_wrapper_yaml.split(".")[0]
self.app_wrapper_yaml = None
self.app_wrapper_name = None

if generate_app_wrapper:
self.app_wrapper_yaml = self.create_app_wrapper()
self.app_wrapper_name = self.app_wrapper_yaml.split(".")[0]

def create_app_wrapper(self):
"""
Called upon cluster object creation, creates an AppWrapper yaml based on
the specifications of the ClusterConfiguration.
Called upon cluster object creation if generate_app_wrapper is True, creates an AppWrapper yaml
based on the specifications of the ClusterConfiguration.
"""

if self.config.namespace is None:
Expand Down Expand Up @@ -115,6 +119,9 @@ def up(self):
Applies the AppWrapper yaml, pushing the resource request onto
the MCAD queue.
"""
if self.app_wrapper_yaml is None:
print("Error putting up RayCluster: AppWrapper yaml not generated")
return
namespace = self.config.namespace
try:
config_check()
Expand Down Expand Up @@ -145,7 +152,7 @@ def down(self):
version="v1beta1",
namespace=namespace,
plural="appwrappers",
name=self.app_wrapper_name,
name=self.config.name,
)
except Exception as e: # pragma: no cover
return _kube_api_error_handling(e)
Expand Down Expand Up @@ -346,7 +353,7 @@ def from_k8_cluster_object(rc):
]["image"],
local_interactive=local_interactive,
)
return Cluster(cluster_config)
return Cluster(cluster_config, False)

def from_definition_yaml(yaml_path):
try:
Expand Down
1 change: 0 additions & 1 deletion tests/unit_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2518,7 +2518,6 @@ def test_cleanup():
os.remove("unit-test-default-cluster.yaml")
os.remove("test.yaml")
os.remove("raytest2.yaml")
os.remove("quicktest.yaml")
os.remove("tls-cluster-namespace/ca.crt")
os.remove("tls-cluster-namespace/tls.crt")
os.remove("tls-cluster-namespace/tls.key")
Expand Down