openai/openai-python
Publicmirrored from https://github.com/openai/openai-pythonAvailable
tests/api_resources/fine_tuning/test_jobs.py
690lines · modeblame
5cfb125aStainless Bot2 years ago | 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. |
08b8179aDavid Schnurr2 years ago | 2 | |
| 3 | from __future__ import annotations | |
| 4 | | |
| 5 | import os | |
86379b44Stainless Bot2 years ago | 6 | from typing import Any, cast |
08b8179aDavid Schnurr2 years ago | 7 | |
| 8 | import pytest | |
| 9 | | |
| 10 | from openai import OpenAI, AsyncOpenAI | |
| 11 | from tests.utils import assert_matches_type | |
| 12 | from openai.pagination import SyncCursorPage, AsyncCursorPage | |
4a0f0fa0Stainless Bot2 years ago | 13 | from openai.types.fine_tuning import ( |
| 14 | FineTuningJob, | |
| 15 | FineTuningJobEvent, | |
| 16 | ) | |
08b8179aDavid Schnurr2 years ago | 17 | |
| 18 | base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") | |
| 19 | | |
| 20 | | |
| 21 | class TestJobs: | |
98d779fbStainless Bot2 years ago | 22 | parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) |
08b8179aDavid Schnurr2 years ago | 23 | |
| 24 | @parametrize | |
| 25 | def test_method_create(self, client: OpenAI) -> None: | |
| 26 | job = client.fine_tuning.jobs.create( | |
bf1ca86cRobert Craigie1 years ago | 27 | model="gpt-4o-mini", |
08b8179aDavid Schnurr2 years ago | 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( | |
bf1ca86cRobert Craigie1 years ago | 35 | model="gpt-4o-mini", |
08b8179aDavid Schnurr2 years ago | 36 | training_file="file-abc123", |
baa9f07fRobert Craigie2 years ago | 37 | hyperparameters={ |
| 38 | "batch_size": "auto", | |
| 39 | "learning_rate_multiplier": "auto", | |
| 40 | "n_epochs": "auto", | |
| 41 | }, | |
f5247e30Stainless Bot2 years ago | 42 | integrations=[ |
| 43 | { | |
| 44 | "type": "wandb", | |
| 45 | "wandb": { | |
| 46 | "project": "my-wandb-project", | |
092a8df7Stainless Bot1 years ago | 47 | "entity": "entity", |
| 48 | "name": "name", | |
dd19d4f9Stainless Bot1 years ago | 49 | "tags": ["custom-tag"], |
f5247e30Stainless Bot2 years ago | 50 | }, |
dd19d4f9Stainless Bot1 years ago | 51 | } |
f5247e30Stainless Bot2 years ago | 52 | ], |
5608d64bstainless-app[bot]1 years ago | 53 | metadata={"foo": "string"}, |
575ff607stainless-app[bot]1 years ago | 54 | method={ |
a3b8e772stainless-app[bot]1 years ago | 55 | "type": "supervised", |
575ff607stainless-app[bot]1 years ago | 56 | "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 ago | 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 | }, | |
575ff607stainless-app[bot]1 years ago | 82 | "supervised": { |
| 83 | "hyperparameters": { | |
| 84 | "batch_size": "auto", | |
| 85 | "learning_rate_multiplier": "auto", | |
| 86 | "n_epochs": "auto", | |
| 87 | } | |
| 88 | }, | |
| 89 | }, | |
f5247e30Stainless Bot2 years ago | 90 | seed=42, |
08b8179aDavid Schnurr2 years ago | 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( | |
bf1ca86cRobert Craigie1 years ago | 99 | model="gpt-4o-mini", |
08b8179aDavid Schnurr2 years ago | 100 | training_file="file-abc123", |
| 101 | ) | |
86379b44Stainless Bot2 years ago | 102 | |
| 103 | assert response.is_closed is True | |
08b8179aDavid Schnurr2 years ago | 104 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 105 | job = response.parse() | |
| 106 | assert_matches_type(FineTuningJob, job, path=["response"]) | |
| 107 | | |
86379b44Stainless Bot2 years ago | 108 | @parametrize |
| 109 | def test_streaming_response_create(self, client: OpenAI) -> None: | |
| 110 | with client.fine_tuning.jobs.with_streaming_response.create( | |
bf1ca86cRobert Craigie1 years ago | 111 | model="gpt-4o-mini", |
86379b44Stainless Bot2 years ago | 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 | | |
08b8179aDavid Schnurr2 years ago | 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 | ) | |
86379b44Stainless Bot2 years ago | 134 | |
| 135 | assert response.is_closed is True | |
08b8179aDavid Schnurr2 years ago | 136 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 137 | job = response.parse() | |
| 138 | assert_matches_type(FineTuningJob, job, path=["response"]) | |
| 139 | | |
86379b44Stainless Bot2 years ago | 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 | | |
023a4e66Stainless Bot2 years ago | 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 | | |
08b8179aDavid Schnurr2 years ago | 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, | |
5608d64bstainless-app[bot]1 years ago | 170 | metadata={"foo": "string"}, |
08b8179aDavid Schnurr2 years ago | 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() | |
86379b44Stainless Bot2 years ago | 177 | |
| 178 | assert response.is_closed is True | |
08b8179aDavid Schnurr2 years ago | 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 | | |
86379b44Stainless Bot2 years ago | 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 | | |
08b8179aDavid Schnurr2 years ago | 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 | ) | |
86379b44Stainless Bot2 years ago | 206 | |
| 207 | assert response.is_closed is True | |
08b8179aDavid Schnurr2 years ago | 208 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 209 | job = response.parse() | |
| 210 | assert_matches_type(FineTuningJob, job, path=["response"]) | |
| 211 | | |
86379b44Stainless Bot2 years ago | 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 | | |
023a4e66Stainless Bot2 years ago | 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 | | |
08b8179aDavid Schnurr2 years ago | 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 | ) | |
86379b44Stainless Bot2 years ago | 253 | |
| 254 | assert response.is_closed is True | |
08b8179aDavid Schnurr2 years ago | 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 | | |
86379b44Stainless Bot2 years ago | 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 | | |
023a4e66Stainless Bot2 years ago | 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 | | |
a3b8e772stainless-app[bot]1 years ago | 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 | | |
08b8179aDavid Schnurr2 years ago | 355 | |
| 356 | class TestAsyncJobs: | |
c62e9907stainless-app[bot]1 years ago | 357 | parametrize = pytest.mark.parametrize( |
| 358 | "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] | |
| 359 | ) | |
08b8179aDavid Schnurr2 years ago | 360 | |
| 361 | @parametrize | |
98d779fbStainless Bot2 years ago | 362 | async def test_method_create(self, async_client: AsyncOpenAI) -> None: |
| 363 | job = await async_client.fine_tuning.jobs.create( | |
bf1ca86cRobert Craigie1 years ago | 364 | model="gpt-4o-mini", |
08b8179aDavid Schnurr2 years ago | 365 | training_file="file-abc123", |
| 366 | ) | |
| 367 | assert_matches_type(FineTuningJob, job, path=["response"]) | |
| 368 | | |
| 369 | @parametrize | |
98d779fbStainless Bot2 years ago | 370 | async def test_method_create_with_all_params(self, async_client: AsyncOpenAI) -> None: |
| 371 | job = await async_client.fine_tuning.jobs.create( | |
bf1ca86cRobert Craigie1 years ago | 372 | model="gpt-4o-mini", |
08b8179aDavid Schnurr2 years ago | 373 | training_file="file-abc123", |
baa9f07fRobert Craigie2 years ago | 374 | hyperparameters={ |
| 375 | "batch_size": "auto", | |
| 376 | "learning_rate_multiplier": "auto", | |
| 377 | "n_epochs": "auto", | |
| 378 | }, | |
f5247e30Stainless Bot2 years ago | 379 | integrations=[ |
| 380 | { | |
| 381 | "type": "wandb", | |
| 382 | "wandb": { | |
| 383 | "project": "my-wandb-project", | |
092a8df7Stainless Bot1 years ago | 384 | "entity": "entity", |
| 385 | "name": "name", | |
dd19d4f9Stainless Bot1 years ago | 386 | "tags": ["custom-tag"], |
f5247e30Stainless Bot2 years ago | 387 | }, |
dd19d4f9Stainless Bot1 years ago | 388 | } |
f5247e30Stainless Bot2 years ago | 389 | ], |
5608d64bstainless-app[bot]1 years ago | 390 | metadata={"foo": "string"}, |
575ff607stainless-app[bot]1 years ago | 391 | method={ |
a3b8e772stainless-app[bot]1 years ago | 392 | "type": "supervised", |
575ff607stainless-app[bot]1 years ago | 393 | "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 ago | 401 | "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 ago | 419 | "supervised": { |
| 420 | "hyperparameters": { | |
| 421 | "batch_size": "auto", | |
| 422 | "learning_rate_multiplier": "auto", | |
| 423 | "n_epochs": "auto", | |
| 424 | } | |
| 425 | }, | |
| 426 | }, | |
f5247e30Stainless Bot2 years ago | 427 | seed=42, |
08b8179aDavid Schnurr2 years ago | 428 | suffix="x", |
| 429 | validation_file="file-abc123", | |
| 430 | ) | |
| 431 | assert_matches_type(FineTuningJob, job, path=["response"]) | |
| 432 | | |
| 433 | @parametrize | |
98d779fbStainless Bot2 years ago | 434 | async def test_raw_response_create(self, async_client: AsyncOpenAI) -> None: |
| 435 | response = await async_client.fine_tuning.jobs.with_raw_response.create( | |
bf1ca86cRobert Craigie1 years ago | 436 | model="gpt-4o-mini", |
08b8179aDavid Schnurr2 years ago | 437 | training_file="file-abc123", |
| 438 | ) | |
86379b44Stainless Bot2 years ago | 439 | |
| 440 | assert response.is_closed is True | |
08b8179aDavid Schnurr2 years ago | 441 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 442 | job = response.parse() | |
| 443 | assert_matches_type(FineTuningJob, job, path=["response"]) | |
| 444 | | |
86379b44Stainless Bot2 years ago | 445 | @parametrize |
98d779fbStainless Bot2 years ago | 446 | async def test_streaming_response_create(self, async_client: AsyncOpenAI) -> None: |
| 447 | async with async_client.fine_tuning.jobs.with_streaming_response.create( | |
bf1ca86cRobert Craigie1 years ago | 448 | model="gpt-4o-mini", |
86379b44Stainless Bot2 years ago | 449 | training_file="file-abc123", |
| 450 | ) as response: | |
| 451 | assert not response.is_closed | |
| 452 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" | |
| 453 | | |
| 454 | job = await response.parse() | |
| 455 | assert_matches_type(FineTuningJob, job, path=["response"]) | |
| 456 | | |
| 457 | assert cast(Any, response.is_closed) is True | |
| 458 | | |
08b8179aDavid Schnurr2 years ago | 459 | @parametrize |
98d779fbStainless Bot2 years ago | 460 | async def test_method_retrieve(self, async_client: AsyncOpenAI) -> None: |
| 461 | job = await async_client.fine_tuning.jobs.retrieve( | |
08b8179aDavid Schnurr2 years ago | 462 | "ft-AF1WoRqd3aJAHsqc9NY7iL8F", |
| 463 | ) | |
| 464 | assert_matches_type(FineTuningJob, job, path=["response"]) | |
| 465 | | |
| 466 | @parametrize | |
98d779fbStainless Bot2 years ago | 467 | async def test_raw_response_retrieve(self, async_client: AsyncOpenAI) -> None: |
| 468 | response = await async_client.fine_tuning.jobs.with_raw_response.retrieve( | |
08b8179aDavid Schnurr2 years ago | 469 | "ft-AF1WoRqd3aJAHsqc9NY7iL8F", |
| 470 | ) | |
86379b44Stainless Bot2 years ago | 471 | |
| 472 | assert response.is_closed is True | |
08b8179aDavid Schnurr2 years ago | 473 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 474 | job = response.parse() | |
| 475 | assert_matches_type(FineTuningJob, job, path=["response"]) | |
| 476 | | |
86379b44Stainless Bot2 years ago | 477 | @parametrize |
98d779fbStainless Bot2 years ago | 478 | async def test_streaming_response_retrieve(self, async_client: AsyncOpenAI) -> None: |
| 479 | async with async_client.fine_tuning.jobs.with_streaming_response.retrieve( | |
86379b44Stainless Bot2 years ago | 480 | "ft-AF1WoRqd3aJAHsqc9NY7iL8F", |
| 481 | ) as response: | |
| 482 | assert not response.is_closed | |
| 483 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" | |
| 484 | | |
| 485 | job = await response.parse() | |
| 486 | assert_matches_type(FineTuningJob, job, path=["response"]) | |
| 487 | | |
| 488 | assert cast(Any, response.is_closed) is True | |
| 489 | | |
023a4e66Stainless Bot2 years ago | 490 | @parametrize |
98d779fbStainless Bot2 years ago | 491 | async def test_path_params_retrieve(self, async_client: AsyncOpenAI) -> None: |
023a4e66Stainless Bot2 years ago | 492 | with pytest.raises(ValueError, match=r"Expected a non-empty value for `fine_tuning_job_id` but received ''"): |
98d779fbStainless Bot2 years ago | 493 | await async_client.fine_tuning.jobs.with_raw_response.retrieve( |
023a4e66Stainless Bot2 years ago | 494 | "", |
| 495 | ) | |
| 496 | | |
08b8179aDavid Schnurr2 years ago | 497 | @parametrize |
98d779fbStainless Bot2 years ago | 498 | async def test_method_list(self, async_client: AsyncOpenAI) -> None: |
| 499 | job = await async_client.fine_tuning.jobs.list() | |
08b8179aDavid Schnurr2 years ago | 500 | assert_matches_type(AsyncCursorPage[FineTuningJob], job, path=["response"]) |
| 501 | | |
| 502 | @parametrize | |
98d779fbStainless Bot2 years ago | 503 | async def test_method_list_with_all_params(self, async_client: AsyncOpenAI) -> None: |
| 504 | job = await async_client.fine_tuning.jobs.list( | |
08b8179aDavid Schnurr2 years ago | 505 | after="string", |
| 506 | limit=0, | |
5608d64bstainless-app[bot]1 years ago | 507 | metadata={"foo": "string"}, |
08b8179aDavid Schnurr2 years ago | 508 | ) |
| 509 | assert_matches_type(AsyncCursorPage[FineTuningJob], job, path=["response"]) | |
| 510 | | |
| 511 | @parametrize | |
98d779fbStainless Bot2 years ago | 512 | async def test_raw_response_list(self, async_client: AsyncOpenAI) -> None: |
| 513 | response = await async_client.fine_tuning.jobs.with_raw_response.list() | |
86379b44Stainless Bot2 years ago | 514 | |
| 515 | assert response.is_closed is True | |
08b8179aDavid Schnurr2 years ago | 516 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 517 | job = response.parse() | |
| 518 | assert_matches_type(AsyncCursorPage[FineTuningJob], job, path=["response"]) | |
| 519 | | |
86379b44Stainless Bot2 years ago | 520 | @parametrize |
98d779fbStainless Bot2 years ago | 521 | async def test_streaming_response_list(self, async_client: AsyncOpenAI) -> None: |
| 522 | async with async_client.fine_tuning.jobs.with_streaming_response.list() as response: | |
86379b44Stainless Bot2 years ago | 523 | assert not response.is_closed |
| 524 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" | |
| 525 | | |
| 526 | job = await response.parse() | |
| 527 | assert_matches_type(AsyncCursorPage[FineTuningJob], job, path=["response"]) | |
| 528 | | |
| 529 | assert cast(Any, response.is_closed) is True | |
| 530 | | |
08b8179aDavid Schnurr2 years ago | 531 | @parametrize |
98d779fbStainless Bot2 years ago | 532 | async def test_method_cancel(self, async_client: AsyncOpenAI) -> None: |
| 533 | job = await async_client.fine_tuning.jobs.cancel( | |
08b8179aDavid Schnurr2 years ago | 534 | "ft-AF1WoRqd3aJAHsqc9NY7iL8F", |
| 535 | ) | |
| 536 | assert_matches_type(FineTuningJob, job, path=["response"]) | |
| 537 | | |
| 538 | @parametrize | |
98d779fbStainless Bot2 years ago | 539 | async def test_raw_response_cancel(self, async_client: AsyncOpenAI) -> None: |
| 540 | response = await async_client.fine_tuning.jobs.with_raw_response.cancel( | |
08b8179aDavid Schnurr2 years ago | 541 | "ft-AF1WoRqd3aJAHsqc9NY7iL8F", |
| 542 | ) | |
86379b44Stainless Bot2 years ago | 543 | |
| 544 | assert response.is_closed is True | |
08b8179aDavid Schnurr2 years ago | 545 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 546 | job = response.parse() | |
| 547 | assert_matches_type(FineTuningJob, job, path=["response"]) | |
| 548 | | |
86379b44Stainless Bot2 years ago | 549 | @parametrize |
98d779fbStainless Bot2 years ago | 550 | async def test_streaming_response_cancel(self, async_client: AsyncOpenAI) -> None: |
| 551 | async with async_client.fine_tuning.jobs.with_streaming_response.cancel( | |
86379b44Stainless Bot2 years ago | 552 | "ft-AF1WoRqd3aJAHsqc9NY7iL8F", |
| 553 | ) as response: | |
| 554 | assert not response.is_closed | |
| 555 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" | |
| 556 | | |
| 557 | job = await response.parse() | |
| 558 | assert_matches_type(FineTuningJob, job, path=["response"]) | |
| 559 | | |
| 560 | assert cast(Any, response.is_closed) is True | |
| 561 | | |
023a4e66Stainless Bot2 years ago | 562 | @parametrize |
98d779fbStainless Bot2 years ago | 563 | async def test_path_params_cancel(self, async_client: AsyncOpenAI) -> None: |
023a4e66Stainless Bot2 years ago | 564 | with pytest.raises(ValueError, match=r"Expected a non-empty value for `fine_tuning_job_id` but received ''"): |
98d779fbStainless Bot2 years ago | 565 | await async_client.fine_tuning.jobs.with_raw_response.cancel( |
023a4e66Stainless Bot2 years ago | 566 | "", |
| 567 | ) | |
| 568 | | |
08b8179aDavid Schnurr2 years ago | 569 | @parametrize |
98d779fbStainless Bot2 years ago | 570 | async def test_method_list_events(self, async_client: AsyncOpenAI) -> None: |
| 571 | job = await async_client.fine_tuning.jobs.list_events( | |
08b8179aDavid Schnurr2 years ago | 572 | "ft-AF1WoRqd3aJAHsqc9NY7iL8F", |
| 573 | ) | |
| 574 | assert_matches_type(AsyncCursorPage[FineTuningJobEvent], job, path=["response"]) | |
| 575 | | |
| 576 | @parametrize | |
98d779fbStainless Bot2 years ago | 577 | async def test_method_list_events_with_all_params(self, async_client: AsyncOpenAI) -> None: |
| 578 | job = await async_client.fine_tuning.jobs.list_events( | |
08b8179aDavid Schnurr2 years ago | 579 | "ft-AF1WoRqd3aJAHsqc9NY7iL8F", |
| 580 | after="string", | |
| 581 | limit=0, | |
| 582 | ) | |
| 583 | assert_matches_type(AsyncCursorPage[FineTuningJobEvent], job, path=["response"]) | |
| 584 | | |
| 585 | @parametrize | |
98d779fbStainless Bot2 years ago | 586 | async def test_raw_response_list_events(self, async_client: AsyncOpenAI) -> None: |
| 587 | response = await async_client.fine_tuning.jobs.with_raw_response.list_events( | |
08b8179aDavid Schnurr2 years ago | 588 | "ft-AF1WoRqd3aJAHsqc9NY7iL8F", |
| 589 | ) | |
86379b44Stainless Bot2 years ago | 590 | |
| 591 | assert response.is_closed is True | |
08b8179aDavid Schnurr2 years ago | 592 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 593 | job = response.parse() | |
| 594 | assert_matches_type(AsyncCursorPage[FineTuningJobEvent], job, path=["response"]) | |
86379b44Stainless Bot2 years ago | 595 | |
| 596 | @parametrize | |
98d779fbStainless Bot2 years ago | 597 | async def test_streaming_response_list_events(self, async_client: AsyncOpenAI) -> None: |
| 598 | async with async_client.fine_tuning.jobs.with_streaming_response.list_events( | |
86379b44Stainless Bot2 years ago | 599 | "ft-AF1WoRqd3aJAHsqc9NY7iL8F", |
| 600 | ) as response: | |
| 601 | assert not response.is_closed | |
| 602 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" | |
| 603 | | |
| 604 | job = await response.parse() | |
| 605 | assert_matches_type(AsyncCursorPage[FineTuningJobEvent], job, path=["response"]) | |
| 606 | | |
| 607 | assert cast(Any, response.is_closed) is True | |
023a4e66Stainless Bot2 years ago | 608 | |
| 609 | @parametrize | |
98d779fbStainless Bot2 years ago | 610 | async def test_path_params_list_events(self, async_client: AsyncOpenAI) -> None: |
023a4e66Stainless Bot2 years ago | 611 | with pytest.raises(ValueError, match=r"Expected a non-empty value for `fine_tuning_job_id` but received ''"): |
98d779fbStainless Bot2 years ago | 612 | await async_client.fine_tuning.jobs.with_raw_response.list_events( |
023a4e66Stainless Bot2 years ago | 613 | "", |
| 614 | ) | |
a3b8e772stainless-app[bot]1 years ago | 615 | |
| 616 | @parametrize | |
| 617 | async def test_method_pause(self, async_client: AsyncOpenAI) -> None: | |
| 618 | job = await async_client.fine_tuning.jobs.pause( | |
| 619 | "ft-AF1WoRqd3aJAHsqc9NY7iL8F", | |
| 620 | ) | |
| 621 | assert_matches_type(FineTuningJob, job, path=["response"]) | |
| 622 | | |
| 623 | @parametrize | |
| 624 | async def test_raw_response_pause(self, async_client: AsyncOpenAI) -> None: | |
| 625 | response = await async_client.fine_tuning.jobs.with_raw_response.pause( | |
| 626 | "ft-AF1WoRqd3aJAHsqc9NY7iL8F", | |
| 627 | ) | |
| 628 | | |
| 629 | assert response.is_closed is True | |
| 630 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" | |
| 631 | job = response.parse() | |
| 632 | assert_matches_type(FineTuningJob, job, path=["response"]) | |
| 633 | | |
| 634 | @parametrize | |
| 635 | async def test_streaming_response_pause(self, async_client: AsyncOpenAI) -> None: | |
| 636 | async with async_client.fine_tuning.jobs.with_streaming_response.pause( | |
| 637 | "ft-AF1WoRqd3aJAHsqc9NY7iL8F", | |
| 638 | ) as response: | |
| 639 | assert not response.is_closed | |
| 640 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" | |
| 641 | | |
| 642 | job = await response.parse() | |
| 643 | assert_matches_type(FineTuningJob, job, path=["response"]) | |
| 644 | | |
| 645 | assert cast(Any, response.is_closed) is True | |
| 646 | | |
| 647 | @parametrize | |
| 648 | async def test_path_params_pause(self, async_client: AsyncOpenAI) -> None: | |
| 649 | with pytest.raises(ValueError, match=r"Expected a non-empty value for `fine_tuning_job_id` but received ''"): | |
| 650 | await async_client.fine_tuning.jobs.with_raw_response.pause( | |
| 651 | "", | |
| 652 | ) | |
| 653 | | |
| 654 | @parametrize | |
| 655 | async def test_method_resume(self, async_client: AsyncOpenAI) -> None: | |
| 656 | job = await async_client.fine_tuning.jobs.resume( | |
| 657 | "ft-AF1WoRqd3aJAHsqc9NY7iL8F", | |
| 658 | ) | |
| 659 | assert_matches_type(FineTuningJob, job, path=["response"]) | |
| 660 | | |
| 661 | @parametrize | |
| 662 | async def test_raw_response_resume(self, async_client: AsyncOpenAI) -> None: | |
| 663 | response = await async_client.fine_tuning.jobs.with_raw_response.resume( | |
| 664 | "ft-AF1WoRqd3aJAHsqc9NY7iL8F", | |
| 665 | ) | |
| 666 | | |
| 667 | assert response.is_closed is True | |
| 668 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" | |
| 669 | job = response.parse() | |
| 670 | assert_matches_type(FineTuningJob, job, path=["response"]) | |
| 671 | | |
| 672 | @parametrize | |
| 673 | async def test_streaming_response_resume(self, async_client: AsyncOpenAI) -> None: | |
| 674 | async with async_client.fine_tuning.jobs.with_streaming_response.resume( | |
| 675 | "ft-AF1WoRqd3aJAHsqc9NY7iL8F", | |
| 676 | ) as response: | |
| 677 | assert not response.is_closed | |
| 678 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" | |
| 679 | | |
| 680 | job = await response.parse() | |
| 681 | assert_matches_type(FineTuningJob, job, path=["response"]) | |
| 682 | | |
| 683 | assert cast(Any, response.is_closed) is True | |
| 684 | | |
| 685 | @parametrize | |
| 686 | async def test_path_params_resume(self, async_client: AsyncOpenAI) -> None: | |
| 687 | with pytest.raises(ValueError, match=r"Expected a non-empty value for `fine_tuning_job_id` but received ''"): | |
| 688 | await async_client.fine_tuning.jobs.with_raw_response.resume( | |
| 689 | "", | |
| 690 | ) |