openai/openai-python

Public

mirrored from https://github.com/openai/openai-pythonAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v1.86.0

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

tests/api_resources/fine_tuning/test_jobs.py

688lines · modecode

1# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
3from __future__ import annotations
4
5import os
6from typing import Any, cast
7
8import pytest
9
10from openai import OpenAI, AsyncOpenAI
11from tests.utils import assert_matches_type
12from openai.pagination import SyncCursorPage, AsyncCursorPage
13from openai.types.fine_tuning import (
14 FineTuningJob,
15 FineTuningJobEvent,
16)
17
18base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
19
20
21class TestJobs:
22 parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"])
23
24 @parametrize
25 def test_method_create(self, client: OpenAI) -> None:
26 job = client.fine_tuning.jobs.create(
27 model="gpt-4o-mini",
28 training_file="file-abc123",
29 )
30 assert_matches_type(FineTuningJob, job, path=["response"])
31
32 @parametrize
33 def test_method_create_with_all_params(self, client: OpenAI) -> None:
34 job = client.fine_tuning.jobs.create(
35 model="gpt-4o-mini",
36 training_file="file-abc123",
37 hyperparameters={
38 "batch_size": "auto",
39 "learning_rate_multiplier": "auto",
40 "n_epochs": "auto",
41 },
42 integrations=[
43 {
44 "type": "wandb",
45 "wandb": {
46 "project": "my-wandb-project",
47 "entity": "entity",
48 "name": "name",
49 "tags": ["custom-tag"],
50 },
51 }
52 ],
53 metadata={"foo": "string"},
54 method={
55 "type": "supervised",
56 "dpo": {
57 "hyperparameters": {
58 "batch_size": "auto",
59 "beta": "auto",
60 "learning_rate_multiplier": "auto",
61 "n_epochs": "auto",
62 }
63 },
64 "reinforcement": {
65 "grader": {
66 "input": "input",
67 "name": "name",
68 "operation": "eq",
69 "reference": "reference",
70 "type": "string_check",
71 },
72 "hyperparameters": {
73 "batch_size": "auto",
74 "compute_multiplier": "auto",
75 "eval_interval": "auto",
76 "eval_samples": "auto",
77 "learning_rate_multiplier": "auto",
78 "n_epochs": "auto",
79 "reasoning_effort": "default",
80 },
81 },
82 "supervised": {
83 "hyperparameters": {
84 "batch_size": "auto",
85 "learning_rate_multiplier": "auto",
86 "n_epochs": "auto",
87 }
88 },
89 },
90 seed=42,
91 suffix="x",
92 validation_file="file-abc123",
93 )
94 assert_matches_type(FineTuningJob, job, path=["response"])
95
96 @parametrize
97 def test_raw_response_create(self, client: OpenAI) -> None:
98 response = client.fine_tuning.jobs.with_raw_response.create(
99 model="gpt-4o-mini",
100 training_file="file-abc123",
101 )
102
103 assert response.is_closed is True
104 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
105 job = response.parse()
106 assert_matches_type(FineTuningJob, job, path=["response"])
107
108 @parametrize
109 def test_streaming_response_create(self, client: OpenAI) -> None:
110 with client.fine_tuning.jobs.with_streaming_response.create(
111 model="gpt-4o-mini",
112 training_file="file-abc123",
113 ) as response:
114 assert not response.is_closed
115 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
116
117 job = response.parse()
118 assert_matches_type(FineTuningJob, job, path=["response"])
119
120 assert cast(Any, response.is_closed) is True
121
122 @parametrize
123 def test_method_retrieve(self, client: OpenAI) -> None:
124 job = client.fine_tuning.jobs.retrieve(
125 "ft-AF1WoRqd3aJAHsqc9NY7iL8F",
126 )
127 assert_matches_type(FineTuningJob, job, path=["response"])
128
129 @parametrize
130 def test_raw_response_retrieve(self, client: OpenAI) -> None:
131 response = client.fine_tuning.jobs.with_raw_response.retrieve(
132 "ft-AF1WoRqd3aJAHsqc9NY7iL8F",
133 )
134
135 assert response.is_closed is True
136 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
137 job = response.parse()
138 assert_matches_type(FineTuningJob, job, path=["response"])
139
140 @parametrize
141 def test_streaming_response_retrieve(self, client: OpenAI) -> None:
142 with client.fine_tuning.jobs.with_streaming_response.retrieve(
143 "ft-AF1WoRqd3aJAHsqc9NY7iL8F",
144 ) as response:
145 assert not response.is_closed
146 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
147
148 job = response.parse()
149 assert_matches_type(FineTuningJob, job, path=["response"])
150
151 assert cast(Any, response.is_closed) is True
152
153 @parametrize
154 def test_path_params_retrieve(self, client: OpenAI) -> None:
155 with pytest.raises(ValueError, match=r"Expected a non-empty value for `fine_tuning_job_id` but received ''"):
156 client.fine_tuning.jobs.with_raw_response.retrieve(
157 "",
158 )
159
160 @parametrize
161 def test_method_list(self, client: OpenAI) -> None:
162 job = client.fine_tuning.jobs.list()
163 assert_matches_type(SyncCursorPage[FineTuningJob], job, path=["response"])
164
165 @parametrize
166 def test_method_list_with_all_params(self, client: OpenAI) -> None:
167 job = client.fine_tuning.jobs.list(
168 after="string",
169 limit=0,
170 metadata={"foo": "string"},
171 )
172 assert_matches_type(SyncCursorPage[FineTuningJob], job, path=["response"])
173
174 @parametrize
175 def test_raw_response_list(self, client: OpenAI) -> None:
176 response = client.fine_tuning.jobs.with_raw_response.list()
177
178 assert response.is_closed is True
179 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
180 job = response.parse()
181 assert_matches_type(SyncCursorPage[FineTuningJob], job, path=["response"])
182
183 @parametrize
184 def test_streaming_response_list(self, client: OpenAI) -> None:
185 with client.fine_tuning.jobs.with_streaming_response.list() as response:
186 assert not response.is_closed
187 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
188
189 job = response.parse()
190 assert_matches_type(SyncCursorPage[FineTuningJob], job, path=["response"])
191
192 assert cast(Any, response.is_closed) is True
193
194 @parametrize
195 def test_method_cancel(self, client: OpenAI) -> None:
196 job = client.fine_tuning.jobs.cancel(
197 "ft-AF1WoRqd3aJAHsqc9NY7iL8F",
198 )
199 assert_matches_type(FineTuningJob, job, path=["response"])
200
201 @parametrize
202 def test_raw_response_cancel(self, client: OpenAI) -> None:
203 response = client.fine_tuning.jobs.with_raw_response.cancel(
204 "ft-AF1WoRqd3aJAHsqc9NY7iL8F",
205 )
206
207 assert response.is_closed is True
208 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
209 job = response.parse()
210 assert_matches_type(FineTuningJob, job, path=["response"])
211
212 @parametrize
213 def test_streaming_response_cancel(self, client: OpenAI) -> None:
214 with client.fine_tuning.jobs.with_streaming_response.cancel(
215 "ft-AF1WoRqd3aJAHsqc9NY7iL8F",
216 ) as response:
217 assert not response.is_closed
218 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
219
220 job = response.parse()
221 assert_matches_type(FineTuningJob, job, path=["response"])
222
223 assert cast(Any, response.is_closed) is True
224
225 @parametrize
226 def test_path_params_cancel(self, client: OpenAI) -> None:
227 with pytest.raises(ValueError, match=r"Expected a non-empty value for `fine_tuning_job_id` but received ''"):
228 client.fine_tuning.jobs.with_raw_response.cancel(
229 "",
230 )
231
232 @parametrize
233 def test_method_list_events(self, client: OpenAI) -> None:
234 job = client.fine_tuning.jobs.list_events(
235 "ft-AF1WoRqd3aJAHsqc9NY7iL8F",
236 )
237 assert_matches_type(SyncCursorPage[FineTuningJobEvent], job, path=["response"])
238
239 @parametrize
240 def test_method_list_events_with_all_params(self, client: OpenAI) -> None:
241 job = client.fine_tuning.jobs.list_events(
242 "ft-AF1WoRqd3aJAHsqc9NY7iL8F",
243 after="string",
244 limit=0,
245 )
246 assert_matches_type(SyncCursorPage[FineTuningJobEvent], job, path=["response"])
247
248 @parametrize
249 def test_raw_response_list_events(self, client: OpenAI) -> None:
250 response = client.fine_tuning.jobs.with_raw_response.list_events(
251 "ft-AF1WoRqd3aJAHsqc9NY7iL8F",
252 )
253
254 assert response.is_closed is True
255 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
256 job = response.parse()
257 assert_matches_type(SyncCursorPage[FineTuningJobEvent], job, path=["response"])
258
259 @parametrize
260 def test_streaming_response_list_events(self, client: OpenAI) -> None:
261 with client.fine_tuning.jobs.with_streaming_response.list_events(
262 "ft-AF1WoRqd3aJAHsqc9NY7iL8F",
263 ) as response:
264 assert not response.is_closed
265 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
266
267 job = response.parse()
268 assert_matches_type(SyncCursorPage[FineTuningJobEvent], job, path=["response"])
269
270 assert cast(Any, response.is_closed) is True
271
272 @parametrize
273 def test_path_params_list_events(self, client: OpenAI) -> None:
274 with pytest.raises(ValueError, match=r"Expected a non-empty value for `fine_tuning_job_id` but received ''"):
275 client.fine_tuning.jobs.with_raw_response.list_events(
276 "",
277 )
278
279 @parametrize
280 def test_method_pause(self, client: OpenAI) -> None:
281 job = client.fine_tuning.jobs.pause(
282 "ft-AF1WoRqd3aJAHsqc9NY7iL8F",
283 )
284 assert_matches_type(FineTuningJob, job, path=["response"])
285
286 @parametrize
287 def test_raw_response_pause(self, client: OpenAI) -> None:
288 response = client.fine_tuning.jobs.with_raw_response.pause(
289 "ft-AF1WoRqd3aJAHsqc9NY7iL8F",
290 )
291
292 assert response.is_closed is True
293 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
294 job = response.parse()
295 assert_matches_type(FineTuningJob, job, path=["response"])
296
297 @parametrize
298 def test_streaming_response_pause(self, client: OpenAI) -> None:
299 with client.fine_tuning.jobs.with_streaming_response.pause(
300 "ft-AF1WoRqd3aJAHsqc9NY7iL8F",
301 ) as response:
302 assert not response.is_closed
303 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
304
305 job = response.parse()
306 assert_matches_type(FineTuningJob, job, path=["response"])
307
308 assert cast(Any, response.is_closed) is True
309
310 @parametrize
311 def test_path_params_pause(self, client: OpenAI) -> None:
312 with pytest.raises(ValueError, match=r"Expected a non-empty value for `fine_tuning_job_id` but received ''"):
313 client.fine_tuning.jobs.with_raw_response.pause(
314 "",
315 )
316
317 @parametrize
318 def test_method_resume(self, client: OpenAI) -> None:
319 job = client.fine_tuning.jobs.resume(
320 "ft-AF1WoRqd3aJAHsqc9NY7iL8F",
321 )
322 assert_matches_type(FineTuningJob, job, path=["response"])
323
324 @parametrize
325 def test_raw_response_resume(self, client: OpenAI) -> None:
326 response = client.fine_tuning.jobs.with_raw_response.resume(
327 "ft-AF1WoRqd3aJAHsqc9NY7iL8F",
328 )
329
330 assert response.is_closed is True
331 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
332 job = response.parse()
333 assert_matches_type(FineTuningJob, job, path=["response"])
334
335 @parametrize
336 def test_streaming_response_resume(self, client: OpenAI) -> None:
337 with client.fine_tuning.jobs.with_streaming_response.resume(
338 "ft-AF1WoRqd3aJAHsqc9NY7iL8F",
339 ) as response:
340 assert not response.is_closed
341 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
342
343 job = response.parse()
344 assert_matches_type(FineTuningJob, job, path=["response"])
345
346 assert cast(Any, response.is_closed) is True
347
348 @parametrize
349 def test_path_params_resume(self, client: OpenAI) -> None:
350 with pytest.raises(ValueError, match=r"Expected a non-empty value for `fine_tuning_job_id` but received ''"):
351 client.fine_tuning.jobs.with_raw_response.resume(
352 "",
353 )
354
355
356class TestAsyncJobs:
357 parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"])
358
359 @parametrize
360 async def test_method_create(self, async_client: AsyncOpenAI) -> None:
361 job = await async_client.fine_tuning.jobs.create(
362 model="gpt-4o-mini",
363 training_file="file-abc123",
364 )
365 assert_matches_type(FineTuningJob, job, path=["response"])
366
367 @parametrize
368 async def test_method_create_with_all_params(self, async_client: AsyncOpenAI) -> None:
369 job = await async_client.fine_tuning.jobs.create(
370 model="gpt-4o-mini",
371 training_file="file-abc123",
372 hyperparameters={
373 "batch_size": "auto",
374 "learning_rate_multiplier": "auto",
375 "n_epochs": "auto",
376 },
377 integrations=[
378 {
379 "type": "wandb",
380 "wandb": {
381 "project": "my-wandb-project",
382 "entity": "entity",
383 "name": "name",
384 "tags": ["custom-tag"],
385 },
386 }
387 ],
388 metadata={"foo": "string"},
389 method={
390 "type": "supervised",
391 "dpo": {
392 "hyperparameters": {
393 "batch_size": "auto",
394 "beta": "auto",
395 "learning_rate_multiplier": "auto",
396 "n_epochs": "auto",
397 }
398 },
399 "reinforcement": {
400 "grader": {
401 "input": "input",
402 "name": "name",
403 "operation": "eq",
404 "reference": "reference",
405 "type": "string_check",
406 },
407 "hyperparameters": {
408 "batch_size": "auto",
409 "compute_multiplier": "auto",
410 "eval_interval": "auto",
411 "eval_samples": "auto",
412 "learning_rate_multiplier": "auto",
413 "n_epochs": "auto",
414 "reasoning_effort": "default",
415 },
416 },
417 "supervised": {
418 "hyperparameters": {
419 "batch_size": "auto",
420 "learning_rate_multiplier": "auto",
421 "n_epochs": "auto",
422 }
423 },
424 },
425 seed=42,
426 suffix="x",
427 validation_file="file-abc123",
428 )
429 assert_matches_type(FineTuningJob, job, path=["response"])
430
431 @parametrize
432 async def test_raw_response_create(self, async_client: AsyncOpenAI) -> None:
433 response = await async_client.fine_tuning.jobs.with_raw_response.create(
434 model="gpt-4o-mini",
435 training_file="file-abc123",
436 )
437
438 assert response.is_closed is True
439 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
440 job = response.parse()
441 assert_matches_type(FineTuningJob, job, path=["response"])
442
443 @parametrize
444 async def test_streaming_response_create(self, async_client: AsyncOpenAI) -> None:
445 async with async_client.fine_tuning.jobs.with_streaming_response.create(
446 model="gpt-4o-mini",
447 training_file="file-abc123",
448 ) as response:
449 assert not response.is_closed
450 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
451
452 job = await response.parse()
453 assert_matches_type(FineTuningJob, job, path=["response"])
454
455 assert cast(Any, response.is_closed) is True
456
457 @parametrize
458 async def test_method_retrieve(self, async_client: AsyncOpenAI) -> None:
459 job = await async_client.fine_tuning.jobs.retrieve(
460 "ft-AF1WoRqd3aJAHsqc9NY7iL8F",
461 )
462 assert_matches_type(FineTuningJob, job, path=["response"])
463
464 @parametrize
465 async def test_raw_response_retrieve(self, async_client: AsyncOpenAI) -> None:
466 response = await async_client.fine_tuning.jobs.with_raw_response.retrieve(
467 "ft-AF1WoRqd3aJAHsqc9NY7iL8F",
468 )
469
470 assert response.is_closed is True
471 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
472 job = response.parse()
473 assert_matches_type(FineTuningJob, job, path=["response"])
474
475 @parametrize
476 async def test_streaming_response_retrieve(self, async_client: AsyncOpenAI) -> None:
477 async with async_client.fine_tuning.jobs.with_streaming_response.retrieve(
478 "ft-AF1WoRqd3aJAHsqc9NY7iL8F",
479 ) as response:
480 assert not response.is_closed
481 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
482
483 job = await response.parse()
484 assert_matches_type(FineTuningJob, job, path=["response"])
485
486 assert cast(Any, response.is_closed) is True
487
488 @parametrize
489 async def test_path_params_retrieve(self, async_client: AsyncOpenAI) -> None:
490 with pytest.raises(ValueError, match=r"Expected a non-empty value for `fine_tuning_job_id` but received ''"):
491 await async_client.fine_tuning.jobs.with_raw_response.retrieve(
492 "",
493 )
494
495 @parametrize
496 async def test_method_list(self, async_client: AsyncOpenAI) -> None:
497 job = await async_client.fine_tuning.jobs.list()
498 assert_matches_type(AsyncCursorPage[FineTuningJob], job, path=["response"])
499
500 @parametrize
501 async def test_method_list_with_all_params(self, async_client: AsyncOpenAI) -> None:
502 job = await async_client.fine_tuning.jobs.list(
503 after="string",
504 limit=0,
505 metadata={"foo": "string"},
506 )
507 assert_matches_type(AsyncCursorPage[FineTuningJob], job, path=["response"])
508
509 @parametrize
510 async def test_raw_response_list(self, async_client: AsyncOpenAI) -> None:
511 response = await async_client.fine_tuning.jobs.with_raw_response.list()
512
513 assert response.is_closed is True
514 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
515 job = response.parse()
516 assert_matches_type(AsyncCursorPage[FineTuningJob], job, path=["response"])
517
518 @parametrize
519 async def test_streaming_response_list(self, async_client: AsyncOpenAI) -> None:
520 async with async_client.fine_tuning.jobs.with_streaming_response.list() as response:
521 assert not response.is_closed
522 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
523
524 job = await response.parse()
525 assert_matches_type(AsyncCursorPage[FineTuningJob], job, path=["response"])
526
527 assert cast(Any, response.is_closed) is True
528
529 @parametrize
530 async def test_method_cancel(self, async_client: AsyncOpenAI) -> None:
531 job = await async_client.fine_tuning.jobs.cancel(
532 "ft-AF1WoRqd3aJAHsqc9NY7iL8F",
533 )
534 assert_matches_type(FineTuningJob, job, path=["response"])
535
536 @parametrize
537 async def test_raw_response_cancel(self, async_client: AsyncOpenAI) -> None:
538 response = await async_client.fine_tuning.jobs.with_raw_response.cancel(
539 "ft-AF1WoRqd3aJAHsqc9NY7iL8F",
540 )
541
542 assert response.is_closed is True
543 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
544 job = response.parse()
545 assert_matches_type(FineTuningJob, job, path=["response"])
546
547 @parametrize
548 async def test_streaming_response_cancel(self, async_client: AsyncOpenAI) -> None:
549 async with async_client.fine_tuning.jobs.with_streaming_response.cancel(
550 "ft-AF1WoRqd3aJAHsqc9NY7iL8F",
551 ) as response:
552 assert not response.is_closed
553 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
554
555 job = await response.parse()
556 assert_matches_type(FineTuningJob, job, path=["response"])
557
558 assert cast(Any, response.is_closed) is True
559
560 @parametrize
561 async def test_path_params_cancel(self, async_client: AsyncOpenAI) -> None:
562 with pytest.raises(ValueError, match=r"Expected a non-empty value for `fine_tuning_job_id` but received ''"):
563 await async_client.fine_tuning.jobs.with_raw_response.cancel(
564 "",
565 )
566
567 @parametrize
568 async def test_method_list_events(self, async_client: AsyncOpenAI) -> None:
569 job = await async_client.fine_tuning.jobs.list_events(
570 "ft-AF1WoRqd3aJAHsqc9NY7iL8F",
571 )
572 assert_matches_type(AsyncCursorPage[FineTuningJobEvent], job, path=["response"])
573
574 @parametrize
575 async def test_method_list_events_with_all_params(self, async_client: AsyncOpenAI) -> None:
576 job = await async_client.fine_tuning.jobs.list_events(
577 "ft-AF1WoRqd3aJAHsqc9NY7iL8F",
578 after="string",
579 limit=0,
580 )
581 assert_matches_type(AsyncCursorPage[FineTuningJobEvent], job, path=["response"])
582
583 @parametrize
584 async def test_raw_response_list_events(self, async_client: AsyncOpenAI) -> None:
585 response = await async_client.fine_tuning.jobs.with_raw_response.list_events(
586 "ft-AF1WoRqd3aJAHsqc9NY7iL8F",
587 )
588
589 assert response.is_closed is True
590 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
591 job = response.parse()
592 assert_matches_type(AsyncCursorPage[FineTuningJobEvent], job, path=["response"])
593
594 @parametrize
595 async def test_streaming_response_list_events(self, async_client: AsyncOpenAI) -> None:
596 async with async_client.fine_tuning.jobs.with_streaming_response.list_events(
597 "ft-AF1WoRqd3aJAHsqc9NY7iL8F",
598 ) as response:
599 assert not response.is_closed
600 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
601
602 job = await response.parse()
603 assert_matches_type(AsyncCursorPage[FineTuningJobEvent], job, path=["response"])
604
605 assert cast(Any, response.is_closed) is True
606
607 @parametrize
608 async def test_path_params_list_events(self, async_client: AsyncOpenAI) -> None:
609 with pytest.raises(ValueError, match=r"Expected a non-empty value for `fine_tuning_job_id` but received ''"):
610 await async_client.fine_tuning.jobs.with_raw_response.list_events(
611 "",
612 )
613
614 @parametrize
615 async def test_method_pause(self, async_client: AsyncOpenAI) -> None:
616 job = await async_client.fine_tuning.jobs.pause(
617 "ft-AF1WoRqd3aJAHsqc9NY7iL8F",
618 )
619 assert_matches_type(FineTuningJob, job, path=["response"])
620
621 @parametrize
622 async def test_raw_response_pause(self, async_client: AsyncOpenAI) -> None:
623 response = await async_client.fine_tuning.jobs.with_raw_response.pause(
624 "ft-AF1WoRqd3aJAHsqc9NY7iL8F",
625 )
626
627 assert response.is_closed is True
628 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
629 job = response.parse()
630 assert_matches_type(FineTuningJob, job, path=["response"])
631
632 @parametrize
633 async def test_streaming_response_pause(self, async_client: AsyncOpenAI) -> None:
634 async with async_client.fine_tuning.jobs.with_streaming_response.pause(
635 "ft-AF1WoRqd3aJAHsqc9NY7iL8F",
636 ) as response:
637 assert not response.is_closed
638 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
639
640 job = await response.parse()
641 assert_matches_type(FineTuningJob, job, path=["response"])
642
643 assert cast(Any, response.is_closed) is True
644
645 @parametrize
646 async def test_path_params_pause(self, async_client: AsyncOpenAI) -> None:
647 with pytest.raises(ValueError, match=r"Expected a non-empty value for `fine_tuning_job_id` but received ''"):
648 await async_client.fine_tuning.jobs.with_raw_response.pause(
649 "",
650 )
651
652 @parametrize
653 async def test_method_resume(self, async_client: AsyncOpenAI) -> None:
654 job = await async_client.fine_tuning.jobs.resume(
655 "ft-AF1WoRqd3aJAHsqc9NY7iL8F",
656 )
657 assert_matches_type(FineTuningJob, job, path=["response"])
658
659 @parametrize
660 async def test_raw_response_resume(self, async_client: AsyncOpenAI) -> None:
661 response = await async_client.fine_tuning.jobs.with_raw_response.resume(
662 "ft-AF1WoRqd3aJAHsqc9NY7iL8F",
663 )
664
665 assert response.is_closed is True
666 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
667 job = response.parse()
668 assert_matches_type(FineTuningJob, job, path=["response"])
669
670 @parametrize
671 async def test_streaming_response_resume(self, async_client: AsyncOpenAI) -> None:
672 async with async_client.fine_tuning.jobs.with_streaming_response.resume(
673 "ft-AF1WoRqd3aJAHsqc9NY7iL8F",
674 ) as response:
675 assert not response.is_closed
676 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
677
678 job = await response.parse()
679 assert_matches_type(FineTuningJob, job, path=["response"])
680
681 assert cast(Any, response.is_closed) is True
682
683 @parametrize
684 async def test_path_params_resume(self, async_client: AsyncOpenAI) -> None:
685 with pytest.raises(ValueError, match=r"Expected a non-empty value for `fine_tuning_job_id` but received ''"):
686 await async_client.fine_tuning.jobs.with_raw_response.resume(
687 "",
688 )
689