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