Skip to content

Commit eebba25

Browse files
jmhsiehclaude
andauthored
docs: update default ExitMode to DELETE_AFTER_JOBS (#170)
- Default on_exit changed from DELETE to DELETE_AFTER_JOBS - Document new wait_timeout parameter - Move Exit Modes section under KubeRay since it only applies there Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 9ebafcc commit eebba25

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

docs/geneva/jobs/contexts.mdx

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,37 @@ See the API docs for all the parameters [`GenevaCluster.create_kuberay()`](https
9797

9898
</CodeGroup>
9999

100+
#### Exit Modes
101+
102+
By default, the KubeRay cluster waits for all running jobs to complete before deleting. You can customize this behavior with the `on_exit` parameter:
103+
104+
```python Python icon="python"
105+
from geneva.runners.ray.raycluster import ExitMode
106+
107+
with db.context(cluster=cluster_name, manifest=manifest_name, on_exit=ExitMode.DELETE_AFTER_JOBS):
108+
fut1 = tbl.backfill_async("embedding_a")
109+
fut2 = tbl.backfill_async("embedding_b")
110+
# No need to call .result() — the context waits for both jobs
111+
# Both jobs completed; cluster deleted
112+
```
113+
114+
| Exit Mode | Behavior |
115+
|-----------|----------|
116+
| `ExitMode.DELETE_AFTER_JOBS` (default) | Wait for all async jobs to complete, then delete. Ideal for batch scripts using `backfill_async()`. |
117+
| `ExitMode.DELETE` | Always delete the cluster immediately on exit, without waiting for running jobs. |
118+
| `ExitMode.DELETE_ON_SUCCESS` | Delete on success; retain if an exception occurred. Useful for debugging. |
119+
| `ExitMode.RETAIN` | Never delete the cluster. Useful for notebooks and interactive sessions. |
120+
121+
<Tip>
122+
`DELETE_AFTER_JOBS` is the default — the cluster stays alive until all running jobs have finished, then cleans itself up automatically. You can set a `wait_timeout` (in seconds) to cap how long the cluster waits before deleting:
123+
124+
```python Python icon="python"
125+
with db.context(cluster=cluster_name, on_exit=ExitMode.DELETE_AFTER_JOBS, wait_timeout=300):
126+
fut = tbl.backfill_async("embedding")
127+
# Waits up to 5 minutes for jobs, then deletes regardless
128+
```
129+
</Tip>
130+
100131
### External Ray cluster
101132
If you already have a Ray cluster, Geneva can execute jobs against it too. You do so by defining a Geneva cluster with [`GenevaCluster.create_external()`](https://lancedb.github.io/geneva/api/cluster/#geneva.cluster.mgr.GenevaCluster.create_external) which has the address of the cluster. Here's an example:
102133

@@ -266,7 +297,7 @@ with db.context(cluster=cluster_name, manifest=manifest_name):
266297
```
267298
</CodeGroup>
268299

269-
In a notebook environment, you can manually enter and exit the context manager in multiple steps like so:
300+
In a notebook environment, you can manually enter and exit the context manager in multiple steps like so:
270301

271302
<CodeGroup>
272303
```python Python icon="python"

0 commit comments

Comments
 (0)