Skip to content

Commit 21cd4c8

Browse files
fix access to TranscriptionSegment (Azure#37644)
* fix access to TranscriptionSegment * fix ci * fix ci * mark tests live only * cspell
1 parent 5dfbceb commit 21cd4c8

20 files changed

+131
-108
lines changed

.vscode/cspell.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,7 @@
353353
"prevsnapshot",
354354
"pschema",
355355
"PSECRET",
356+
"pydantic",
356357
"pyfetch",
357358
"pyfuncitem",
358359
"pygobject",

sdk/openai/azure-openai/pyproject.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,7 @@ mypy = false
44
pyright = false
55
type_check_samples = false
66
verifytypes = false
7+
sphinx = false
8+
sdist = false
9+
mindependency = false
10+
verifysdist = false

sdk/openai/azure-openai/tests/test_assistants.py

Lines changed: 35 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -87,16 +87,16 @@ def on_message_delta(self, delta: MessageDelta, snapshot: Message):
8787
if content.text.value:
8888
assert content.text.value is not None
8989
if content.text.annotations:
90-
for annot in content.text.annotations:
91-
if annot.type == "file_citation":
92-
assert annot.end_index is not None
93-
assert annot.file_citation.file_id
94-
assert annot.file_citation.quote
95-
assert annot.start_index is not None
96-
elif annot.type == "file_path":
97-
assert annot.end_index is not None
98-
assert annot.file_path.file_id
99-
assert annot.start_index is not None
90+
for annotation in content.text.annotations:
91+
if annotation.type == "file_citation":
92+
assert annotation.end_index is not None
93+
assert annotation.file_citation.file_id
94+
assert annotation.file_citation.quote
95+
assert annotation.start_index is not None
96+
elif annotation.type == "file_path":
97+
assert annotation.end_index is not None
98+
assert annotation.file_path.file_id
99+
assert annotation.start_index is not None
100100
elif content.type == "image_file":
101101
assert content.index is not None
102102
assert content.image_file.file_id
@@ -109,36 +109,36 @@ def on_message_done(self, message: Message):
109109
if msg.type == "text":
110110
assert msg.text.value
111111
if msg.text.annotations:
112-
for annot in msg.text.annotations:
113-
if annot.type == "file_citation":
114-
assert annot.end_index is not None
115-
assert annot.file_citation.file_id
116-
assert annot.file_citation.quote
117-
assert annot.start_index is not None
118-
assert annot.text is not None
119-
elif annot.type == "file_path":
120-
assert annot.end_index is not None
121-
assert annot.file_path.file_id
122-
assert annot.start_index is not None
123-
assert annot.text is not None
112+
for annotation in msg.text.annotations:
113+
if annotation.type == "file_citation":
114+
assert annotation.end_index is not None
115+
assert annotation.file_citation.file_id
116+
assert annotation.file_citation.quote
117+
assert annotation.start_index is not None
118+
assert annotation.text is not None
119+
elif annotation.type == "file_path":
120+
assert annotation.end_index is not None
121+
assert annotation.file_path.file_id
122+
assert annotation.start_index is not None
123+
assert annotation.text is not None
124124

125125
def on_text_created(self, text: Text):
126126
assert text.value is not None
127127

128128
def on_text_done(self, text: Text):
129129
assert text.value is not None
130-
for annot in text.annotations:
131-
if annot.type == "file_citation":
132-
assert annot.end_index is not None
133-
assert annot.file_citation.file_id
134-
assert annot.file_citation.quote
135-
assert annot.start_index is not None
136-
assert annot.text is not None
137-
elif annot.type == "file_path":
138-
assert annot.end_index is not None
139-
assert annot.file_path.file_id
140-
assert annot.start_index is not None
141-
assert annot.text is not None
130+
for annotation in text.annotations:
131+
if annotation.type == "file_citation":
132+
assert annotation.end_index is not None
133+
assert annotation.file_citation.file_id
134+
assert annotation.file_citation.quote
135+
assert annotation.start_index is not None
136+
assert annotation.text is not None
137+
elif annotation.type == "file_path":
138+
assert annotation.end_index is not None
139+
assert annotation.file_path.file_id
140+
assert annotation.start_index is not None
141+
assert annotation.text is not None
142142

143143
def on_image_file_done(self, image_file: ImageFile):
144144
assert image_file.file_id
@@ -179,6 +179,7 @@ def on_tool_call_done(self, tool_call: ToolCall):
179179
assert tool_call.function.name is not None
180180

181181

182+
@pytest.mark.live_test_only
182183
class TestAssistants(AzureRecordedTestCase):
183184

184185
def handle_run_failure(self, run: Run):

sdk/openai/azure-openai/tests/test_assistants_async.py

Lines changed: 35 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -87,16 +87,16 @@ async def on_message_delta(self, delta: MessageDelta, snapshot: Message):
8787
if content.text.value:
8888
assert content.text.value is not None
8989
if content.text.annotations:
90-
for annot in content.text.annotations:
91-
if annot.type == "file_citation":
92-
assert annot.end_index is not None
93-
assert annot.file_citation.file_id
94-
assert annot.file_citation.quote
95-
assert annot.start_index is not None
96-
elif annot.type == "file_path":
97-
assert annot.end_index is not None
98-
assert annot.file_path.file_id
99-
assert annot.start_index is not None
90+
for annotation in content.text.annotations:
91+
if annotation.type == "file_citation":
92+
assert annotation.end_index is not None
93+
assert annotation.file_citation.file_id
94+
assert annotation.file_citation.quote
95+
assert annotation.start_index is not None
96+
elif annotation.type == "file_path":
97+
assert annotation.end_index is not None
98+
assert annotation.file_path.file_id
99+
assert annotation.start_index is not None
100100
elif content.type == "image_file":
101101
assert content.index is not None
102102
assert content.image_file.file_id
@@ -108,36 +108,36 @@ async def on_message_done(self, message: Message):
108108
if msg.type == "text":
109109
assert msg.text.value
110110
if msg.text.annotations:
111-
for annot in msg.text.annotations:
112-
if annot.type == "file_citation":
113-
assert annot.end_index is not None
114-
assert annot.file_citation.file_id
115-
assert annot.file_citation.quote
116-
assert annot.start_index is not None
117-
assert annot.text is not None
118-
elif annot.type == "file_path":
119-
assert annot.end_index is not None
120-
assert annot.file_path.file_id
121-
assert annot.start_index is not None
122-
assert annot.text is not None
111+
for annotation in msg.text.annotations:
112+
if annotation.type == "file_citation":
113+
assert annotation.end_index is not None
114+
assert annotation.file_citation.file_id
115+
assert annotation.file_citation.quote
116+
assert annotation.start_index is not None
117+
assert annotation.text is not None
118+
elif annotation.type == "file_path":
119+
assert annotation.end_index is not None
120+
assert annotation.file_path.file_id
121+
assert annotation.start_index is not None
122+
assert annotation.text is not None
123123

124124
async def on_text_created(self, text: Text):
125125
assert text.value is not None
126126

127127
async def on_text_done(self, text: Text):
128128
assert text.value is not None
129-
for annot in text.annotations:
130-
if annot.type == "file_citation":
131-
assert annot.end_index is not None
132-
assert annot.file_citation.file_id
133-
assert annot.file_citation.quote
134-
assert annot.start_index is not None
135-
assert annot.text is not None
136-
elif annot.type == "file_path":
137-
assert annot.end_index is not None
138-
assert annot.file_path.file_id
139-
assert annot.start_index is not None
140-
assert annot.text is not None
129+
for annotation in text.annotations:
130+
if annotation.type == "file_citation":
131+
assert annotation.end_index is not None
132+
assert annotation.file_citation.file_id
133+
assert annotation.file_citation.quote
134+
assert annotation.start_index is not None
135+
assert annotation.text is not None
136+
elif annotation.type == "file_path":
137+
assert annotation.end_index is not None
138+
assert annotation.file_path.file_id
139+
assert annotation.start_index is not None
140+
assert annotation.text is not None
141141

142142
async def on_image_file_done(self, image_file: ImageFile):
143143
assert image_file.file_id
@@ -178,6 +178,7 @@ async def on_tool_call_done(self, tool_call: ToolCall):
178178
assert tool_call.function.name is not None
179179

180180

181+
@pytest.mark.live_test_only
181182
class TestAssistantsAsync(AzureRecordedTestCase):
182183

183184
def handle_run_failure(self, run: Run):

sdk/openai/azure-openai/tests/test_audio.py

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
audio_long_test_file = pathlib.Path(__file__).parent / "./assets/wikipediaOcelot.wav"
1515

1616

17+
@pytest.mark.live_test_only
1718
class TestAudio(AzureRecordedTestCase):
1819

1920
@configure
@@ -87,16 +88,16 @@ def test_transcribe_verbose(self, client, api_type, api_version, **kwargs):
8788
assert result.language == "english"
8889
assert result.duration == 56.25
8990
for segment in result.segments:
90-
assert segment["id"] is not None
91-
assert segment["seek"] is not None
92-
assert segment["start"] is not None
93-
assert segment["end"] is not None
94-
assert segment["text"] is not None
95-
assert segment["tokens"] is not None
96-
assert segment["temperature"] is not None
97-
assert segment["avg_logprob"] is not None
98-
assert segment["compression_ratio"] is not None
99-
assert segment["no_speech_prob"] is not None
91+
assert segment.id is not None
92+
assert segment.seek is not None
93+
assert segment.start is not None
94+
assert segment.end is not None
95+
assert segment.text is not None
96+
assert segment.tokens is not None
97+
assert segment.temperature is not None
98+
assert segment.avg_logprob is not None
99+
assert segment.compression_ratio is not None
100+
assert segment.no_speech_prob is not None
100101

101102
@configure
102103
@pytest.mark.parametrize("api_type, api_version", [(WHISPER_AZURE, GA), (WHISPER_AZURE, PREVIEW), (OPENAI, "v1")])
@@ -152,16 +153,16 @@ def test_translate_verbose(self, client, api_type, api_version, **kwargs):
152153
assert result.language == "english"
153154
assert result.duration == 56.25
154155
for segment in result.segments:
155-
assert segment["id"] is not None
156-
assert segment["seek"] is not None
157-
assert segment["start"] is not None
158-
assert segment["end"] is not None
159-
assert segment["text"] is not None
160-
assert segment["tokens"] is not None
161-
assert segment["temperature"] is not None
162-
assert segment["avg_logprob"] is not None
163-
assert segment["compression_ratio"] is not None
164-
assert segment["no_speech_prob"] is not None
156+
assert segment.id is not None
157+
assert segment.seek is not None
158+
assert segment.start is not None
159+
assert segment.end is not None
160+
assert segment.text is not None
161+
assert segment.tokens is not None
162+
assert segment.temperature is not None
163+
assert segment.avg_logprob is not None
164+
assert segment.compression_ratio is not None
165+
assert segment.no_speech_prob is not None
165166

166167
@configure
167168
@pytest.mark.parametrize("api_type, api_version", [(WHISPER_AZURE, GA), (WHISPER_AZURE, PREVIEW), (OPENAI, "v1")])

sdk/openai/azure-openai/tests/test_audio_async.py

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
audio_long_test_file = pathlib.Path(__file__).parent / "./assets/wikipediaOcelot.wav"
1515

1616

17+
@pytest.mark.live_test_only
1718
class TestAudioAsync(AzureRecordedTestCase):
1819

1920
@configure_async
@@ -92,16 +93,16 @@ async def test_transcribe_verbose(self, client_async, api_type, api_version, **k
9293
assert result.language == "english"
9394
assert result.duration == 56.25
9495
for segment in result.segments:
95-
assert segment["id"] is not None
96-
assert segment["seek"] is not None
97-
assert segment["start"] is not None
98-
assert segment["end"] is not None
99-
assert segment["text"] is not None
100-
assert segment["tokens"] is not None
101-
assert segment["temperature"] is not None
102-
assert segment["avg_logprob"] is not None
103-
assert segment["compression_ratio"] is not None
104-
assert segment["no_speech_prob"] is not None
96+
assert segment.id is not None
97+
assert segment.seek is not None
98+
assert segment.start is not None
99+
assert segment.end is not None
100+
assert segment.text is not None
101+
assert segment.tokens is not None
102+
assert segment.temperature is not None
103+
assert segment.avg_logprob is not None
104+
assert segment.compression_ratio is not None
105+
assert segment.no_speech_prob is not None
105106

106107
@configure_async
107108
@pytest.mark.asyncio
@@ -161,16 +162,16 @@ async def test_translate_verbose(self, client_async, api_type, api_version, **kw
161162
assert result.language == "english"
162163
assert result.duration == 56.25
163164
for segment in result.segments:
164-
assert segment["id"] is not None
165-
assert segment["seek"] is not None
166-
assert segment["start"] is not None
167-
assert segment["end"] is not None
168-
assert segment["text"] is not None
169-
assert segment["tokens"] is not None
170-
assert segment["temperature"] is not None
171-
assert segment["avg_logprob"] is not None
172-
assert segment["compression_ratio"] is not None
173-
assert segment["no_speech_prob"] is not None
165+
assert segment.id is not None
166+
assert segment.seek is not None
167+
assert segment.start is not None
168+
assert segment.end is not None
169+
assert segment.text is not None
170+
assert segment.tokens is not None
171+
assert segment.temperature is not None
172+
assert segment.avg_logprob is not None
173+
assert segment.compression_ratio is not None
174+
assert segment.no_speech_prob is not None
174175

175176
@configure_async
176177
@pytest.mark.asyncio

sdk/openai/azure-openai/tests/test_chat_completions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
)
2525

2626

27+
@pytest.mark.live_test_only
2728
class TestChatCompletions(AzureRecordedTestCase):
2829

2930
@configure

sdk/openai/azure-openai/tests/test_chat_completions_async.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
)
2525

2626

27+
@pytest.mark.live_test_only
2728
class TestChatCompletionsAsync(AzureRecordedTestCase):
2829

2930
@configure_async

sdk/openai/azure-openai/tests/test_cli.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
audio_test_file = pathlib.Path(__file__).parent / "./assets/hello.m4a"
2424

2525

26+
@pytest.mark.live_test_only
2627
class TestCLI(AzureRecordedTestCase):
2728
"""No support for embeddings CLI cmd"""
2829

sdk/openai/azure-openai/tests/test_client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
)
2121

