Skip to content

Commit 0ed3fd5

Browse files
ruiren_microsoftCopilot
andcommitted
Address PR feedback: revert Core version, document backpressure, fix test cleanup
- Revert foundry-local-core to 1.0.0rc1 (no dev builds on main) - Re-add try/except for execute_command_with_binary (1.0.0rc1 lacks symbol) - Document blocking backpressure behavior in append() - Remove unnecessary time.sleep(0.5) in error test - Add stop() cleanup in error test (required for non-daemon thread) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent de6bf18 commit 0ed3fd5

5 files changed

Lines changed: 17 additions & 9 deletions

File tree

sdk/python/requirements-winml.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ pydantic>=2.0.0
22
requests>=2.32.4
33
openai>=2.24.0
44
# WinML native binary packages from the ORT-Nightly PyPI feed.
5-
foundry-local-core-winml==1.0.0.dev202604082039
5+
foundry-local-core-winml==1.0.0rc1
66
onnxruntime-core==1.23.2.3
77
onnxruntime-genai-core==0.13.1

sdk/python/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ pydantic>=2.0.0
22
requests>=2.32.4
33
openai>=2.24.0
44
# Standard native binary packages from the ORT-Nightly PyPI feed.
5-
foundry-local-core==1.0.0.dev202604082039
5+
foundry-local-core==1.0.0rc1
66
onnxruntime-core==1.24.4; sys_platform != "linux"
77
onnxruntime-gpu==1.24.4; sys_platform == "linux"
88
onnxruntime-genai-core==0.13.1; sys_platform != "linux"

sdk/python/src/detail/core_interop.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,15 @@ def _initialize_native_libraries() -> 'NativeBinaryPaths':
190190
ctypes.c_void_p] # user_data
191191
lib.execute_command_with_callback.restype = None
192192

193-
lib.execute_command_with_binary.argtypes = [ctypes.POINTER(StreamingRequestBuffer),
194-
ctypes.POINTER(ResponseBuffer)]
195-
lib.execute_command_with_binary.restype = None
193+
# execute_command_with_binary is required for live audio streaming.
194+
# Guard with try/except until Core packages with this symbol are released.
195+
try:
196+
lib.execute_command_with_binary.argtypes = [ctypes.POINTER(StreamingRequestBuffer),
197+
ctypes.POINTER(ResponseBuffer)]
198+
lib.execute_command_with_binary.restype = None
199+
except AttributeError:
200+
logger.debug("execute_command_with_binary not exported by Core — "
201+
"live audio streaming will not be available until Core is updated")
196202

197203
return paths
198204

sdk/python/src/openai/live_audio_transcription_client.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,9 @@ def append(self, pcm_data: bytes) -> None:
168168
"No active streaming session. Call start() first."
169169
)
170170

171+
# put() blocks if the queue is full (backpressure). This prevents
172+
# unbounded memory growth when the native core is slower than
173+
# real-time. Capacity is configurable via push_queue_capacity.
171174
push_queue.put(data_copy)
172175

173176
def get_transcription_stream(self) -> Generator[LiveAudioTranscriptionResponse, None, None]:

sdk/python/test/openai/test_live_audio_transcription.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -316,14 +316,13 @@ def test_push_error_surfaces_as_exception(self):
316316

317317
session.append(b'\x00' * 3200)
318318

319-
# Give push loop time to process
320-
import time
321-
time.sleep(0.5)
322-
323319
with pytest.raises(FoundryLocalException, match="Push failed"):
324320
for _ in session.get_transcription_stream():
325321
pass
326322

323+
# Cleanup: stop to join the push thread
324+
session.stop()
325+
327326
def test_context_manager_calls_stop(self):
328327
"""Verify context manager calls stop on exit."""
329328
mock_interop = MagicMock(spec=CoreInterop)

0 commit comments

Comments
 (0)