|
30 | 30 | TrainingMethodSFT, |
31 | 31 | TrainingType, |
32 | 32 | ) |
33 | | -from together.types.finetune import ( |
34 | | - DownloadCheckpointType, |
35 | | - FinetuneEvent, |
36 | | - FinetuneEventType, |
37 | | -) |
38 | | -from together.utils import ( |
39 | | - get_event_step, |
40 | | - log_warn_once, |
41 | | - normalize_key, |
42 | | -) |
| 33 | +from together.types.finetune import DownloadCheckpointType |
| 34 | +from together.utils import log_warn_once, normalize_key |
43 | 35 |
|
44 | 36 |
|
45 | 37 | _FT_JOB_WITH_STEP_REGEX = r"^ft-[\dabcdef-]+:\d+$" |
@@ -256,70 +248,6 @@ def _parse_raw_checkpoints( |
256 | 248 | return parsed_checkpoints |
257 | 249 |
|
258 | 250 |
|
259 | | -def _process_checkpoints_from_events( |
260 | | - events: List[FinetuneEvent], id: str |
261 | | -) -> List[FinetuneCheckpoint]: |
262 | | - """ |
263 | | - Helper function to process events and create checkpoint list. |
264 | | -
|
265 | | - Args: |
266 | | - events (List[FinetuneEvent]): List of fine-tune events to process |
267 | | - id (str): Fine-tune job ID |
268 | | -
|
269 | | - Returns: |
270 | | - List[FinetuneCheckpoint]: List of available checkpoints |
271 | | - """ |
272 | | - checkpoints: List[FinetuneCheckpoint] = [] |
273 | | - |
274 | | - for event in events: |
275 | | - event_type = event.type |
276 | | - |
277 | | - if event_type == FinetuneEventType.CHECKPOINT_SAVE: |
278 | | - step = get_event_step(event) |
279 | | - checkpoint_name = f"{id}:{step}" if step is not None else id |
280 | | - |
281 | | - checkpoints.append( |
282 | | - FinetuneCheckpoint( |
283 | | - type=( |
284 | | - f"Intermediate (step {step})" |
285 | | - if step is not None |
286 | | - else "Intermediate" |
287 | | - ), |
288 | | - timestamp=event.created_at, |
289 | | - name=checkpoint_name, |
290 | | - ) |
291 | | - ) |
292 | | - elif event_type == FinetuneEventType.JOB_COMPLETE: |
293 | | - if hasattr(event, "model_path"): |
294 | | - checkpoints.append( |
295 | | - FinetuneCheckpoint( |
296 | | - type=( |
297 | | - "Final Merged" |
298 | | - if hasattr(event, "adapter_path") |
299 | | - else "Final" |
300 | | - ), |
301 | | - timestamp=event.created_at, |
302 | | - name=id, |
303 | | - ) |
304 | | - ) |
305 | | - |
306 | | - if hasattr(event, "adapter_path"): |
307 | | - checkpoints.append( |
308 | | - FinetuneCheckpoint( |
309 | | - type=( |
310 | | - "Final Adapter" if hasattr(event, "model_path") else "Final" |
311 | | - ), |
312 | | - timestamp=event.created_at, |
313 | | - name=id, |
314 | | - ) |
315 | | - ) |
316 | | - |
317 | | - # Sort by timestamp (newest first) |
318 | | - checkpoints.sort(key=lambda x: x.timestamp, reverse=True) |
319 | | - |
320 | | - return checkpoints |
321 | | - |
322 | | - |
323 | 251 | class FineTuning: |
324 | 252 | def __init__(self, client: TogetherClient) -> None: |
325 | 253 | self._client = client |
@@ -585,19 +513,6 @@ def list_events(self, id: str) -> FinetuneListEvents: |
585 | 513 |
|
586 | 514 | return FinetuneListEvents(**response.data) |
587 | 515 |
|
588 | | - def list_checkpoints_from_events(self, id: str) -> List[FinetuneCheckpoint]: |
589 | | - """ |
590 | | - List available checkpoints for a fine-tuning job |
591 | | -
|
592 | | - Args: |
593 | | - id (str): Unique identifier of the fine-tune job to list checkpoints for |
594 | | -
|
595 | | - Returns: |
596 | | - List[FinetuneCheckpoint]: List of available checkpoints |
597 | | - """ |
598 | | - events = self.list_events(id).data or [] |
599 | | - return _process_checkpoints_from_events(events, id) |
600 | | - |
601 | 516 | def list_checkpoints(self, id: str) -> List[FinetuneCheckpoint]: |
602 | 517 | """ |
603 | 518 | List available checkpoints for a fine-tuning job |
@@ -1000,20 +915,6 @@ async def list_events(self, id: str) -> FinetuneListEvents: |
1000 | 915 |
|
1001 | 916 | return FinetuneListEvents(**events_response.data) |
1002 | 917 |
|
1003 | | - async def list_checkpoints_from_events(self, id: str) -> List[FinetuneCheckpoint]: |
1004 | | - """ |
1005 | | - List available checkpoints for a fine-tuning job |
1006 | | -
|
1007 | | - Args: |
1008 | | - id (str): Unique identifier of the fine-tune job to list checkpoints for |
1009 | | -
|
1010 | | - Returns: |
1011 | | - List[FinetuneCheckpoint]: Object containing list of available checkpoints |
1012 | | - """ |
1013 | | - events_list = await self.list_events(id) |
1014 | | - events = events_list.data or [] |
1015 | | - return _process_checkpoints_from_events(events, id) |
1016 | | - |
1017 | 918 | async def list_checkpoints(self, id: str) -> List[FinetuneCheckpoint]: |
1018 | 919 | """ |
1019 | 920 | List available checkpoints for a fine-tuning job |
|
0 commit comments