Repository navigation
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a new tutorial and example code for deploying a FunASR Speech Recognition Model using Ray Serve, exposing an OpenAI-compatible transcription endpoint. The feedback highlights several areas for improvement: addressing a potential temporary file leak if an exception occurs during file writing, preventing Out-Of-Memory (OOM) errors by avoiding unbounded caching of ML models, using torch.cuda.is_available() for more robust GPU detection, and updating the tutorial's installation dependencies to include openai instead of requests.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| suffix = os.path.splitext(filename or "")[1] or ".wav" | ||
| with tempfile.NamedTemporaryFile(suffix=suffix, delete=False) as audio_file: | ||
| audio_file.write(audio_bytes) | ||
| audio_path = audio_file.name | ||
|
|
||
| try: | ||
| model_name = model or self._default_model | ||
| result = self._get_model(model_name).generate( | ||
| input=audio_path, | ||
| language=language or "auto", | ||
| use_itn=True, | ||
| batch_size_s=60, | ||
| merge_vad=True, | ||
| merge_length_s=15, | ||
| ) | ||
| finally: | ||
| os.remove(audio_path) |
There was a problem hiding this comment.
If an exception occurs during audio_file.write(audio_bytes) (for example, due to a disk full error or a disconnected client), the context manager will exit but the temporary file created with delete=False will not be cleaned up, leading to a resource leak.
To prevent leaking temporary files, we should ensure that the file is closed and removed in a finally block that covers the entire lifetime of the temporary file.
suffix = os.path.splitext(filename or "")[1] or ".wav"
audio_file = tempfile.NamedTemporaryFile(suffix=suffix, delete=False)
audio_path = audio_file.name
try:
audio_file.write(audio_bytes)
audio_file.close()
model_name = model or self._default_model
result = self._get_model(model_name).generate(
input=audio_path,
language=language or "auto",
use_itn=True,
batch_size_s=60,
merge_vad=True,
merge_length_s=15,
)
finally:
try:
audio_file.close()
except Exception:
pass
try:
os.remove(audio_path)
except Exception:
passThere was a problem hiding this comment.
Follow-up after rechecking the current 780eb4c head: this edge case is still reproducible. The outer finally only removes names already in audio_paths, but the current path is appended after audio_file.write(audio), so a write failure leaves that file behind. I added a failure-injection regression that went red for the leaked path, then opened nh-atuan#1 with the minimal one-line ordering fix. The same test passes after the change; py_compile, Ruff lint, and git diff --check also pass.
There was a problem hiding this comment.
Thanks for taking another look and for catching this edge case, @LauraGPT.
You're absolutely right, the current ordering still leaves a window where a failure during audio_file.write(...) can leak the temporary file before it's tracked for cleanup. Thanks as well for putting together the minimal fix and the regression test in nh-atuan#1.
I'll apply the ordering change, rerun the validation, and update this PR accordingly. Really appreciate the careful recheck!
| def _get_model(self, model_name: str): | ||
| if model_name not in self._models: | ||
| self._models[model_name] = self._auto_model_cls( | ||
| model=model_name, | ||
| vad_model="fsmn-vad", | ||
| vad_kwargs={"max_single_segment_time": 30000}, | ||
| device=self._device, | ||
| ) | ||
| return self._models[model_name] |
There was a problem hiding this comment.
Unbounded caching of heavy machine learning models in self._models can easily lead to GPU/CPU Out-Of-Memory (OOM) errors if clients request multiple different models. Since this is a serving endpoint, it is highly recommended to either restrict the allowed models to a predefined set or limit the cache size (e.g., keeping only the default model or evicting older models).
| self._device = device or ( | ||
| "cuda:0" if os.environ.get("CUDA_VISIBLE_DEVICES") else "cpu" | ||
| ) |
There was a problem hiding this comment.
Checking os.environ.get("CUDA_VISIBLE_DEVICES") directly is less robust than using PyTorch's built-in utility torch.cuda.is_available(). PyTorch automatically respects CUDA_VISIBLE_DEVICES and also ensures that the CUDA driver and library are properly loaded and functional.
| self._device = device or ( | |
| "cuda:0" if os.environ.get("CUDA_VISIBLE_DEVICES") else "cpu" | |
| ) | |
| import torch | |
| self._device = device or ( | |
| "cuda:0" if torch.cuda.is_available() else "cpu" | |
| ) |
| Install Ray Serve and the packages used by this example: | ||
|
|
||
| ```bash | ||
| pip install "ray[serve]" funasr modelscope python-multipart requests |
There was a problem hiding this comment.
The tutorial uses the openai Python client in the "Query the Endpoint" section, but openai is not listed in the installation dependencies. Conversely, requests is installed but never used in the tutorial. Let's update the dependency installation command to replace requests with openai.
| pip install "ray[serve]" funasr modelscope python-multipart requests | |
| pip install "ray[serve]" funasr modelscope python-multipart openai |
abrarsheikh
left a comment
There was a problem hiding this comment.
Thanks for putting this together. My comments are mostly about tuning the example with some real world considerations which will make it more useful to the reader.
|
|
||
| @serve.deployment | ||
| @serve.ingress(fastapi_app) | ||
| class OpenAICompatibleIngress: |
There was a problem hiding this comment.
looks like the ingress deployment doesn't autoscale but the ASR deployment does. More meta question what is the ideal num replica ratio between the two deployments?
There was a problem hiding this comment.
From the FunASR side there is no model-defined fixed ingress:ASR replica ratio. The ingress only reads multipart input and forwards a deployment-handle call, while FunASRModel owns model memory and GPU inference, so the two bottlenecks scale independently.
The current 1–2 ingress and 0–4 ASR ranges are therefore a reasonable example topology rather than a required 1:N ratio: one ingress replica can feed multiple GPU ASR replicas, and a second ingress is useful only when upload/parsing or HTTP concurrency becomes measurable. The updated tutorial now makes that distinction and points users to benchmark representative audio before changing either range.
| ) | ||
|
|
||
| if model_name not in self._models: | ||
| self._models[model_name] = self._auto_model_cls( |
There was a problem hiding this comment.
if the example relies on choosing a model at runtime, then its better to use model multiplexing feature from serve.
| audio_path = audio_file.name | ||
|
|
||
| model_name = model or self._default_model | ||
| result = self._get_model(model_name).generate( |
There was a problem hiding this comment.
does this model benefit from batching?
| return result | ||
|
|
||
|
|
||
| @serve.deployment( |
There was a problem hiding this comment.
what is the ideal max ongoing request for this model? worth figuring that out, it would make the example more realistic
There was a problem hiding this comment.
There is no hardware-independent ideal value because service time changes substantially with GPU type, audio duration, VAD segmentation, and batch composition.
For this example, max_ongoing_requests=8 is a defensible bounded starting point with max_batch_size=4: it permits a full active batch plus one batch of queued work, while target_ongoing_requests=4 asks the autoscaler to add replicas around one full batch per replica. The tutorial now labels these as tuning values and includes an RPS/p50/p95 benchmark for short, medium, and long clips. Claiming a universal measured optimum here would be misleading; production values should come from that workload-specific benchmark.
There was a problem hiding this comment.
Thanks for the detailed explanation, @LauraGPT, that makes sense. I agree that there isn't a hardware-independent optimum, so I've positioned these values as tuning starting points rather than recommended universal defaults.
The benchmark section is also intended to help users derive workload-specific settings for their own deployments.
Thanks again for the thoughtful clarification.
|
|
||
| audio_bytes = await file.read() | ||
| result = await self._asr_handle.transcribe.remote( | ||
| audio_bytes=audio_bytes, |
There was a problem hiding this comment.
It is worth running some benchmarks on different audio file sizes and noting the RPS and latency at each size level. that will make the example more realistic
|
Thanks for the review. I updated the example to make the serving topology and tuning choices more realistic:
Validation:
|
|
Hi reviewers, I've addressed the review comments and updated the PR. Could someone please review it when available? Thanks! |
|
I did a pass over the current head ( What I checked locally:
I also cross-checked the earlier inline review themes against the current diff: temp file cleanup is now in No additional blockers found from this pass. |
|
Thanks @LauraGPT for taking the time to review the updated version and for re-checking all of the previous review points. I appreciate the thorough validation, especially the checks around the tutorial references, Glad to hear there are no additional blockers from your review. Thanks again for the detailed feedback throughout the process, it helped improve both the implementation and the tutorial significantly. |
LauraGPT
left a comment
There was a problem hiding this comment.
Reviewed the current FunASR/Ray Serve example from the FunASR integration side. I do not see additional blockers in the current head; the tutorial references, example registration, and Serve application structure match the validation noted earlier.
|
Thanks for the review and approval, @LauraGPT! I appreciate you taking the time to revisit the updated PR and verify all of the previous review points. It's great to hear that the tutorial references, example registration, and Serve application structure all look good from the FunASR integration side. Thanks again for the thorough validation and helpful feedback throughout the review process. |
|
CI triage for current head
Based on the logs, I don't see a FunASR/Serve code change indicated by the current red checks. I'll keep monitoring the automatic retries. |
|
I found one contributor-side runtime blocker while re-validating the current head: I prepared a focused fix for the branch owner in nh-atuan/ray#2. It groups batched requests by normalized scalar language, restores response order, and adds regression tests for the default single-request and mixed-language cases. Local results: 2 tests passed, plus Once that small PR is merged into Update after merge:
No additional contributor-side FunASR change is indicated by those two red statuses; a maintainer retry after the upstream CI/docs issue clears is appropriate. |
|
Rechecked current head The previous FunASR runtime blocker is cleared: batched requests are grouped by scalar language before calling Validation I ran locally on the current head: I also parsed |
|
Rechecked current head I opened a tiny contributor-branch follow-up with only that mechanical change: nh-atuan#3 Validation on the patched branch: The RTD failure I could inspect still points at unrelated Tune docs warnings, not the FunASR Serve files. |
|
Fresh CI triage on current head
I attempted to merge |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
Reviewed by Cursor Bugbot for commit 9171540. Configure here.
| latencies = [future.result() for future in as_completed(futures)] | ||
| elapsed = time.perf_counter() - start | ||
| p50 = statistics.median(latencies) | ||
| p95 = statistics.quantiles(latencies, n=20)[18] |
There was a problem hiding this comment.
Benchmark p95 needs twenty samples
Medium Severity
The new benchmark snippet computes p95 with statistics.quantiles(..., n=20), which (default exclusive method) requires at least twenty latency samples. --requests-per-file defaults to 10, and the documented curl/run example does not raise it, so the script raises StatisticsError after successful transcriptions when printing metrics.
Reviewed by Cursor Bugbot for commit 9171540. Configure here.
There was a problem hiding this comment.
I reproduced the exact expression before changing the example. This finding is not valid for the documented default: Python statistics.quantiles(data, n=20) does not require 20 observations; it requires at least two. On the branch environment (Python 3.12.3), statistics.quantiles([1.0, ..., 10.0], n=20)[18] returns 10.45, so the default --requests-per-file=10 and the documented command complete normally. Counts 0 or 1 are a separate CLI-input edge case, but they are not the reported/default path. I am leaving the benchmark unchanged rather than adding a workaround for a false positive.
|
@nh-atuan, I found and owned the current DCO failure: my earlier Black-only commit I rebuilt the same final five-file change as one clean commit on current Ray
Fresh current-master validation passed: 2 focused tests, Ruff 0.15.10, Black, compileall, YAML/example uniqueness, Because the missing sign-off is already in this PR history and Ray does not enable DCO remediation commits, a follow-up commit cannot clear it. Please update |
|
Thanks so much for taking the time to dig into this and for preparing such a detailed analysis and fix, @LauraGPT. I really appreciate the careful validation and all the effort you put into helping improve this example. I'll incorporate the changes, push an updated commit as soon as possible, and follow up here once it's ready. Thanks again, and don't worry, I won't let this slip. |
LauraGPT
left a comment
There was a problem hiding this comment.
Re-verified the current DCO-compliant head (34d097c) after the force-push. The patch is identical to the previously reviewed implementation. Local validation on this exact commit: 2 focused tests passed; py_compile, Black, Ruff 0.15.10, YAML parsing, and git diff --check all passed. Approving the current head.
|
@abrarsheikh, could you re-review the current DCO-clean head I revalidated this exact head locally (2 focused tests, |
|
Thanks so much for re-verifying the DCO-clean head and for the approval, @LauraGPT. I really appreciate the thorough validation and your help following up with @abrarsheikh. It’s great to know that all checks are now green and that the remaining review threads have been addressed. Your careful reviews and detailed guidance throughout this process have helped improve the PR significantly. Thanks again for all your support! |
|
Hi reviewers, all review feedback has been addressed and the latest validation is green. The relevant tests/checks are passing, and the PR should be ready for another review. I'd really appreciate it if you could take a look when you have time. Thanks! |
|
This pull request has been automatically marked as stale because it has not had You can always ask for help on our discussion forum or Ray's public slack channel. If you'd like to keep this open, just leave any comment, and the stale label will be removed. |
|
Hi maintainers/reviewers, Just a quick follow-up to keep this PR active. The latest DCO-clean head has addressed the previous review feedback, and the relevant tests/checks are passing. The PR is currently waiting for code-owner review. If there are any remaining concerns or changes needed, I’d be happy to address them. Thanks again for your time and review. |
dstrodtman
left a comment
There was a problem hiding this comment.
Docs-team style pass on the tutorial prose (funasr-asr.md), run by Douglas Strodtman on the Anyscale docs team with Claude Code assisting. I read through the existing threads first and I stand behind every note below.
Scope: style, grammar, and docs conventions only, against Ray's documentation style guide. I'm not evaluating the FunASR or Serve behavior. Technical correctness and the code-owner sign-off on the example belong to the Ray Serve maintainers. @abrarsheikh's threads on ingress-to-ASR scaling, model multiplexing, batching, and max_ongoing_requests read as addressed by you and @LauraGPT, but they're the code owner's to confirm, so I'm deferring to ray-serve on all of that rather than re-raising it.
Everything below is an inline, click-acceptable suggestion, and none of it is blocking. The recurring one is heading case: the guide uses sentence case for every heading (first word and proper nouns only). Heads up that several sibling tutorials (stable-diffusion, text-classification, object-detection) still use title-case H1s in this Serve a <X> Model pattern, so the H1 is a judgment call if you'd rather keep the tutorial titles consistent with those. The section headings are the clearer fix.
I'm leaving this as a comment rather than a ray-docs approval on purpose: /doc/source/serve/ is co-owned by ray-serve and ray-docs, so a docs-side approval would satisfy the code-owner gate and could merge the example before ray-serve signs off on its behavior. The docs side has no blocking prose objection.
Thanks for the careful iteration on this one. The prose is in good shape.
| --- | ||
| orphan: true | ||
| --- |
There was a problem hiding this comment.
The style guide asks every page to carry a description in its MyST html_meta front matter, which search results and the social preview use. This page has none. Here's a description drawn from the intro:
| --- | |
| orphan: true | |
| --- | |
| --- | |
| orphan: true | |
| myst: | |
| html_meta: | |
| description: "Deploy an automatic speech recognition (ASR) service with FunASR and Ray Serve behind an OpenAI-compatible transcription endpoint." | |
| --- |
|
|
||
| (serve-funasr-asr-tutorial)= | ||
|
|
||
| # Serve a FunASR Speech Recognition Model |
There was a problem hiding this comment.
Sentence case per the style guide (FunASR stays capitalized as a product name). See the note in the review summary: this H1 follows a title-case pattern that a few sibling tutorials still use, so keep the title cased if you'd rather stay consistent with them.
| # Serve a FunASR Speech Recognition Model | |
| # Serve a FunASR speech recognition model |
| exposes an OpenAI-compatible `POST /v1/audio/transcriptions` endpoint and scales | ||
| the FunASR deployment independently from the HTTP ingress. | ||
|
|
||
| ## Install Dependencies |
There was a problem hiding this comment.
Sentence case per the style guide.
| ## Install Dependencies | |
| ## Install dependencies |
| example on a CPU-only machine, remove `ray_actor_options={"num_gpus": 1}` from | ||
| the `FunASRModel` deployment in the code. | ||
|
|
||
| ## Define the Serve Application |
There was a problem hiding this comment.
Sentence case per the style guide (Serve stays capitalized as a Ray component).
| ## Define the Serve Application | |
| ## Define the Serve application |
| The application has two deployments: | ||
|
|
||
| 1. `OpenAICompatibleIngress` accepts multipart form uploads at `/v1/audio/transcriptions`. | ||
| 2. `FunASRModel` loads FunASR models and runs batched ASR inference. Serve can |
There was a problem hiding this comment.
Nit: the style guide numbers every ordered-list item 1. and lets MyST auto-number, so inserting or reordering a step stays a one-line edit.
| 2. `FunASRModel` loads FunASR models and runs batched ASR inference. Serve can | |
| 1. `FunASRModel` loads FunASR models and runs batched ASR inference. Serve can |
| autoscale this deployment separately from the ingress deployment. | ||
|
|
||
| The ingress deployment is lightweight, so the example keeps one to two ingress | ||
| replicas and allows each replica to queue more concurrent requests. The ASR |
There was a problem hiding this comment.
The style guide steers away from allows/lets/enables toward what the reader or the component actually does.
| replicas and allows each replica to queue more concurrent requests. The ASR | |
| replicas, with each replica handling more concurrent requests. The ASR |
| serve additional FunASR models, add their model names to `ALLOWED_MODELS` and | ||
| pass one of those names in the multipart `model` field. | ||
|
|
||
| ## Run the Service |
There was a problem hiding this comment.
Sentence case per the style guide.
| ## Run the Service | |
| ## Run the service |
| The first request downloads the configured FunASR model, so it may take longer | ||
| than later requests. | ||
|
|
||
| ## Query the Endpoint |
There was a problem hiding this comment.
Sentence case per the style guide.
| ## Query the Endpoint | |
| ## Query the endpoint |
| `response_format=verbose_json` to include FunASR segment metadata when the | ||
| selected model returns it. | ||
|
|
||
| ## Benchmark the Deployment |
There was a problem hiding this comment.
Sentence case per the style guide (deployment is a generic Ray concept, so lowercase).
| ## Benchmark the Deployment | |
| ## Benchmark the deployment |
|
Thanks @dstrodtman for the thorough docs style review and helpful feedback I have applied all of your suggestions to
Local validation ( |
|
I checked the single failing status on the current exact head The failure is in Buildkite The same environment-level import error is repeated across the full failed shard, including |
|
Thanks so much @LauraGPT for the thorough CI triage and detailed breakdown Your analysis was spot on, the previous failure in To resolve this and ensure clean CI runs:
All fresh CI checks have been re-triggered on the updated head. |
…utorial Add a comprehensive tutorial and example demonstrating how to deploy an automatic speech recognition (ASR) service using FunASR and Ray Serve. - Add FunASR Serve application doc code with OpenAI-compatible transcription endpoint. - Add unit tests for the doc code integration. - Add FunASR ASR tutorial markdown document and register it in examples.yml. - Register doc code test in doc/BUILD.bazel. Signed-off-by: nh-atuan <[email protected]>
9fd4e0b to
cf7e734
Compare
CI Triage for Build #53246The failures across the three Wanda image build steps ( Root Cause:Inside the Dockerfile image builds, |
|
Hi maintainers/reviewers, The PR is now updated on the latest head, with the previous review feedback addressed and the latest CI checks passing. The remaining blocker is code-owner review. When you have a chance, could you please take a look at the current head and let me know if there are any remaining concerns or changes needed? Thanks for your time and review. |
…ervability pages to MyST (#66461) ## Why are these changes needed? Converts the last non-API-reference RST pages under `ray-core/`, `data/`, and `rllib/` to MyST Markdown, plus the `train/` and `ray-observability/` pages that `doc/BUILD.bazel` names by path. The API reference trees (`*/api/`, `rllib/package_ref/`, and `ray-core/compiled-graph/compiled-graph-api`) stay RST for now. Each page gets its own commit, so you can review one file at a time. Every commit renames the page's literal `.rst` paths in `doc/BUILD.bazel` to `.md`. These paths are in `exclude` lists and in the explicit `files` lists of `doctest[data-gpu]` and `doctest[train-gpu]`, and they don't glob. Without the edit, an excluded page would silently join its target once it's `.md`, and an included page would silently drop out of it. Conversions are format-only: labels, headings, and prose are unchanged. A final whitespace-only commit soft-wraps the prose. `ray-soft-wrap`'s `verify.py` confirms non-whitespace bytes, rendered HTML, and idempotence for all 11 files. ### `rllib/getting-started`: doctest target removed The first commit deletes `doctest[rllib2]`, the only target over `rllib/getting-started.rst`, before the page converts. The target is tagged `manual` with a hang TODO, so no premerge or postmerge step has run it, and nothing else references it (`git grep rllib2` is empty). Its 15 `testcode` blocks had no `testoutput`, so they asserted nothing. The 12 visible blocks become display-only `python` code blocks. The three `:hide:` blocks held `.stop()` cleanups that never rendered, so they're deleted. `doctest[rllib]` still excludes the page. If these examples should be validated later, a `doc_code/` script is the better route than reviving the hanging target. cc @elliot-barn, who owns the TODO. This commit isn't buildable on its own. It turns a `.. testcode::` that had no blank line before its body into a `.. code-block:: python`, still with no blank line, and docutils reads the body as extra arguments to the directive. The later conversion commit fixes it in the `.md`, and a squash merge never puts the intermediate commit on master. ### Doctest coverage Docs-only PRs don't run doctests premerge. This PR edits `doc/BUILD.bazel`, so every library's docs example step runs, but premerge can't show the conversion kept the same blocks. For that, I parsed each `.md` and the `.rst` it replaced with Ray's `pytest-sphinx` fork, the same parser the doctest macro runs, and asserted identical sections (directive, body, `:options:`, `:skipif:`) and examples. | Page | BUILD role | Examples before → after | | --- | --- | --- | | `ray-core/handling-dependencies` | `doctest[core]` exclude | 17 → 17 | | `ray-core/tasks/nested-tasks` | `doctest[core]` exclude | 0 → 0 (`literalinclude` of a tested `doc_code/` file) | | `data/batch-inference` | `doctest_each` exclude, `doctest[data-gpu]` files | 7 → 7 | | `data/transforming-data` | `doctest_each` exclude, `doctest[data-gpu]` files | 24 → 24 | | `data/contributing/contributing` | `doctest_each` glob | 0 → 0 (toctree only) | | `rllib/getting-started` | `doctest[rllib]` exclude, `doctest[rllib2]` removed | 15 → 0, by the removal commit | | `ray-observability/user-guides/cli-sdk` | top-level exclude | 16 → 16 | | `ray-observability/user-guides/ray-tracing` | top-level exclude | 3 → 3 | | `train/horovod` | `doctest[train]` exclude | 2 → 2 | | `train/user-guides/data-loading-preprocessing` | `doctest[train]` exclude, `doctest[train-gpu]` files | 6 → 6 | | `train/user-guides/using-accelerators` | `doctest[train]` exclude, `doctest[train-gpu]` files | 10 → 10 | To show the check would catch a broken conversion, I mutated each page with examples three ways: dropping a `testcode` block, altering a line in one, and turning one into a four-backtick fence. The last renders fine but is never collected. The check failed on all 24 mutations. ### Rendering changes I ran `render_diff.py` on all 11 pages against `/en/master`. Six render identically: `nested-tasks`, `data/contributing/contributing`, `cli-sdk`, `ray-tracing`, `horovod`, and `using-accelerators`. Every difference on the other five is listed here. - `rllib/getting-started`: on master, one `.. testcode::` line had no blank line after it. docutils read the block's first six lines, the `best_result = results.get_best_result(...)` call, as the directive's argument and dropped them. So master shows code that uses `best_result` without showing where it comes from. The converted page renders all six lines. This is the one place the conversion deliberately doesn't reproduce master. - `rllib/getting-started`: the "Farama gymnasium" link now has `https://`. On master it's a relative link to `gymnasium.farama.org` that 404s. - `ray-core/handling-dependencies`: MyST drops the apostrophe when it slugifies the "can't import the packages" heading, so the section id changes. That heading had no label, so the page adds a target carrying the old docutils slug, and existing `#...-can-t-import-...` links still resolve. An auto-numbered span id, which nothing links to, also changes from `id4` to `id2`. - `data/batch-inference` and `train/user-guides/data-loading-preprocessing`: each renders an RST comment as an HTML comment, which readers never see. - `data/transforming-data`: the "When using" definition list's `<dl>` gains the unstyled `myst` class. The first preview diff also caught three regressions that the green build didn't. MyST's `replacements` extension turned two `(c)` list markers into `©` and an `etc..` into `etc…`. The anchor above had changed too. A follow-up commit fixes all three. A sweep of the 11 pages found no other text that extension rewrites. ### Dead `doc/BUILD.bazel` excludes A final commit drops four `exclude` entries that name files that have moved: two in `doctest[serve]` and two in the serve `doc_code` test. A glob exclude naming a missing file excludes nothing, so these had silently stopped applying. This doesn't change what any target runs. #66462 carries the same commit, along with a lint check that fails on this class of stale path, so the two PRs merge cleanly in either order. ### Open PRs that edit these files Each of these open PRs edits one of the converted `.rst` files, so each will need to move its change to the `.md`: #66279, #66191, #65956, #65933, and #65830 (`handling-dependencies`), #65693 (`cli-sdk`), and #66419, #66420, #66422, and #66423 (`data/batch-inference`, `train/user-guides/data-loading-preprocessing`). #66096, #64053, and #63881 also edit `doc/BUILD.bazel`, and only #66096 edits nearby lines. ## Related issue number None. No open PR converts these pages. I checked `gh pr list` for open PRs touching each file. ## Checks - [x] I've signed off every commit (`git commit -s`). - [x] Pre-commit hooks passed on every commit. - Doctest parity: `python3 doctest_parity.py <the 11 .md files>` with `pytest==7.4.4` and `pytest-sphinx @ git+https://github.com/ray-project/pytest-sphinx`. All OK, run again after the soft-wrap commit. - Static checks on every `.md`: fences balance, no leftover RST roles or directives, every label from the `.rst` is present, and directive counts match. - Read the Docs preview builds green under `fail_on_warning`, and the render diff against `/en/master` is in Rendering changes. The first build hit the known autosummary-import segfault and passed on rebuild. - Local doctest run: not done. The GPU targets need hardware, and the CPU targets run in this PR's premerge because of the `BUILD.bazel` change. AI assistance (Claude Code) was used for the conversion and the verification scripts. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Signed-off-by: Douglas Strodtman <[email protected]> Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
|
Hi maintainers/reviewers, The PR has now been updated to the latest head with all previous review feedback addressed, and the latest CI checks are passing. The remaining blocker is code-owner review. Could someone from the Ray Serve team please take a look at the current head when you have a chance? If there are any remaining concerns or changes needed, I’d be happy to address them. Thanks again for your time and review. |
…ervability pages to MyST (ray-project#66461) ## Why are these changes needed? Converts the last non-API-reference RST pages under `ray-core/`, `data/`, and `rllib/` to MyST Markdown, plus the `train/` and `ray-observability/` pages that `doc/BUILD.bazel` names by path. The API reference trees (`*/api/`, `rllib/package_ref/`, and `ray-core/compiled-graph/compiled-graph-api`) stay RST for now. Each page gets its own commit, so you can review one file at a time. Every commit renames the page's literal `.rst` paths in `doc/BUILD.bazel` to `.md`. These paths are in `exclude` lists and in the explicit `files` lists of `doctest[data-gpu]` and `doctest[train-gpu]`, and they don't glob. Without the edit, an excluded page would silently join its target once it's `.md`, and an included page would silently drop out of it. Conversions are format-only: labels, headings, and prose are unchanged. A final whitespace-only commit soft-wraps the prose. `ray-soft-wrap`'s `verify.py` confirms non-whitespace bytes, rendered HTML, and idempotence for all 11 files. ### `rllib/getting-started`: doctest target removed The first commit deletes `doctest[rllib2]`, the only target over `rllib/getting-started.rst`, before the page converts. The target is tagged `manual` with a hang TODO, so no premerge or postmerge step has run it, and nothing else references it (`git grep rllib2` is empty). Its 15 `testcode` blocks had no `testoutput`, so they asserted nothing. The 12 visible blocks become display-only `python` code blocks. The three `:hide:` blocks held `.stop()` cleanups that never rendered, so they're deleted. `doctest[rllib]` still excludes the page. If these examples should be validated later, a `doc_code/` script is the better route than reviving the hanging target. cc @elliot-barn, who owns the TODO. This commit isn't buildable on its own. It turns a `.. testcode::` that had no blank line before its body into a `.. code-block:: python`, still with no blank line, and docutils reads the body as extra arguments to the directive. The later conversion commit fixes it in the `.md`, and a squash merge never puts the intermediate commit on master. ### Doctest coverage Docs-only PRs don't run doctests premerge. This PR edits `doc/BUILD.bazel`, so every library's docs example step runs, but premerge can't show the conversion kept the same blocks. For that, I parsed each `.md` and the `.rst` it replaced with Ray's `pytest-sphinx` fork, the same parser the doctest macro runs, and asserted identical sections (directive, body, `:options:`, `:skipif:`) and examples. | Page | BUILD role | Examples before → after | | --- | --- | --- | | `ray-core/handling-dependencies` | `doctest[core]` exclude | 17 → 17 | | `ray-core/tasks/nested-tasks` | `doctest[core]` exclude | 0 → 0 (`literalinclude` of a tested `doc_code/` file) | | `data/batch-inference` | `doctest_each` exclude, `doctest[data-gpu]` files | 7 → 7 | | `data/transforming-data` | `doctest_each` exclude, `doctest[data-gpu]` files | 24 → 24 | | `data/contributing/contributing` | `doctest_each` glob | 0 → 0 (toctree only) | | `rllib/getting-started` | `doctest[rllib]` exclude, `doctest[rllib2]` removed | 15 → 0, by the removal commit | | `ray-observability/user-guides/cli-sdk` | top-level exclude | 16 → 16 | | `ray-observability/user-guides/ray-tracing` | top-level exclude | 3 → 3 | | `train/horovod` | `doctest[train]` exclude | 2 → 2 | | `train/user-guides/data-loading-preprocessing` | `doctest[train]` exclude, `doctest[train-gpu]` files | 6 → 6 | | `train/user-guides/using-accelerators` | `doctest[train]` exclude, `doctest[train-gpu]` files | 10 → 10 | To show the check would catch a broken conversion, I mutated each page with examples three ways: dropping a `testcode` block, altering a line in one, and turning one into a four-backtick fence. The last renders fine but is never collected. The check failed on all 24 mutations. ### Rendering changes I ran `render_diff.py` on all 11 pages against `/en/master`. Six render identically: `nested-tasks`, `data/contributing/contributing`, `cli-sdk`, `ray-tracing`, `horovod`, and `using-accelerators`. Every difference on the other five is listed here. - `rllib/getting-started`: on master, one `.. testcode::` line had no blank line after it. docutils read the block's first six lines, the `best_result = results.get_best_result(...)` call, as the directive's argument and dropped them. So master shows code that uses `best_result` without showing where it comes from. The converted page renders all six lines. This is the one place the conversion deliberately doesn't reproduce master. - `rllib/getting-started`: the "Farama gymnasium" link now has `https://`. On master it's a relative link to `gymnasium.farama.org` that 404s. - `ray-core/handling-dependencies`: MyST drops the apostrophe when it slugifies the "can't import the packages" heading, so the section id changes. That heading had no label, so the page adds a target carrying the old docutils slug, and existing `#...-can-t-import-...` links still resolve. An auto-numbered span id, which nothing links to, also changes from `id4` to `id2`. - `data/batch-inference` and `train/user-guides/data-loading-preprocessing`: each renders an RST comment as an HTML comment, which readers never see. - `data/transforming-data`: the "When using" definition list's `<dl>` gains the unstyled `myst` class. The first preview diff also caught three regressions that the green build didn't. MyST's `replacements` extension turned two `(c)` list markers into `©` and an `etc..` into `etc…`. The anchor above had changed too. A follow-up commit fixes all three. A sweep of the 11 pages found no other text that extension rewrites. ### Dead `doc/BUILD.bazel` excludes A final commit drops four `exclude` entries that name files that have moved: two in `doctest[serve]` and two in the serve `doc_code` test. A glob exclude naming a missing file excludes nothing, so these had silently stopped applying. This doesn't change what any target runs. ray-project#66462 carries the same commit, along with a lint check that fails on this class of stale path, so the two PRs merge cleanly in either order. ### Open PRs that edit these files Each of these open PRs edits one of the converted `.rst` files, so each will need to move its change to the `.md`: ray-project#66279, ray-project#66191, ray-project#65956, ray-project#65933, and ray-project#65830 (`handling-dependencies`), ray-project#65693 (`cli-sdk`), and ray-project#66419, ray-project#66420, ray-project#66422, and ray-project#66423 (`data/batch-inference`, `train/user-guides/data-loading-preprocessing`). ray-project#66096, ray-project#64053, and ray-project#63881 also edit `doc/BUILD.bazel`, and only ray-project#66096 edits nearby lines. ## Related issue number None. No open PR converts these pages. I checked `gh pr list` for open PRs touching each file. ## Checks - [x] I've signed off every commit (`git commit -s`). - [x] Pre-commit hooks passed on every commit. - Doctest parity: `python3 doctest_parity.py <the 11 .md files>` with `pytest==7.4.4` and `pytest-sphinx @ git+https://github.com/ray-project/pytest-sphinx`. All OK, run again after the soft-wrap commit. - Static checks on every `.md`: fences balance, no leftover RST roles or directives, every label from the `.rst` is present, and directive counts match. - Read the Docs preview builds green under `fail_on_warning`, and the render diff against `/en/master` is in Rendering changes. The first build hit the known autosummary-import segfault and passed on rebuild. - Local doctest run: not done. The GPU targets need hardware, and the CPU targets run in this PR's premerge because of the `BUILD.bazel` change. AI assistance (Claude Code) was used for the conversion and the verification scripts. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Signed-off-by: Douglas Strodtman <[email protected]> Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
#67012) ## Why are these changes needed? Ray's docs are retiring notebooks and the `doc_code` scripts that no page shows. This PR adds a guard so that debt can't grow back while it's being burned down. It follows the shape of `doc/test_no_new_rst.py`. `doc/test_doc_assets.py` checks the tracked tree, not the diff, and fails in three cases: 1. **A new notebook.** Any `.ipynb` under `doc/source/` that isn't on `doc/asset_allowlists/notebooks.txt`. 2. **A `doc_code` script that no page shows.** A `.py` under `doc/source/**/doc_code/` counts as shown if any of these holds: - A page pulls it in with `literalinclude` or `include`. RST and MyST forms both count, as do relative and `/`-rooted paths. - A shown script imports it, transitively. - It's a test wrapper. That means it imports an included script, or it names an included file in a string literal. The second form covers the `llm/doc_code/serve/**/*_yaml_config_example.py` scripts that load and deploy an included YAML config, so they need no permanent exemption. Anything else has to be on `doc/asset_allowlists/doc_code.txt`. 3. **A stale allowlist entry.** A listed file that's gone, or that a page now shows, also fails, so both lists only shrink. Each conversion or cleanup PR deletes its own lines. `python doc/test_doc_assets.py --update` rewrites both lists from the tree. It's there for re-seeding after a rebase. The contributor docs say not to use it to get a new file through. ### Seeded debt at this commit - 52 notebooks. - 10 unshown `doc_code` scripts. Two open PRs clear 7 of them: #66964 handles 5 Serve and LLM scripts, and #66965 handles the 2 RLlib scripts. If either merges first, this PR re-seeds with `--update`. If either merges after this one, it deletes its own allowlist lines. The scripts with no open PR are `cluster/doc_code/simple-trainer.py` (run by the included `slurm-basic.sh`, never shown), `cluster/doc_code/yarn/dashboard.py`, and `llm/doc_code/serve/custom_vllm/qwen3_reward_plugin/qwen3_rm.py` (linked on GitHub, not included). ### Where it runs: a lint matrix entry, not a `py_test` The check runs as `lint: doc_assets` in the `lint-small-prose` matrix next to `doc_no_new_rst`. It doesn't run as a Bazel `py_test`, for two reasons: - A prose-only change can fail it. Deleting a page's last `literalinclude` of a script orphans that script. That step keeps the `always` tag, so it runs on every PR, including prose-only ones. A `doc`-tagged test would miss them. - It reads the whole `doc/source/` tree. As a `py_test`, it would need all of `doc/source/` as `data` to get into the Bazel sandbox. It runs postmerge as well, because non-PR builds run everything. **REEf: please confirm this placement, the premerge gating, and the rule changes below.** ### Routing - `doc/test_doc_assets.py` joins `doc/test_no_new_rst.py` in the `doc` build-infra rule in `test.rules.txt`. Without that, it falls to the `doc/*.py` catch-all and emits `doc_example`. - The allowlists route to nothing in `test.rules.txt`. Only the lint step reads them, and that step runs on every PR. They get `always lint` from the `always.rules.txt` catch-all. - Expectations for both paths are added to `test.rules.test.txt` and `always.rules.test.txt`. ### Limits - The check doesn't apply Sphinx `exclude_patterns`, so a page excluded from the build still counts as showing what it includes. At this commit, honoring the excludes changes nothing. - `doc/source/ray-contribute/docs.md` still describes authoring notebooks. Rewriting it is separate work, which removes the notebook template and replaces that guidance. Until then, the check's failure message points to the new section in `ci.md`. ## Related issue number None. Before opening this PR, I searched open PRs for notebook, allowlist, `doc_code`, and orphan keywords and found no other ratchet. #66964, #66965, #67008, and #66884 shrink or move the seeded debt, and none of them adds a check. #64053 adds a new Serve example plus a test that names the example script by filename. The test-wrapper rule passes it, provided its page includes the example script. ## Checks - [x] I've signed off every commit (DCO). - [x] `./ci/lint/lint.sh doc_assets`: passes on this branch with the seeded lists. - [x] Each failure mode, exercised locally and then reverted: a new `.ipynb` fails, a new unshown `doc_code` script fails, removing a page's `literalinclude` fails along with the scripts that only it imported, a stale allowlist line fails, and a test script that imports an included script passes. - [x] `--update` is idempotent on this tree. - [x] `rayci test-rules`, built from `ray-project/rayci` master: all rule tests pass, including the new expectations. - [x] `pre-commit run` on the changed files: passed, including black and ruff. - [x] Cross-checked the seed against an independent scan of the same tree. It lists the same 9 scripts, and also flags `test_service_pb2.py`, which only an unshown script imports. #66964 deletes both of those `pb2` scripts. AI assistance (Claude Code) was used to prepare this PR. I reviewed every changed line. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Signed-off-by: Douglas Strodtman <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>


Description
Adds a Ray Serve tutorial and runnable doc code example for serving FunASR automatic speech recognition (ASR) models.
This PR includes:
funasr_asr.pyServe application with a FastAPI ingress endpoint compatible withPOST /v1/audio/transcriptions.FunASRModeldeployment for ASR inference.serve run, and requests using both the OpenAI Python client andcurl.This addresses the request for a FunASR Ray Serve integration example and demonstrates scalable speech-to-text serving with Ray Serve.
Related issues
Closes #64052
Additional information
Validation performed:
python -m py_compile doc/source/serve/doc_code/funasr_asr.pygit diff --checkdoc/source/serve/examples.ymlwith PyYAMLI did not run full FunASR inference locally because it requires downloading model weights.