Skip to content

[pull] master from ray-project:master#4086

Merged
pull[bot] merged 1 commit intomiqdigital:masterfrom
ray-project:master
Apr 27, 2026
Merged

[pull] master from ray-project:master#4086
pull[bot] merged 1 commit intomiqdigital:masterfrom
ray-project:master

Conversation

@pull
Copy link
Copy Markdown

@pull pull Bot commented Apr 27, 2026

See Commits and Changes for more details.


Created by pull[bot] (v2.0.0-alpha.4)

Can you help keep this open source service alive? 💖 Please sponsor : )

…#62821)

## Description

This PR enables `test_tracing_utils` for Windows by addressing file
locking issues and cross-platform line ending discrepancies. It also
ensures that tracing tests are no longer skipped on Windows.

### Key Changes
* **Re-enabled Windows Tests:** Removed `pytest.mark.skipif` for the
`win32` platform to allow tracing tests to run in Windows environments.
* **Fixed File Handle Leak in ConsoleSpanExporter:** ConsoleSpanExporter
was initialized with an inline `open()` call that was never explicitly
closed, causing a `PermissionError` on Windows when attempting to delete
span files after tests. Fixed by subclassing ConsoleSpanExporter with a
`shutdown()` method that explicitly flushes and closes the file handle.
`provider.shutdown()` is now called inside `safe_remove()` to trigger
the cleanup chain before deletion.
* **Improved Span Parsing:** Replaced `.split("}\n{")` with
`re.split(r'}\s*\n\s*{', file_contents)` in `load_spans`. This
regex-based approach correctly handles different newline sequences (`\n`
vs `\r\n`) and potential whitespace variations between JSON objects,
preventing decoding failures.
* **Explicit Exporter Path:** Added
`tracing_exporter_import_path=DEFAULT_TRACING_EXPORTER_IMPORT_PATH`
across multiple test cases to ensure consistent tracing configuration.
---

## Related issues

Closes #61443

---

## Additional information

* **Cleanup Refactor:** Replaced all instances of `shutil.rmtree` and
`os.remove` with `safe_remove_directory` for span directory management.
* **Windows Compatibility Fix:** The `load_spans` fix is critical for
Windows where `ConsoleSpanExporter` may output CRLF (`\r\n`) line
endings, which previously broke the manual JSON string splitting logic.

---

## Test Verification

* **Platform:** Windows 11 / Windows 10
* **Command:** `pytest -v python/ray/serve/tests/test_tracing_utils.py`
* **Result:** Verified that all tests in `test_tracing_utils.py` pass
locally on Windows after applying these changes.

<img width="1766" height="434" alt="image"
src="https://github.com/user-attachments/assets/bcdbe069-1145-4f47-8d09-1b059113041a"
/>

---------

Signed-off-by: baohg153 <baohg.main@gmail.com>
Signed-off-by: phmkhoi <phanhuynhminhkhoi@gmail.com>
Signed-off-by: TriNguyen1208 <ductri0981@gmail.com>
Signed-off-by: Nguyễn Đức Trí <168810923+TriNguyen1208@users.noreply.github.com>
Co-authored-by: phmkhoi <phanhuynhminhkhoi@gmail.com>
@pull pull Bot locked and limited conversation to collaborators Apr 27, 2026
@pull pull Bot added the ⤵️ pull label Apr 27, 2026
@pull pull Bot merged commit ba15069 into miqdigital:master Apr 27, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant