openai/openai-python

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
next

Branches

Tags

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

Clone

HTTPS

Download ZIP

tests/api_resources/fine_tuning/test_jobs.py

690lines · modeblame

5cfb125aStainless Bot2 years ago1# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
08b8179aDavid Schnurr2 years ago2
3from __future__ import annotations
4
5import os
86379b44Stainless Bot2 years ago6from typing import Any, cast
08b8179aDavid Schnurr2 years ago7
8import pytest
9
10from openai import OpenAI, AsyncOpenAI
11from tests.utils import assert_matches_type
12from openai.pagination import SyncCursorPage, AsyncCursorPage
4a0f0fa0Stainless Bot2 years ago13from openai.types.fine_tuning import (
14FineTuningJob,
15FineTuningJobEvent,
16)
08b8179aDavid Schnurr2 years ago17
18base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
19
20
21class TestJobs:
98d779fbStainless Bot2 years ago22parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"])
08b8179aDavid Schnurr2 years ago23
24@parametrize
25def test_method_create(self, client: OpenAI) -> None:
26job = client.fine_tuning.jobs.create(
bf1ca86cRobert Craigie1 years ago27model="gpt-4o-mini",
08b8179aDavid Schnurr2 years ago28training_file="file-abc123",
29)
30assert_matches_type(FineTuningJob, job, path=["response"])
31
32@parametrize
33def test_method_create_with_all_params(self, client: OpenAI) -> None:
34job = client.fine_tuning.jobs.create(
bf1ca86cRobert Craigie1 years ago35model="gpt-4o-mini",
08b8179aDavid Schnurr2 years ago36training_file="file-abc123",
baa9f07fRobert Craigie2 years ago37hyperparameters={
38"batch_size": "auto",
39"learning_rate_multiplier": "auto",
40"n_epochs": "auto",
41},
f5247e30Stainless Bot2 years ago42integrations=[
43{
44"type": "wandb",
45"wandb": {
46"project": "my-wandb-project",
092a8df7Stainless Bot1 years ago47"entity": "entity",
48"name": "name",
dd19d4f9Stainless Bot1 years ago49"tags": ["custom-tag"],
f5247e30Stainless Bot2 years ago50},
dd19d4f9Stainless Bot1 years ago51}
f5247e30Stainless Bot2 years ago52],
5608d64bstainless-app[bot]1 years ago53metadata={"foo": "string"},
575ff607stainless-app[bot]1 years ago54method={
a3b8e772stainless-app[bot]1 years ago55"type": "supervised",
575ff607stainless-app[bot]1 years ago56"dpo": {
57"hyperparameters": {
58"batch_size": "auto",
59"beta": "auto",
60"learning_rate_multiplier": "auto",
61"n_epochs": "auto",
62}
63},
a3b8e772stainless-app[bot]1 years ago64"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},
575ff607stainless-app[bot]1 years ago82"supervised": {
83"hyperparameters": {
84"batch_size": "auto",
85"learning_rate_multiplier": "auto",
86"n_epochs": "auto",
87}
88},
89},
f5247e30Stainless Bot2 years ago90seed=42,
08b8179aDavid Schnurr2 years ago91suffix="x",
92validation_file="file-abc123",
93)
94assert_matches_type(FineTuningJob, job, path=["response"])
95
96@parametrize
97def test_raw_response_create(self, client: OpenAI) -> None:
98response = client.fine_tuning.jobs.with_raw_response.create(
bf1ca86cRobert Craigie1 years ago99model="gpt-4o-mini",
08b8179aDavid Schnurr2 years ago100training_file="file-abc123",
101)
86379b44Stainless Bot2 years ago102
103assert response.is_closed is True
08b8179aDavid Schnurr2 years ago104assert response.http_request.headers.get("X-Stainless-Lang") == "python"
105job = response.parse()
106assert_matches_type(FineTuningJob, job, path=["response"])
107
86379b44Stainless Bot2 years ago108@parametrize
109def test_streaming_response_create(self, client: OpenAI) -> None:
110with client.fine_tuning.jobs.with_streaming_response.create(
bf1ca86cRobert Craigie1 years ago111model="gpt-4o-mini",
86379b44Stainless Bot2 years ago112training_file="file-abc123",
113) as response:
114assert not response.is_closed
115assert response.http_request.headers.get("X-Stainless-Lang") == "python"
116
117job = response.parse()
118assert_matches_type(FineTuningJob, job, path=["response"])
119
120assert cast(Any, response.is_closed) is True
121
08b8179aDavid Schnurr2 years ago122@parametrize
123def test_method_retrieve(self, client: OpenAI) -> None:
124job = client.fine_tuning.jobs.retrieve(
125"ft-AF1WoRqd3aJAHsqc9NY7iL8F",
126)
127assert_matches_type(FineTuningJob, job, path=["response"])
128
129@parametrize
130def test_raw_response_retrieve(self, client: OpenAI) -> None:
131response = client.fine_tuning.jobs.with_raw_response.retrieve(
132"ft-AF1WoRqd3aJAHsqc9NY7iL8F",
133)
86379b44Stainless Bot2 years ago134
135assert response.is_closed is True
08b8179aDavid Schnurr2 years ago136assert response.http_request.headers.get("X-Stainless-Lang") == "python"
137job = response.parse()
138assert_matches_type(FineTuningJob, job, path=["response"])
139
86379b44Stainless Bot2 years ago140@parametrize
141def test_streaming_response_retrieve(self, client: OpenAI) -> None:
142with client.fine_tuning.jobs.with_streaming_response.retrieve(
143"ft-AF1WoRqd3aJAHsqc9NY7iL8F",
144) as response:
145assert not response.is_closed
146assert response.http_request.headers.get("X-Stainless-Lang") == "python"
147
148job = response.parse()
149assert_matches_type(FineTuningJob, job, path=["response"])
150
151assert cast(Any, response.is_closed) is True
152
023a4e66Stainless Bot2 years ago153@parametrize
154def test_path_params_retrieve(self, client: OpenAI) -> None:
155with pytest.raises(ValueError, match=r"Expected a non-empty value for `fine_tuning_job_id` but received ''"):
156client.fine_tuning.jobs.with_raw_response.retrieve(
157"",
158)
159
08b8179aDavid Schnurr2 years ago160@parametrize
161def test_method_list(self, client: OpenAI) -> None:
162job = client.fine_tuning.jobs.list()
163assert_matches_type(SyncCursorPage[FineTuningJob], job, path=["response"])
164
165@parametrize
166def test_method_list_with_all_params(self, client: OpenAI) -> None:
167job = client.fine_tuning.jobs.list(
168after="string",
169limit=0,
5608d64bstainless-app[bot]1 years ago170metadata={"foo": "string"},
08b8179aDavid Schnurr2 years ago171)
172assert_matches_type(SyncCursorPage[FineTuningJob], job, path=["response"])
173
174@parametrize
175def test_raw_response_list(self, client: OpenAI) -> None:
176response = client.fine_tuning.jobs.with_raw_response.list()
86379b44Stainless Bot2 years ago177
178assert response.is_closed is True
08b8179aDavid Schnurr2 years ago179assert response.http_request.headers.get("X-Stainless-Lang") == "python"
180job = response.parse()
181assert_matches_type(SyncCursorPage[FineTuningJob], job, path=["response"])
182
86379b44Stainless Bot2 years ago183@parametrize
184def test_streaming_response_list(self, client: OpenAI) -> None:
185with client.fine_tuning.jobs.with_streaming_response.list() as response:
186assert not response.is_closed
187assert response.http_request.headers.get("X-Stainless-Lang") == "python"
188
189job = response.parse()
190assert_matches_type(SyncCursorPage[FineTuningJob], job, path=["response"])
191
192assert cast(Any, response.is_closed) is True
193
08b8179aDavid Schnurr2 years ago194@parametrize
195def test_method_cancel(self, client: OpenAI) -> None:
196job = client.fine_tuning.jobs.cancel(
197"ft-AF1WoRqd3aJAHsqc9NY7iL8F",
198)
199assert_matches_type(FineTuningJob, job, path=["response"])
200
201@parametrize
202def test_raw_response_cancel(self, client: OpenAI) -> None:
203response = client.fine_tuning.jobs.with_raw_response.cancel(
204"ft-AF1WoRqd3aJAHsqc9NY7iL8F",
205)
86379b44Stainless Bot2 years ago206
207assert response.is_closed is True
08b8179aDavid Schnurr2 years ago208assert response.http_request.headers.get("X-Stainless-Lang") == "python"
209job = response.parse()
210assert_matches_type(FineTuningJob, job, path=["response"])
211
86379b44Stainless Bot2 years ago212@parametrize
213def test_streaming_response_cancel(self, client: OpenAI) -> None:
214with client.fine_tuning.jobs.with_streaming_response.cancel(
215"ft-AF1WoRqd3aJAHsqc9NY7iL8F",
216) as response:
217assert not response.is_closed
218assert response.http_request.headers.get("X-Stainless-Lang") == "python"
219
220job = response.parse()
221assert_matches_type(FineTuningJob, job, path=["response"])
222
223assert cast(Any, response.is_closed) is True
224
023a4e66Stainless Bot2 years ago225@parametrize
226def test_path_params_cancel(self, client: OpenAI) -> None:
227with pytest.raises(ValueError, match=r"Expected a non-empty value for `fine_tuning_job_id` but received ''"):
228client.fine_tuning.jobs.with_raw_response.cancel(
229"",
230)
231
08b8179aDavid Schnurr2 years ago232@parametrize
233def test_method_list_events(self, client: OpenAI) -> None:
234job = client.fine_tuning.jobs.list_events(
235"ft-AF1WoRqd3aJAHsqc9NY7iL8F",
236)
237assert_matches_type(SyncCursorPage[FineTuningJobEvent], job, path=["response"])
238
239@parametrize
240def test_method_list_events_with_all_params(self, client: OpenAI) -> None:
241job = client.fine_tuning.jobs.list_events(
242"ft-AF1WoRqd3aJAHsqc9NY7iL8F",
243after="string",
244limit=0,
245)
246assert_matches_type(SyncCursorPage[FineTuningJobEvent], job, path=["response"])
247
248@parametrize
249def test_raw_response_list_events(self, client: OpenAI) -> None:
250response = client.fine_tuning.jobs.with_raw_response.list_events(
251"ft-AF1WoRqd3aJAHsqc9NY7iL8F",
252)
86379b44Stainless Bot2 years ago253
254assert response.is_closed is True
08b8179aDavid Schnurr2 years ago255assert response.http_request.headers.get("X-Stainless-Lang") == "python"
256job = response.parse()
257assert_matches_type(SyncCursorPage[FineTuningJobEvent], job, path=["response"])
258
86379b44Stainless Bot2 years ago259@parametrize
260def test_streaming_response_list_events(self, client: OpenAI) -> None:
261with client.fine_tuning.jobs.with_streaming_response.list_events(
262"ft-AF1WoRqd3aJAHsqc9NY7iL8F",
263) as response:
264assert not response.is_closed
265assert response.http_request.headers.get("X-Stainless-Lang") == "python"
266
267job = response.parse()
268assert_matches_type(SyncCursorPage[FineTuningJobEvent], job, path=["response"])
269
270assert cast(Any, response.is_closed) is True
271
023a4e66Stainless Bot2 years ago272@parametrize
273def test_path_params_list_events(self, client: OpenAI) -> None:
274with pytest.raises(ValueError, match=r"Expected a non-empty value for `fine_tuning_job_id` but received ''"):
275client.fine_tuning.jobs.with_raw_response.list_events(
276"",
277)
278
a3b8e772stainless-app[bot]1 years ago279@parametrize
280def test_method_pause(self, client: OpenAI) -> None:
281job = client.fine_tuning.jobs.pause(
282"ft-AF1WoRqd3aJAHsqc9NY7iL8F",
283)
284assert_matches_type(FineTuningJob, job, path=["response"])
285
286@parametrize
287def test_raw_response_pause(self, client: OpenAI) -> None:
288response = client.fine_tuning.jobs.with_raw_response.pause(
289"ft-AF1WoRqd3aJAHsqc9NY7iL8F",
290)
291
292assert response.is_closed is True
293assert response.http_request.headers.get("X-Stainless-Lang") == "python"
294job = response.parse()
295assert_matches_type(FineTuningJob, job, path=["response"])
296
297@parametrize
298def test_streaming_response_pause(self, client: OpenAI) -> None:
299with client.fine_tuning.jobs.with_streaming_response.pause(
300"ft-AF1WoRqd3aJAHsqc9NY7iL8F",
301) as response:
302assert not response.is_closed
303assert response.http_request.headers.get("X-Stainless-Lang") == "python"
304
305job = response.parse()
306assert_matches_type(FineTuningJob, job, path=["response"])
307
308assert cast(Any, response.is_closed) is True
309
310@parametrize
311def test_path_params_pause(self, client: OpenAI) -> None:
312with pytest.raises(ValueError, match=r"Expected a non-empty value for `fine_tuning_job_id` but received ''"):
313client.fine_tuning.jobs.with_raw_response.pause(
314"",
315)
316
317@parametrize
318def test_method_resume(self, client: OpenAI) -> None:
319job = client.fine_tuning.jobs.resume(
320"ft-AF1WoRqd3aJAHsqc9NY7iL8F",
321)
322assert_matches_type(FineTuningJob, job, path=["response"])
323
324@parametrize
325def test_raw_response_resume(self, client: OpenAI) -> None:
326response = client.fine_tuning.jobs.with_raw_response.resume(
327"ft-AF1WoRqd3aJAHsqc9NY7iL8F",
328)
329
330assert response.is_closed is True
331assert response.http_request.headers.get("X-Stainless-Lang") == "python"
332job = response.parse()
333assert_matches_type(FineTuningJob, job, path=["response"])
334
335@parametrize
336def test_streaming_response_resume(self, client: OpenAI) -> None:
337with client.fine_tuning.jobs.with_streaming_response.resume(
338"ft-AF1WoRqd3aJAHsqc9NY7iL8F",
339) as response:
340assert not response.is_closed
341assert response.http_request.headers.get("X-Stainless-Lang") == "python"
342
343job = response.parse()
344assert_matches_type(FineTuningJob, job, path=["response"])
345
346assert cast(Any, response.is_closed) is True
347
348@parametrize
349def test_path_params_resume(self, client: OpenAI) -> None:
350with pytest.raises(ValueError, match=r"Expected a non-empty value for `fine_tuning_job_id` but received ''"):
351client.fine_tuning.jobs.with_raw_response.resume(
352"",
353)
354
08b8179aDavid Schnurr2 years ago355
356class TestAsyncJobs:
c62e9907stainless-app[bot]1 years ago357parametrize = pytest.mark.parametrize(
358"async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"]
359)
08b8179aDavid Schnurr2 years ago360
361@parametrize
98d779fbStainless Bot2 years ago362async def test_method_create(self, async_client: AsyncOpenAI) -> None:
363job = await async_client.fine_tuning.jobs.create(
bf1ca86cRobert Craigie1 years ago364model="gpt-4o-mini",
08b8179aDavid Schnurr2 years ago365training_file="file-abc123",
366)
367assert_matches_type(FineTuningJob, job, path=["response"])
368
369@parametrize
98d779fbStainless Bot2 years ago370async def test_method_create_with_all_params(self, async_client: AsyncOpenAI) -> None:
371job = await async_client.fine_tuning.jobs.create(
bf1ca86cRobert Craigie1 years ago372model="gpt-4o-mini",
08b8179aDavid Schnurr2 years ago373training_file="file-abc123",
baa9f07fRobert Craigie2 years ago374hyperparameters={
375"batch_size": "auto",
376"learning_rate_multiplier": "auto",
377"n_epochs": "auto",
378},
f5247e30Stainless Bot2 years ago379integrations=[
380{
381"type": "wandb",
382"wandb": {
383"project": "my-wandb-project",
092a8df7Stainless Bot1 years ago384"entity": "entity",
385"name": "name",
dd19d4f9Stainless Bot1 years ago386"tags": ["custom-tag"],
f5247e30Stainless Bot2 years ago387},
dd19d4f9Stainless Bot1 years ago388}
f5247e30Stainless Bot2 years ago389],
5608d64bstainless-app[bot]1 years ago390metadata={"foo": "string"},
575ff607stainless-app[bot]1 years ago391method={
a3b8e772stainless-app[bot]1 years ago392"type": "supervised",
575ff607stainless-app[bot]1 years ago393"dpo": {
394"hyperparameters": {
395"batch_size": "auto",
396"beta": "auto",
397"learning_rate_multiplier": "auto",
398"n_epochs": "auto",
399}
400},
a3b8e772stainless-app[bot]1 years ago401"reinforcement": {
402"grader": {
403"input": "input",
404"name": "name",
405"operation": "eq",
406"reference": "reference",
407"type": "string_check",
408},
409"hyperparameters": {
410"batch_size": "auto",
411"compute_multiplier": "auto",
412"eval_interval": "auto",
413"eval_samples": "auto",
414"learning_rate_multiplier": "auto",
415"n_epochs": "auto",
416"reasoning_effort": "default",
417},
418},
575ff607stainless-app[bot]1 years ago419"supervised": {
420"hyperparameters": {
421"batch_size": "auto",
422"learning_rate_multiplier": "auto",
423"n_epochs": "auto",
424}
425},
426},
f5247e30Stainless Bot2 years ago427seed=42,
08b8179aDavid Schnurr2 years ago428suffix="x",
429validation_file="file-abc123",
430)
431assert_matches_type(FineTuningJob, job, path=["response"])
432
433@parametrize
98d779fbStainless Bot2 years ago434async def test_raw_response_create(self, async_client: AsyncOpenAI) -> None:
435response = await async_client.fine_tuning.jobs.with_raw_response.create(
bf1ca86cRobert Craigie1 years ago436model="gpt-4o-mini",
08b8179aDavid Schnurr2 years ago437training_file="file-abc123",
438)
86379b44Stainless Bot2 years ago439
440assert response.is_closed is True
08b8179aDavid Schnurr2 years ago441assert response.http_request.headers.get("X-Stainless-Lang") == "python"
442job = response.parse()
443assert_matches_type(FineTuningJob, job, path=["response"])
444
86379b44Stainless Bot2 years ago445@parametrize
98d779fbStainless Bot2 years ago446async def test_streaming_response_create(self, async_client: AsyncOpenAI) -> None:
447async with async_client.fine_tuning.jobs.with_streaming_response.create(
bf1ca86cRobert Craigie1 years ago448model="gpt-4o-mini",
86379b44Stainless Bot2 years ago449training_file="file-abc123",
450) as response:
451assert not response.is_closed
452assert response.http_request.headers.get("X-Stainless-Lang") == "python"
453
454job = await response.parse()
455assert_matches_type(FineTuningJob, job, path=["response"])
456
457assert cast(Any, response.is_closed) is True
458
08b8179aDavid Schnurr2 years ago459@parametrize
98d779fbStainless Bot2 years ago460async def test_method_retrieve(self, async_client: AsyncOpenAI) -> None:
461job = await async_client.fine_tuning.jobs.retrieve(
08b8179aDavid Schnurr2 years ago462"ft-AF1WoRqd3aJAHsqc9NY7iL8F",
463)
464assert_matches_type(FineTuningJob, job, path=["response"])
465
466@parametrize
98d779fbStainless Bot2 years ago467async def test_raw_response_retrieve(self, async_client: AsyncOpenAI) -> None:
468response = await async_client.fine_tuning.jobs.with_raw_response.retrieve(
08b8179aDavid Schnurr2 years ago469"ft-AF1WoRqd3aJAHsqc9NY7iL8F",
470)
86379b44Stainless Bot2 years ago471
472assert response.is_closed is True
08b8179aDavid Schnurr2 years ago473assert response.http_request.headers.get("X-Stainless-Lang") == "python"
474job = response.parse()
475assert_matches_type(FineTuningJob, job, path=["response"])
476
86379b44Stainless Bot2 years ago477@parametrize
98d779fbStainless Bot2 years ago478async def test_streaming_response_retrieve(self, async_client: AsyncOpenAI) -> None:
479async with async_client.fine_tuning.jobs.with_streaming_response.retrieve(
86379b44Stainless Bot2 years ago480"ft-AF1WoRqd3aJAHsqc9NY7iL8F",
481) as response:
482assert not response.is_closed
483assert response.http_request.headers.get("X-Stainless-Lang") == "python"
484
485job = await response.parse()
486assert_matches_type(FineTuningJob, job, path=["response"])
487
488assert cast(Any, response.is_closed) is True
489
023a4e66Stainless Bot2 years ago490@parametrize
98d779fbStainless Bot2 years ago491async def test_path_params_retrieve(self, async_client: AsyncOpenAI) -> None:
023a4e66Stainless Bot2 years ago492with pytest.raises(ValueError, match=r"Expected a non-empty value for `fine_tuning_job_id` but received ''"):
98d779fbStainless Bot2 years ago493await async_client.fine_tuning.jobs.with_raw_response.retrieve(
023a4e66Stainless Bot2 years ago494"",
495)
496
08b8179aDavid Schnurr2 years ago497@parametrize
98d779fbStainless Bot2 years ago498async def test_method_list(self, async_client: AsyncOpenAI) -> None:
499job = await async_client.fine_tuning.jobs.list()
08b8179aDavid Schnurr2 years ago500assert_matches_type(AsyncCursorPage[FineTuningJob], job, path=["response"])
501
502@parametrize
98d779fbStainless Bot2 years ago503async def test_method_list_with_all_params(self, async_client: AsyncOpenAI) -> None:
504job = await async_client.fine_tuning.jobs.list(
08b8179aDavid Schnurr2 years ago505after="string",
506limit=0,
5608d64bstainless-app[bot]1 years ago507metadata={"foo": "string"},
08b8179aDavid Schnurr2 years ago508)
509assert_matches_type(AsyncCursorPage[FineTuningJob], job, path=["response"])
510
511@parametrize
98d779fbStainless Bot2 years ago512async def test_raw_response_list(self, async_client: AsyncOpenAI) -> None:
513response = await async_client.fine_tuning.jobs.with_raw_response.list()
86379b44Stainless Bot2 years ago514
515assert response.is_closed is True
08b8179aDavid Schnurr2 years ago516assert response.http_request.headers.get("X-Stainless-Lang") == "python"
517job = response.parse()
518assert_matches_type(AsyncCursorPage[FineTuningJob], job, path=["response"])
519
86379b44Stainless Bot2 years ago520@parametrize
98d779fbStainless Bot2 years ago521async def test_streaming_response_list(self, async_client: AsyncOpenAI) -> None:
522async with async_client.fine_tuning.jobs.with_streaming_response.list() as response:
86379b44Stainless Bot2 years ago523assert not response.is_closed
524assert response.http_request.headers.get("X-Stainless-Lang") == "python"
525
526job = await response.parse()
527assert_matches_type(AsyncCursorPage[FineTuningJob], job, path=["response"])
528
529assert cast(Any, response.is_closed) is True
530
08b8179aDavid Schnurr2 years ago531@parametrize
98d779fbStainless Bot2 years ago532async def test_method_cancel(self, async_client: AsyncOpenAI) -> None:
533job = await async_client.fine_tuning.jobs.cancel(
08b8179aDavid Schnurr2 years ago534"ft-AF1WoRqd3aJAHsqc9NY7iL8F",
535)
536assert_matches_type(FineTuningJob, job, path=["response"])
537
538@parametrize
98d779fbStainless Bot2 years ago539async def test_raw_response_cancel(self, async_client: AsyncOpenAI) -> None:
540response = await async_client.fine_tuning.jobs.with_raw_response.cancel(
08b8179aDavid Schnurr2 years ago541"ft-AF1WoRqd3aJAHsqc9NY7iL8F",
542)
86379b44Stainless Bot2 years ago543
544assert response.is_closed is True
08b8179aDavid Schnurr2 years ago545assert response.http_request.headers.get("X-Stainless-Lang") == "python"
546job = response.parse()
547assert_matches_type(FineTuningJob, job, path=["response"])
548
86379b44Stainless Bot2 years ago549@parametrize
98d779fbStainless Bot2 years ago550async def test_streaming_response_cancel(self, async_client: AsyncOpenAI) -> None:
551async with async_client.fine_tuning.jobs.with_streaming_response.cancel(
86379b44Stainless Bot2 years ago552"ft-AF1WoRqd3aJAHsqc9NY7iL8F",
553) as response:
554assert not response.is_closed
555assert response.http_request.headers.get("X-Stainless-Lang") == "python"
556
557job = await response.parse()
558assert_matches_type(FineTuningJob, job, path=["response"])
559
560assert cast(Any, response.is_closed) is True
561
023a4e66Stainless Bot2 years ago562@parametrize
98d779fbStainless Bot2 years ago563async def test_path_params_cancel(self, async_client: AsyncOpenAI) -> None:
023a4e66Stainless Bot2 years ago564with pytest.raises(ValueError, match=r"Expected a non-empty value for `fine_tuning_job_id` but received ''"):
98d779fbStainless Bot2 years ago565await async_client.fine_tuning.jobs.with_raw_response.cancel(
023a4e66Stainless Bot2 years ago566"",
567)
568
08b8179aDavid Schnurr2 years ago569@parametrize
98d779fbStainless Bot2 years ago570async def test_method_list_events(self, async_client: AsyncOpenAI) -> None:
571job = await async_client.fine_tuning.jobs.list_events(
08b8179aDavid Schnurr2 years ago572"ft-AF1WoRqd3aJAHsqc9NY7iL8F",
573)
574assert_matches_type(AsyncCursorPage[FineTuningJobEvent], job, path=["response"])
575
576@parametrize
98d779fbStainless Bot2 years ago577async def test_method_list_events_with_all_params(self, async_client: AsyncOpenAI) -> None:
578job = await async_client.fine_tuning.jobs.list_events(
08b8179aDavid Schnurr2 years ago579"ft-AF1WoRqd3aJAHsqc9NY7iL8F",
580after="string",
581limit=0,
582)
583assert_matches_type(AsyncCursorPage[FineTuningJobEvent], job, path=["response"])
584
585@parametrize
98d779fbStainless Bot2 years ago586async def test_raw_response_list_events(self, async_client: AsyncOpenAI) -> None:
587response = await async_client.fine_tuning.jobs.with_raw_response.list_events(
08b8179aDavid Schnurr2 years ago588"ft-AF1WoRqd3aJAHsqc9NY7iL8F",
589)
86379b44Stainless Bot2 years ago590
591assert response.is_closed is True
08b8179aDavid Schnurr2 years ago592assert response.http_request.headers.get("X-Stainless-Lang") == "python"
593job = response.parse()
594assert_matches_type(AsyncCursorPage[FineTuningJobEvent], job, path=["response"])
86379b44Stainless Bot2 years ago595
596@parametrize
98d779fbStainless Bot2 years ago597async def test_streaming_response_list_events(self, async_client: AsyncOpenAI) -> None:
598async with async_client.fine_tuning.jobs.with_streaming_response.list_events(
86379b44Stainless Bot2 years ago599"ft-AF1WoRqd3aJAHsqc9NY7iL8F",
600) as response:
601assert not response.is_closed
602assert response.http_request.headers.get("X-Stainless-Lang") == "python"
603
604job = await response.parse()
605assert_matches_type(AsyncCursorPage[FineTuningJobEvent], job, path=["response"])
606
607assert cast(Any, response.is_closed) is True
023a4e66Stainless Bot2 years ago608
609@parametrize
98d779fbStainless Bot2 years ago610async def test_path_params_list_events(self, async_client: AsyncOpenAI) -> None:
023a4e66Stainless Bot2 years ago611with pytest.raises(ValueError, match=r"Expected a non-empty value for `fine_tuning_job_id` but received ''"):
98d779fbStainless Bot2 years ago612await async_client.fine_tuning.jobs.with_raw_response.list_events(
023a4e66Stainless Bot2 years ago613"",
614)
a3b8e772stainless-app[bot]1 years ago615
616@parametrize
617async def test_method_pause(self, async_client: AsyncOpenAI) -> None:
618job = await async_client.fine_tuning.jobs.pause(
619"ft-AF1WoRqd3aJAHsqc9NY7iL8F",
620)
621assert_matches_type(FineTuningJob, job, path=["response"])
622
623@parametrize
624async def test_raw_response_pause(self, async_client: AsyncOpenAI) -> None:
625response = await async_client.fine_tuning.jobs.with_raw_response.pause(
626"ft-AF1WoRqd3aJAHsqc9NY7iL8F",
627)
628
629assert response.is_closed is True
630assert response.http_request.headers.get("X-Stainless-Lang") == "python"
631job = response.parse()
632assert_matches_type(FineTuningJob, job, path=["response"])
633
634@parametrize
635async def test_streaming_response_pause(self, async_client: AsyncOpenAI) -> None:
636async with async_client.fine_tuning.jobs.with_streaming_response.pause(
637"ft-AF1WoRqd3aJAHsqc9NY7iL8F",
638) as response:
639assert not response.is_closed
640assert response.http_request.headers.get("X-Stainless-Lang") == "python"
641
642job = await response.parse()
643assert_matches_type(FineTuningJob, job, path=["response"])
644
645assert cast(Any, response.is_closed) is True
646
647@parametrize
648async def test_path_params_pause(self, async_client: AsyncOpenAI) -> None:
649with pytest.raises(ValueError, match=r"Expected a non-empty value for `fine_tuning_job_id` but received ''"):
650await async_client.fine_tuning.jobs.with_raw_response.pause(
651"",
652)
653
654@parametrize
655async def test_method_resume(self, async_client: AsyncOpenAI) -> None:
656job = await async_client.fine_tuning.jobs.resume(
657"ft-AF1WoRqd3aJAHsqc9NY7iL8F",
658)
659assert_matches_type(FineTuningJob, job, path=["response"])
660
661@parametrize
662async def test_raw_response_resume(self, async_client: AsyncOpenAI) -> None:
663response = await async_client.fine_tuning.jobs.with_raw_response.resume(
664"ft-AF1WoRqd3aJAHsqc9NY7iL8F",
665)
666
667assert response.is_closed is True
668assert response.http_request.headers.get("X-Stainless-Lang") == "python"
669job = response.parse()
670assert_matches_type(FineTuningJob, job, path=["response"])
671
672@parametrize
673async def test_streaming_response_resume(self, async_client: AsyncOpenAI) -> None:
674async with async_client.fine_tuning.jobs.with_streaming_response.resume(
675"ft-AF1WoRqd3aJAHsqc9NY7iL8F",
676) as response:
677assert not response.is_closed
678assert response.http_request.headers.get("X-Stainless-Lang") == "python"
679
680job = await response.parse()
681assert_matches_type(FineTuningJob, job, path=["response"])
682
683assert cast(Any, response.is_closed) is True
684
685@parametrize
686async def test_path_params_resume(self, async_client: AsyncOpenAI) -> None:
687with pytest.raises(ValueError, match=r"Expected a non-empty value for `fine_tuning_job_id` but received ''"):
688await async_client.fine_tuning.jobs.with_raw_response.resume(
689"",
690)