Skip to content

Commit 5d0c98d

Browse files
authored
📖 simplify README.md, improve docs (#238)
1 parent d360ad8 commit 5d0c98d

10 files changed

Lines changed: 78 additions & 89 deletions

File tree

README.md

Lines changed: 19 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
**Ray integration for Dagster.**
1414

15-
`dagster-ray` enables you to orchestrate distributed Ray compute from Dagster pipelines, providing seamless integration between Dagster's orchestration capabilities and Ray's distributed computing power.
15+
`dagster-ray` enables working with distributed Ray compute from Dagster pipelines, combining Dagster's excellent orchestration capabilities and Ray's distributed computing power together.
1616

1717
> [!NOTE]
1818
> This project is ready for production use, but some APIs may change between minor releases.
@@ -21,79 +21,31 @@ Learn more in the [docs](https://danielgafni.github.io/dagster-ray)
2121

2222
## 🚀 Key Features
2323

24-
- **Run Launchers & Executors**: Submit Dagster runs or individual ops as Ray jobs
25-
- **Ray Resources**: Manage Ray clusters with Kubernetes (KubeRay) or local backends, connect to them in client mode
26-
- **Dagster Pipes**: Execute external Ray scripts with rich logging and metadata
27-
- **Production Ready**: Tested against a matrix of core dependencies and platform versions, integrated with Dagster+
24+
- **🎯 Run Launchers & Executors**: Submit Dagster runs or individual steps by submitting Ray jobs
25+
- **🔧 Ray Resources**: Automatically create and destroy ephemeral Ray clusters and connect to them in client mode
26+
- **📡 Dagster Pipes Integration**: Submit external scripts as Ray jobs, stream back logs and rich Dagster metadata
27+
- **☸️ KubeRay Support**: Utilize `RayJob` and `RayCluster` custom resources in client or job submission mode ([tutorial](tutorial/kuberay.md))
28+
- **🏭 Production Ready**: Tested against a matrix of core dependencies, integrated with Dagster+
2829

29-
## 📦 Quick Start
30-
31-
### Installation
30+
## Installation
3231

3332
```shell
3433
pip install dagster-ray
3534
```
3635

37-
### Example
38-
39-
Define a Dagster asset that uses Ray in client mode
40-
```python
41-
import dagster as dg
42-
from dagster_ray import RayResource
43-
import ray
44-
45-
46-
@ray.remote
47-
def compute_square(x: int) -> int:
48-
return x**2
49-
50-
51-
@dg.asset
52-
def my_distributed_computation(ray_cluster: RayResource) -> int:
53-
futures = [compute_square.remote(i) for i in range(10)]
54-
return sum(ray.get(futures))
55-
```
56-
57-
Now use `LocalRay` for local development and swap it with a thick cluster in Kubernetes!
58-
59-
```python
60-
from dagster_ray.kuberay import in_k8s, KubeRayInteractiveJob
61-
62-
ray_cluster = LocalRay() if not in_k8s else KubeRayInteractiveJob()
63-
64-
definitions = dg.Definitions(
65-
assets=[my_distributed_computation],
66-
resources={"ray_cluster": ray_cluster},
67-
)
68-
```
69-
70-
Learn more by reading the [tutorials](https://danielgafni.github.io/dagster-ray/tutorial).
71-
7236
## 📚 Docs
7337

7438
**📖 [Full Documentation](https://danielgafni.github.io/dagster-ray)**
7539

7640
- **[Tutorial](https://danielgafni.github.io/dagster-ray/tutorial/)**: Step-by-step guide with examples
77-
- **[API Reference](https://danielgafni.github.io/dagster-ray/api/)**: Complete API documentation
78-
79-
## 🛠️ Integration Options
80-
81-
| Component | Use Case | Cluster Management | Ray Mode |
82-
|-----------|----------|-------------------|------|
83-
| `RayRunLauncher` | Deployment-wide Ray runtime | External | Job Mode |
84-
| `ray_executor` | Ray runtime scoped to a Code Location | External | Job Mode |
85-
| `PipesRayJobClient` | Submit external scripts as Ray jobs | External | Job Mode |
86-
| `PipesKubeRayJobClient` | Submit an external script as a `RayJob`, forward logs and Dagster metadata | Automatic | Job Mode |
87-
| `KubeRayInteractiveJob` | Create a `RayJob`, connect in Client mode without an external script | Automatic | Client Mode |
41+
- **[API Reference](https://danielgafni.github.io/dagster-ray/api/)**: Complete API reference
8842

8943
## 🤝 Contributing
9044

9145
Contributions are very welcome! To get started:
9246

9347
```bash
94-
git clone https://github.com/danielgafni/dagster-ray.git
95-
cd dagster-ray
96-
uv sync --all-extras
48+
uv sync --all-extras --all-groups
9749
uv run pre-commit install
9850
```
9951

@@ -104,7 +56,16 @@ uv run pytest
10456
```
10557

10658
Running KubeRay tests requires the following tools to be present:
107-
- `docker`, `kubectl`, `helm`, `minikube`
59+
- `docker`
60+
- `kubectl`
61+
- `helm`
62+
- `minikube`
63+
64+
❄️ Nix users will find them provided in the dev shell:
65+
66+
```
67+
nix develop
68+
```
10869

10970
### Documentation
11071

@@ -113,9 +74,4 @@ To build and serve the documentation locally:
11374
```bash
11475
# Serve documentation locally
11576
uv run --group docs mkdocs serve
116-
117-
# Build documentation
118-
uv run--group docs mkdocs build
11977
```
120-
121-
The documentation is automatically deployed to GitHub Pages.

docs/index.md

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,30 @@
1-
# Welcome to dagster-ray
2-
3-
**Ray integration for Dagster** - Orchestrate distributed Ray compute from Dagster pipelines with seamless integration between Dagster's orchestration capabilities and Ray's distributed computing power.
1+
# Welcome to `dagster-ray` docs
42

53
[![PyPI version](https://img.shields.io/pypi/v/dagster-ray.svg)](https://pypi.python.org/pypi/dagster-ray)
64
[![License](https://img.shields.io/pypi/l/dagster-ray.svg)](https://pypi.python.org/pypi/dagster-ray)
75
[![Python versions](https://img.shields.io/pypi/pyversions/dagster-ray.svg)](https://pypi.python.org/pypi/dagster-ray)
86
[![CI](https://github.com/danielgafni/dagster-ray/actions/workflows/CI.yml/badge.svg)](https://github.com/danielgafni/dagster-ray/actions/workflows/CI.yml)
7+
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit)
8+
[![basedpyright - checked](https://img.shields.io/badge/basedpyright-checked-42b983)](https://docs.basedpyright.com)
9+
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
10+
11+
---
12+
13+
**Ray integration for Dagster.**
14+
15+
16+
`dagster-ray` enables working with distributed Ray compute from Dagster pipelines, combining Dagster's excellent orchestration capabilities and Ray's distributed computing power together.
17+
918

1019
> [!NOTE]
1120
> This project is ready for production use, but some APIs may change between minor releases.
1221
1322
## 🚀 Key Features
1423

15-
- **🎯 Run Launchers & Executors**: Submit Dagster runs or individual steps as Ray jobs
16-
- **🔧 Ray Resources**: Connect to Ray cluster in client mode and manage their lifecycle
17-
- **📡 Dagster Pipes Integration**: Execute external Ray scripts with rich logging and metadata
18-
- **☸️ KubeRay Support**: Utilize `RayJob` and `RayCluster` custom resources in client or job mode ([tutorial](tutorial/kuberay.md))
24+
- **🎯 Run Launchers & Executors**: Submit Dagster runs or individual steps by submitting Ray jobs
25+
- **🔧 Ray Resources**: Automatically create and destroy ephemeral Ray clusters and connect to them in client mode
26+
- **📡 Dagster Pipes Integration**: Submit external scripts as Ray jobs, stream back logs and rich Dagster metadata
27+
- **☸️ KubeRay Support**: Utilize `RayJob` and `RayCluster` custom resources in client or job submission mode ([tutorial](tutorial/kuberay.md))
1928
- **🏭 Production Ready**: Tested against a matrix of core dependencies, integrated with Dagster+
2029

2130
## ⚡ Quick Start
@@ -27,14 +36,31 @@
2736
pip install dagster-ray
2837
```
2938

39+
!!! tip
40+
See [external cluster tutorial](tutorial/external.md)
41+
3042
=== "With KubeRay"
3143
```bash
3244
pip install 'dagster-ray[kuberay]'
3345
```
3446

47+
!!! tip
48+
See [KubeRay tutorial](tutorial/kuberay.md)
49+
3550
### Basic Usage
51+
#### Execute Dagster steps on an existing Ray cluster
52+
!!! example
53+
```python
54+
import dagster as dg
55+
from dagster_ray import ray_executor
56+
57+
defs = dg.Definitions(..., executor=ray_executor)
58+
```
3659

60+
#### Execute an asset on Ray in client mode
3761
!!! example
62+
63+
3864
Define a Dagster asset that uses Ray in client mode
3965
```python
4066
import dagster as dg
@@ -56,9 +82,10 @@
5682
1. :zap: I am already running in Ray!
5783
2. :bulb: `RayResource` is a type annotation that provides a common interface for Ray resources
5884

59-
Now use `LocalRay` for local development and swap it with a thick cluster in Kubernetes!
85+
Now use [`LocalRay`](api/core.md#dagster_ray.core.resources.LocalRay) for development and swap it with a thick cluster in Kubernetes!
6086

6187
```python
88+
from dagster_ray import LocalRay
6289
from dagster_ray.kuberay import in_k8s, KubeRayInteractiveJob
6390

6491
ray_cluster = LocalRay() if not in_k8s else KubeRayInteractiveJob()
@@ -69,6 +96,8 @@
6996
)
7097
```
7198

99+
[`KubeRayInteractiveJob`](api/kuberay.md#dagster_ray.kuberay.KubeRayInteractiveJob) will create a `RayJob`, connect to it, and optionally perform cleanup according to the configured policy.
100+
72101
Learn more by reading the [tutorials](tutorial/index.md).
73102

74103
## 🛠️ Choosing Your Integration
@@ -118,6 +147,7 @@ Learn more by reading the [tutorials](tutorial/index.md).
118147

119148
!!! tip
120149
See [KubeRay tutorial](tutorial/kuberay.md)
150+
121151
## 📚 What's Next?
122152

123153
<div class="grid cards" markdown>

flake.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
UV_PYTHON = "${python}/bin/python";
3636
shellHook = ''
3737
uv venv --allow-existing
38-
uv sync --frozen --all-extras
38+
uv sync --frozen --all-extras --all-groups
3939
'';
4040
};
4141
};

mkdocs.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,3 +177,6 @@ validation:
177177
absolute_links: warn # Or 'relative_to_docs' - new in MkDocs 1.6
178178
unrecognized_links: warn
179179
anchors: warn # New in MkDocs 1.6
180+
181+
watch:
182+
- src

src/dagster_ray/_base/resources.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,19 +82,19 @@ def my_asset(ray_cluster: RayResource):
8282
)
8383
enable_tracing: bool = Field(
8484
default=False,
85-
description="Enable tracing: inject `RAY_PROFILING=1` and `RAY_task_events_report_interval_ms=0` into the Ray cluster configuration. This allows using `ray.timeline()` to fetch recorded task events. Learn more: https://docs.ray.io/en/latest/ray-core/api/doc/ray.timeline.html#ray-timeline",
85+
description="Enable tracing: inject `RAY_PROFILING=1` and `RAY_task_events_report_interval_ms=0` into the Ray cluster configuration. This allows using `ray.timeline()` to fetch recorded task events. Learn more: [KubeRay docs](https://docs.ray.io/en/latest/ray-core/api/doc/ray.timeline.html#ray-timeline)",
8686
)
8787
enable_actor_task_logging: bool = Field(
8888
default=False,
8989
description="Enable actor task logging: inject `RAY_ENABLE_RECORD_ACTOR_TASK_LOGGING=1` into the Ray cluster configuration.",
9090
)
9191
enable_debug_post_mortem: bool = Field(
9292
default=False,
93-
description="Enable post-mortem debugging: inject `RAY_DEBUG_POST_MORTEM=1` into the Ray cluster configuration. Learn more: https://docs.ray.io/en/latest/ray-observability/ray-distributed-debugger.html",
93+
description="Enable post-mortem debugging: inject `RAY_DEBUG_POST_MORTEM=1` into the Ray cluster configuration. Learn more: [KubeRay docs](https://docs.ray.io/en/latest/ray-observability/ray-distributed-debugger.html)",
9494
)
9595
enable_legacy_debugger: bool = Field(
9696
default=False,
97-
description="Enable legacy debugger: inject `RAY_DEBUG=legacy` into the Ray cluster configuration. Learn more: https://docs.ray.io/en/latest/ray-observability/user-guides/debug-apps/ray-debugging.html#using-the-ray-debugger",
97+
description="Enable legacy debugger: inject `RAY_DEBUG=legacy` into the Ray cluster configuration. Learn more: [KubeRay docs](https://docs.ray.io/en/latest/ray-observability/user-guides/debug-apps/ray-debugging.html#using-the-ray-debugger)",
9898
)
9999

100100
_context: RayBaseContext | None = PrivateAttr()

src/dagster_ray/core/executor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def ray_executor(init_context: InitExecutorContext) -> Executor:
6363
"""Executes steps by submitting them as Ray jobs.
6464
6565
The steps are started inside the Ray cluster directly.
66-
When used together with the `RayRunLauncher`, the executor can inherit the job submission client configuration.
66+
When used together with [`RayRunLauncher`][dagster_ray.core.run_launcher.RayRunLauncher], the executor can inherit the job submission client configuration.
6767
This behavior can be disabled by setting `inherit_job_submission_client_from_ray_run_launcher` to `False`.
6868
6969
Example:

src/dagster_ray/core/pipes.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,10 +223,10 @@ class PipesRayJobClient(dg.PipesClient, TreatAsResourceParam):
223223
Args:
224224
client (JobSubmissionClient): The Ray job submission client
225225
context_injector (Optional[PipesContextInjector]): A context injector to use to inject
226-
context into the Ray job. Defaults to `PipesEnvContextInjector`.
226+
context into the Ray job. Defaults to [`PipesEnvContextInjector`][dagster.PipesEnvContextInjector].
227227
message_reader (Optional[PipesMessageReader]): A message reader to use to read messages
228-
from the glue job run. Defaults to `PipesRayJobMessageReader`.
229-
forward_termination (bool): Whether to cancel the `RayJob` job run when the Dagster process receives a termination signal.
228+
from the glue job run. Defaults to [`PipesRayJobMessageReader`][dagster_ray.core.pipes.PipesRayJobMessageReader].
229+
forward_termination (bool): Whether to cancel the Ray job run when the Dagster process receives a termination signal.
230230
timeout (int): Timeout for various internal interactions with the Kubernetes RayJob.
231231
poll_interval (int): Interval at which to poll Kubernetes for status updates.
232232
Is useful when running in a local environment.

src/dagster_ray/kuberay/pipes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ class PipesKubeRayJobClient(dg.PipesClient, TreatAsResourceParam):
3838
3939
Args:
4040
context_injector (Optional[PipesContextInjector]): A context injector to use to inject
41-
context into the ``RayJob``. Defaults to `PipesEnvContextInjector`.
41+
context into the ``RayJob``. Defaults to [`PipesEnvContextInjector`][dagster.PipesEnvContextInjector].
4242
message_reader (Optional[PipesMessageReader]): A message reader to use to read messages
43-
from the glue job run. Defaults to `PipesRayJobMessageReader`.
43+
from the glue job run. Defaults to [`PipesRayJobMessageReader`][dagster_ray.core.pipes.PipesRayJobMessageReader].
4444
client (Optional[boto3.client]): The Kubernetes API client.
4545
forward_termination (bool): Whether to terminate the Ray job when the Dagster process receives a termination signal,
4646
or if the startup timeout is reached. Defaults to ``True``.

src/dagster_ray/kuberay/resources/raycluster.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ def create_resource(self, context: dg.InitResourceContext) -> RayClusterClient:
2626

2727
class KubeRayCluster(BaseKubeRayResourceConfig, RayResource):
2828
"""
29-
Provides a `RayCluster` for Dagster steps.
29+
Provides a Ray Cluster for Dagster steps.
3030
31-
It is advised to use `dagster_ray.kuberay.KubeRayInteractiveJob` with KubeRay >= 1.3.0 instead.
31+
It is advised to use [`KubeRayInteractiveJob`][dagster_ray.kuberay.resources.KubeRayInteractiveJob] with KubeRay >= 1.3.0 instead.
3232
3333
Info:
3434
Image defaults to `dagster/image` run tag.
@@ -49,7 +49,7 @@ class KubeRayCluster(BaseKubeRayResourceConfig, RayResource):
4949
)
5050
log_cluster_conditions: bool = Field(
5151
default=True,
52-
description="Whether to log RayCluster conditions while waiting for the RayCluster to become ready. For more information, see https://docs.ray.io/en/latest/cluster/kubernetes/user-guides/observability.html#raycluster-status-conditions.",
52+
description="Whether to log RayCluster conditions while waiting for the RayCluster to become ready. Learn more: [KubeRay docs](https://docs.ray.io/en/latest/cluster/kubernetes/user-guides/observability.html#raycluster-status-conditions).",
5353
)
5454

5555
_name: str = PrivateAttr()

src/dagster_ray/kuberay/resources/rayjob.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,22 +32,22 @@ def create_resource(self, context: dg.InitResourceContext):
3232

3333

3434
class InteractiveRayJobSpec(RayJobSpec):
35-
"""Same as `dagster_ray.kuberay.resources.rayjob.RayJobSpec`, but submission mode has to be `InteractiveMode`"""
35+
"""Same as [`RayJobSpec`][dagster_ray.kuberay.configs.RayJobSpec], but `mode` has to be `InteractiveMode`"""
3636

3737
submission_mode: Literal["InteractiveMode"] = "InteractiveMode" # pyright: ignore[reportIncompatibleVariableOverride]
3838

3939

4040
class InteractiveRayJobConfig(RayJobConfig):
41-
"""Same as `dagster_ray.kuberay.resources.rayjob.RayJobConfig`, but `spec.submission_mode` mode has to be `InteractiveMode`"""
41+
"""Same as [`RayJobConfig`][dagster_ray.kuberay.configs.RayJobConfig], but `spec.submission_mode` mode has to be `InteractiveMode`"""
4242

4343
spec: InteractiveRayJobSpec = Field(default_factory=InteractiveRayJobSpec) # pyright: ignore[reportIncompatibleVariableOverride]
4444

4545

4646
class KubeRayInteractiveJob(RayResource, BaseKubeRayResourceConfig):
4747
"""
48-
Provides a `RayJob` for Dagster steps.
48+
Provides a Ray Job for Dagster steps.
4949
50-
Is the recommended way to run Ray workloads with automatic cluster management. It creates a `RayJob`, connects to it in client mode and sets the `jobId` field. Cleanup is handled by the KubeRay controller or by the resource lifecycle logic.
50+
Is the recommended way to run Ray workloads with automatic cluster management. It creates a Ray Job, connects to it in client mode and sets the `jobId` field. Cleanup is handled by the KubeRay controller or by the resource lifecycle logic.
5151
5252
Info:
5353
Image defaults to `dagster/image` run tag.
@@ -72,7 +72,7 @@ class KubeRayInteractiveJob(RayResource, BaseKubeRayResourceConfig):
7272

7373
log_cluster_conditions: bool = Field(
7474
default=True,
75-
description="Whether to log `RayCluster` conditions while waiting for the RayCluster to become ready. For more information, see https://docs.ray.io/en/latest/cluster/kubernetes/user-guides/observability.html#raycluster-status-conditions.",
75+
description="Whether to log `RayCluster` conditions while waiting for the RayCluster to become ready. Learn more: [KubeRay docs](https://docs.ray.io/en/latest/cluster/kubernetes/user-guides/observability.html#raycluster-status-conditions).",
7676
)
7777

7878
_name: str = PrivateAttr()

0 commit comments

Comments
 (0)