Skip to content

Commit e827184

Browse files
committed
docs: enhance currently existing documentation create new documentation for ray clusters and ui widgets
Signed-off-by: Bobbins228 <[email protected]>
1 parent 8537c2d commit e827184

6 files changed

+130
-3
lines changed

docs/authentication.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Authenticating with your cluster allows you to perform actions such as creating
44

55
## Method 1 Token Authentication
66
This is how a typical user would authenticate to their cluster using `TokenAuthentication`.
7-
```
7+
``` python
88
from codeflare_sdk import TokenAuthentication
99

1010
auth = TokenAuthentication(
@@ -26,7 +26,7 @@ If the user has not specifically authenticated through the SDK by other means su
2626
## Method 3 Specifying a Kubernetes Config File
2727
A user can specify a config file via a different authentication class `KubeConfigFileAuthentication` for authenticating with the SDK.<br>
2828
This is what loading a custom config file would typically look like.
29-
```
29+
``` python
3030
from codeflare_sdk import KubeConfigFileAuthentication
3131

3232
auth = KubeConfigFileAuthentication(

docs/cluster-configuration.md

+32-1
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,40 @@ The `labels={"exampleLabel": "example"}` parameter can be used to apply addition
3131

3232
After creating their `cluster`, a user can call `cluster.up()` and `cluster.down()` to respectively create or remove the Ray Cluster.
3333

34+
## Parameters of the `ClusterConfiguration`
35+
Below is a table explaining each of the `ClusterConfiguration` parameters and their default values.
36+
| Name | Type | Description | Default |
37+
| :--------- | :-------- | :-------- | :-------- |
38+
| `name` | `str` | The name of the Ray Cluster/AppWrapper | Required - No default |
39+
| `namespace` | `Optional[str]` | The namespace of the Ray Cluster/AppWrapper | `None` |
40+
| `head_cpu_requests` | `Union[int, str]` | CPU resource requests for the Head Node | `2` |
41+
| `head_cpu_limits` | `Union[int, str]` | CPU resource limits for the Head Node | `2` |
42+
| `head_memory_requests` | `Union[int, str]` | Memory resource requests for the Head Node | `8` |
43+
| `head_memory_limits` | `Union[int, str]` | Memory limits for the Head Node | `8` |
44+
| `head_extended_resource_requests` | `Dict[str, Union[str, int]]` | Extended resource requests for the Head Node see example above | `{}` |
45+
| `worker_cpu_requests` | `Union[int, str]` | CPU resource requests for the Worker Node | `1` |
46+
| `worker_cpu_limits` | `Union[int, str]` | CPU resource limits for the Worker Node | `1` |
47+
| `num_workers` | `int` | Number of Worker Nodes for the Ray Cluster | `1` |
48+
| `worker_memory_requests` | `Union[int, str]` | Memory resource requests for the Worker Node | `8` |
49+
| `worker_memory_limits` | `Union[int, str]` | Memory resource limits for the Worker Node | `8` |
50+
| `appwrapper` | `bool` | A boolean that wraps the Ray Cluster in an AppWrapper when set to True | `False` |
51+
| `envs` | `Dict[str, str]` | A dictionary of environment variables to set for the Ray Cluster | `{}` |
52+
| `image` | `str` | A paramater for specifying the Ray Image | `""` |
53+
| `image_pull_secrets` | `List[str]` | A Parameter for providing a list of Image Pull Secrets | `[]` |
54+
| `write_to_file` | `bool` | A boolean for writing the Ray Cluster as a Yaml file if set to True | `False` |
55+
| `verify_tls` | `bool` | A boolean indicating whether to verify TLS when connecting to the cluster | `True` |
56+
| `labels` | `Dict[str, str]` | A dictionary of labels to apply to the cluster | `{}` |
57+
| `worker_extended_resource_requests` | `Dict[str, Union[str, int]]` | Extended resource requests for the Worker Node see example above | `{}` |
58+
| `extended_resource_mapping` | `Dict[str, str]` | A dictionary of custom resource mappings to map extended resource requests to RayCluster resource names | `{}` |
59+
| `overwrite_default_resource_mapping` | `bool` | A boolean indicating whether to overwrite the default resource mapping | `False` |
60+
| `local_queue` | `Optional[str]` | A parameter for specifying the Local Queue label for the Ray Cluster | `None` |
61+
62+
63+
64+
3465

3566
## Deprecating Parameters
36-
The following parameters of the `ClusterConfiguration` are being deprecated in release `v0.22.0`. <!-- TODO: When removing deprecated parameters update this statement -->
67+
The following parameters of the `ClusterConfiguration` are being deprecated.
3768
| Deprecated Parameter | Replaced By |
3869
| :--------- | :-------- |
3970
| `head_cpus` | `head_cpu_requests`, `head_cpu_limits` |

docs/images/ui-buttons.png

21.9 KB
Loading

docs/images/ui-view-clusters.png

28.1 KB
Loading

docs/ray-cluster-interaction.md

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Ray Cluster Interaction
2+
3+
The CodeFlare SDK offers multiple ways to interact with Ray Clusters including the below methods.
4+
5+
## get_cluster()
6+
The `get_cluster()` function is used to initialise a `Cluster` object from a pre-existing Ray Cluster/AppWrapper. <br>
7+
Below is an example of it's usage:
8+
``` python
9+
from codeflare_sdk import get_cluster
10+
cluster = get_cluster(cluster_name="raytest", namespace="example", is_appwrapper=False, write_to_file=False)
11+
-> output: Yaml resources loaded for raytest
12+
cluster.status()
13+
-> output:
14+
🚀 CodeFlare Cluster Status 🚀
15+
╭─────────────────────────────────────────────────────────────────╮
16+
│ Name │
17+
│ raytest Active ✅ │
18+
│ │
19+
URI: ray://raytest-head-svc.example.svc:10001
20+
│ │
21+
│ Dashboard🔗 │
22+
│ │
23+
╰─────────────────────────────────────────────────────────────────╯
24+
(<CodeFlareClusterStatus.READY: 1>, True)
25+
cluster.down()
26+
cluster.up() # This function will create an exact copy of the retrieved Ray Cluster only if the Ray Cluster has been previously deleted.
27+
```
28+
29+
These are the parameters the `get_cluster()` function accepts:
30+
* `cluster_name: str # Required` -> The name of the Ray Cluster.
31+
* `namespace: str # Default: "default"` -> The namespace of the Ray Cluster.
32+
* `is_appwrapper: bool # Default: False` -> When set to `True` the function will attempt to retrieve an AppWrapper instead of a Ray Cluster.
33+
* `write_to_file: bool # Default: False` -> When set to `True` the Ray Cluster/AppWrapper will be written to a file similar to how it is done in `ClusterConfiguration`.
34+
35+
## list_all_queued()
36+
The `list_all_queued()` function returns (and prints by default) a list of all currently queued-up Ray Clusters in a given namespace.
37+
It accepts the following parameters:
38+
* `namespace: str # Required` -> The namespace you want to retrieve the list from.
39+
* `print_to_console: bool # Default: True` -> Allows the user to print the list to their console.
40+
* `appwrapper: bool # Default: False` -> When set to `True` allows the user to list queued AppWrappers.
41+
42+
43+
44+
## list_all_clusters()
45+
The `list_all_clusters()` function will return a list of detailed descriptions of Ray Clusters to the console by default. It accepts the following parameters:
46+
* `namespace: str # Required` -> The namespace you want to retrieve the list from.
47+
* `print_to_console: bool # Default: True` -> A boolean that allows the user to print the list to their console.
48+
49+
> [!NOTE]
50+
> The following methods require a `Cluster` object to be initialised see [Cluster Configuration](./cluster-configuration.md)
51+
52+
## cluster.up()
53+
The `cluster.up()` function creates a Ray Cluster in the given namespace.
54+
55+
## cluster.down()
56+
The `cluster.down()` function deletes the Ray Cluster in the given namespace.
57+
58+
## cluster.status()
59+
The `cluster.status()` function prints out the status of the Ray Cluster's state with a link to the Ray Dashboard.
60+
61+
## cluster.details()
62+
The `cluster.details()` function prints out a detailed description of the Ray Cluster's status, worker resources and a link to the Ray Dashboard.
63+
64+
## cluster.wait_ready()
65+
The `cluster.wait_ready()` function waits for the requested cluster to be ready, up to an optional timeout and checks every 5 seconds. It accepts the following parameters:
66+
* `timeout: Optional[int] # Default: None` -> Allows the user to define a timeout for the `wait_ready()` function.
67+
* `dashboard_check: bool # Default: True` -> If enabled the `wait_ready()` function will wait until the Ray Dashboard is ready too.

docs/ui-widgets.md

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Jupyter UI Widgets
2+
Below are some examples of the Jupyter UI Widgets that are included in the CodeFlare SDK. <br>
3+
> [!NOTE]
4+
> To use the widgets functionality you must be using the CodeFlare SDK in a Jupyter Notebook environment.
5+
6+
## Cluster Up/Down Buttons
7+
The Cluster Up/Down buttons appear after successfully initialising your [ClusterConfiguration](cluster-configuration.md#ray-cluster-configuration).
8+
There are two buttons and a checkbox `Cluster Up`, `Cluster Down` and `Wait for Cluster?` which mimic the [cluster.up()](ray-cluster-interaction.md#clusterup), [cluster.down()](ray-cluster-interaction.md#clusterdown) and [cluster.wait_ready()](ray-cluster-interaction.md#clusterwait_ready) functionality.
9+
10+
After initialising their `ClusterConfiguration` a user can select the `Wait for Cluster?` checkbox then click the `Cluster Up` button to create their Ray Cluster and wait until it is ready. The cluster can be deleted by clicking the `Cluster Down` button.<br>
11+
12+
<img title="ui buttons" alt="An image of the up/down ui buttons" src="images/ui-buttons.png">
13+
14+
## View Clusters UI Table
15+
The View Clusters UI Table allows a user to see a list of Ray Clusters with information on their configuration including number of workers, CPU requests and limits along with the clusters status.
16+
17+
<img title="view clusters" alt="An image of the view clusters ui table" src="images/ui-view-clusters.png">
18+
19+
Above is a list of two Ray Clusters `raytest` and `raytest2` each of those headings is clickable and will update the table to view the selected Cluster's information.
20+
There are three buttons under the table `Cluster Down`, `View Jobs` and `Open Ray Dashboard`.<br>
21+
* The `Cluster Down` button will delete the selected Cluster.
22+
* The `View Jobs` button will try to open the Ray Dashboard's Jobs view in a Web Browser. The link will also be printed to the console.
23+
* The `Open Ray Dashboard` button will try to open the Ray Dashboard view in a Web Browser. The link will also be printed to the console.
24+
25+
The UI Table can be viewed by calling the following function.
26+
``` python
27+
from codeflare_sdk import view_clusters
28+
view_clusters() # Accepts namespace parameter but will try to gather the namespace from the current context
29+
```

0 commit comments

Comments
 (0)