Skip to content

Check for dashboard readiness after cluster is ready #356

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
Show file tree
Hide file tree
Changes from all commits
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
25 changes: 19 additions & 6 deletions src/codeflare_sdk/cluster/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ def is_dashboard_ready(self) -> bool:
else:
return False

def wait_ready(self, timeout: Optional[int] = None):
def wait_ready(self, timeout: Optional[int] = None, dashboard_check: bool = True):
"""
Waits for requested cluster to be ready, up to an optional timeout (s).
Checks every five seconds.
Expand All @@ -274,19 +274,32 @@ def wait_ready(self, timeout: Optional[int] = None):
dashboard_ready = False
status = None
time = 0
while not ready or not dashboard_ready:
while not ready:
status, ready = self.status(print_to_console=False)
dashboard_ready = self.is_dashboard_ready()
if status == CodeFlareClusterStatus.UNKNOWN:
print(
"WARNING: Current cluster status is unknown, have you run cluster.up yet?"
)
if not ready or not dashboard_ready:
if not ready:
if timeout and time >= timeout:
raise TimeoutError(
f"wait() timed out after waiting {timeout}s for cluster to be ready"
)
sleep(5)
time += 5
print("Requested cluster is up and running!")

while dashboard_check and not dashboard_ready:
dashboard_ready = self.is_dashboard_ready()
if not dashboard_ready:
if timeout and time >= timeout:
raise TimeoutError(f"wait() timed out after waiting {timeout}s")
raise TimeoutError(
f"wait() timed out after waiting {timeout}s for dashboard to be ready"
)
sleep(5)
time += 5
print("Requested cluster and dashboard are up and running!")
if dashboard_ready:
print("Dashboard is ready!")

def details(self, print_to_console: bool = True) -> RayCluster:
cluster = _copy_to_ray(self)
Expand Down
8 changes: 7 additions & 1 deletion tests/unit_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1794,7 +1794,13 @@ def test_wait_ready(mocker, capsys):
captured = capsys.readouterr()
assert (
captured.out
== "Waiting for requested resources to be set up...\nRequested cluster and dashboard are up and running!\n"
== "Waiting for requested resources to be set up...\nRequested cluster is up and running!\nDashboard is ready!\n"
)
cf.wait_ready(dashboard_check=False)
captured = capsys.readouterr()
assert (
captured.out
== "Waiting for requested resources to be set up...\nRequested cluster is up and running!\n"
)


Expand Down