Skip to content

Commit 149151e

Browse files
committed
fix sdk
1 parent 0ed3fd5 commit 149151e

5 files changed

Lines changed: 43 additions & 17 deletions

File tree

sdk/deps_versions.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"foundry-local-core": {
33
"nuget": "1.0.0",
4-
"python": "1.0.0"
4+
"python": "1.0.0rc1"
55
},
66
"onnxruntime": {
77
"version": "1.24.4"

sdk/deps_versions_winml.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"foundry-local-core": {
33
"nuget": "1.0.0",
4-
"python": "1.0.0"
4+
"python": "1.0.0rc1"
55
},
66
"onnxruntime": {
77
"version": "1.23.2.3"

sdk/python/src/openai/live_audio_transcription_client.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,12 @@ 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.
174-
push_queue.put(data_copy)
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.
174+
# Performed outside the lock to avoid blocking stop() and other
175+
# state transitions while waiting for queue space.
176+
push_queue.put(data_copy)
175177

176178
def get_transcription_stream(self) -> Generator[LiveAudioTranscriptionResponse, None, None]:
177179
"""Get the stream of transcription results.
@@ -296,9 +298,9 @@ def _push_loop(self) -> None:
296298
)
297299
except Exception as ex:
298300
logger.error("Push loop terminated with unexpected error: %s", ex)
299-
self._output_queue.put(
300-
FoundryLocalException("Push loop terminated unexpectedly.", ex)
301-
)
301+
fatal_ex = FoundryLocalException("Push loop terminated unexpectedly.")
302+
fatal_ex.__cause__ = ex
303+
self._output_queue.put(fatal_ex)
302304
self._output_queue.put(_SENTINEL)
303305

304306
# --- Context manager support ---

sdk/python/test/openai/test_live_audio_transcription.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -314,14 +314,15 @@ def test_push_error_surfaces_as_exception(self):
314314
session = LiveAudioTranscriptionSession("test-model", mock_interop)
315315
session.start()
316316

317-
session.append(b'\x00' * 3200)
318-
319-
with pytest.raises(FoundryLocalException, match="Push failed"):
320-
for _ in session.get_transcription_stream():
321-
pass
322-
323-
# Cleanup: stop to join the push thread
324-
session.stop()
317+
try:
318+
session.append(b'\x00' * 3200)
319+
320+
with pytest.raises(FoundryLocalException, match="Push failed"):
321+
for _ in session.get_transcription_stream():
322+
pass
323+
finally:
324+
# Cleanup: stop to join the push thread even if assertions fail
325+
session.stop()
325326

326327
def test_context_manager_calls_stop(self):
327328
"""Verify context manager calls stop on exit."""

sdk/python/test/openai/test_live_audio_transcription_e2e.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,17 @@ def e2e_manager():
172172
from foundry_local_sdk.detail.core_interop import CoreInterop
173173
from foundry_local_sdk.foundry_local_manager import FoundryLocalManager
174174

175+
# Snapshot prior global state so we can restore it on teardown and avoid
176+
# cross-test contamination when this fixture runs in a shared session.
177+
prior_state = {
178+
"_initialized": getattr(CoreInterop, "_initialized", False),
179+
"_flcore_library": getattr(CoreInterop, "_flcore_library", None),
180+
"_ort_library": getattr(CoreInterop, "_ort_library", None),
181+
"_genai_library": getattr(CoreInterop, "_genai_library", None),
182+
}
183+
prior_manager_instance = getattr(FoundryLocalManager, "instance", None)
184+
prior_ort_lib_path = os.environ.get("ORT_LIB_PATH")
185+
175186
CoreInterop._initialized = False
176187
CoreInterop._flcore_library = None
177188
CoreInterop._ort_library = None
@@ -202,6 +213,18 @@ def e2e_manager():
202213
pass
203214
FoundryLocalManager.instance = None
204215

216+
# Restore prior global state
217+
CoreInterop._initialized = prior_state["_initialized"]
218+
CoreInterop._flcore_library = prior_state["_flcore_library"]
219+
CoreInterop._ort_library = prior_state["_ort_library"]
220+
CoreInterop._genai_library = prior_state["_genai_library"]
221+
FoundryLocalManager.instance = prior_manager_instance
222+
223+
if prior_ort_lib_path is None:
224+
os.environ.pop("ORT_LIB_PATH", None)
225+
else:
226+
os.environ["ORT_LIB_PATH"] = prior_ort_lib_path
227+
205228

206229
class TestLiveAudioTranscriptionE2E:
207230
"""E2E test for live audio transcription with synthetic PCM audio."""

0 commit comments

Comments
 (0)