2222

23+
@pytest.mark.live_test_only
2324
class TestClient(AzureRecordedTestCase):
2425
"""Azure AD with token provider is missing here because it is tested per feature"""
2526

sdk/openai/azure-openai/tests/test_client_async.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
)
2121

2222

23+
@pytest.mark.live_test_only
2324
class TestClientAsync(AzureRecordedTestCase):
2425
"""Azure AD with token provider is missing here because it is tested per feature"""
2526

sdk/openai/azure-openai/tests/test_completions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from conftest import AZURE, OPENAI, PREVIEW, GA, configure
1111

1212

13+
@pytest.mark.live_test_only
1314
class TestCompletions(AzureRecordedTestCase):
1415
"""Missing tests for keyword argument `suffix`"""
1516

sdk/openai/azure-openai/tests/test_completions_async.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from conftest import AZURE, OPENAI, PREVIEW, GA, configure_async
1010

1111

12+
@pytest.mark.live_test_only
1213
class TestCompletionsAsync(AzureRecordedTestCase):
1314
"""Missing tests for keyword argument `suffix`"""
1415

sdk/openai/azure-openai/tests/test_dall_e.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from conftest import configure, DALLE_AZURE, OPENAI, PREVIEW, GA
1010

1111

12+
@pytest.mark.live_test_only
1213
class TestDallE(AzureRecordedTestCase):
1314

1415
@configure

0 commit comments

Comments
 (0)