together 2.0.0a13__py3-none-any.whl → 2.0.0a15__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. together/_client.py +38 -0
  2. together/_version.py +1 -1
  3. together/constants.py +34 -0
  4. together/error.py +16 -0
  5. together/lib/cli/api/beta/beta.py +12 -0
  6. together/lib/cli/api/beta/clusters.py +357 -0
  7. together/lib/cli/api/beta/clusters_storage.py +152 -0
  8. together/lib/cli/api/utils.py +41 -5
  9. together/lib/cli/cli.py +2 -0
  10. together/lib/types/fine_tuning.py +3 -0
  11. together/resources/__init__.py +14 -0
  12. together/resources/beta/__init__.py +33 -0
  13. together/resources/beta/beta.py +102 -0
  14. together/resources/beta/clusters/__init__.py +33 -0
  15. together/resources/beta/clusters/clusters.py +628 -0
  16. together/resources/beta/clusters/storage.py +490 -0
  17. together/types/__init__.py +12 -1
  18. together/types/beta/__init__.py +12 -0
  19. together/types/beta/cluster.py +93 -0
  20. together/types/beta/cluster_create_params.py +51 -0
  21. together/types/beta/cluster_create_response.py +9 -0
  22. together/types/beta/cluster_delete_response.py +9 -0
  23. together/types/beta/cluster_list_regions_response.py +21 -0
  24. together/types/beta/cluster_list_response.py +12 -0
  25. together/types/beta/cluster_update_params.py +13 -0
  26. together/types/beta/cluster_update_response.py +9 -0
  27. together/types/beta/clusters/__init__.py +10 -0
  28. together/types/beta/clusters/cluster_storage.py +13 -0
  29. together/types/beta/clusters/storage_create_params.py +17 -0
  30. together/types/beta/clusters/storage_create_response.py +9 -0
  31. together/types/beta/clusters/storage_delete_response.py +9 -0
  32. together/types/beta/clusters/storage_list_response.py +12 -0
  33. together/types/beta/clusters/storage_update_params.py +13 -0
  34. together/types/chat_completions.py +7 -0
  35. together/types/endpoints.py +4 -0
  36. together/types/files.py +8 -0
  37. together/types/fine_tuning_cancel_response.py +3 -0
  38. together/types/fine_tuning_list_response.py +3 -0
  39. together/types/finetune.py +27 -0
  40. together/types/finetune_response.py +2 -0
  41. together/types/models.py +2 -0
  42. {together-2.0.0a13.dist-info → together-2.0.0a15.dist-info}/METADATA +55 -8
  43. {together-2.0.0a13.dist-info → together-2.0.0a15.dist-info}/RECORD +46 -15
  44. {together-2.0.0a13.dist-info → together-2.0.0a15.dist-info}/WHEEL +0 -0
  45. {together-2.0.0a13.dist-info → together-2.0.0a15.dist-info}/entry_points.txt +0 -0
  46. {together-2.0.0a13.dist-info → together-2.0.0a15.dist-info}/licenses/LICENSE +0 -0
@@ -1,13 +1,16 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  import re
4
+ import sys
4
5
  import math
5
- from typing import List, Union, Literal
6
+ from typing import Any, List, Union, Literal, TypeVar, Callable
6
7
  from gettext import gettext as _
7
8
  from datetime import datetime
9
+ from functools import wraps
8
10
 
9
11
  import click
10
12
 
13
+ from together import APIError
11
14
  from together.lib.types.fine_tuning import COMPLETED_STATUSES, FinetuneResponse
12
15
  from together.types.finetune_response import FinetuneResponse as _FinetuneResponse
13
16
  from together.types.fine_tuning_list_response import Data
@@ -101,11 +104,11 @@ def generate_progress_bar(
101
104
  progress = "Progress: [bold red]unavailable[/bold red]"
102
105
  if finetune_job.status in COMPLETED_STATUSES:
103
106
  progress = "Progress: [bold green]completed[/bold green]"
104
- elif finetune_job.updated_at is not None:
105
- update_at = finetune_job.updated_at.astimezone()
107
+ elif getattr(finetune_job, "started_at", None) is not None and isinstance(finetune_job.started_at, datetime):
108
+ started_at = finetune_job.started_at.astimezone()
106
109
 
107
110
  if finetune_job.progress is not None:
108
- if current_time < update_at:
111
+ if current_time < started_at:
109
112
  return progress
110
113
 
111
114
  if not finetune_job.progress.estimate_available:
@@ -114,7 +117,7 @@ def generate_progress_bar(
114
117
  if finetune_job.progress.seconds_remaining <= 0:
115
118
  return progress
116
119
 
117
- elapsed_time = (current_time - update_at).total_seconds()
120
+ elapsed_time = (current_time - started_at).total_seconds()
118
121
  ratio_filled = min(elapsed_time / finetune_job.progress.seconds_remaining, 1.0)
119
122
  percentage = ratio_filled * 100
120
123
  filled = math.ceil(ratio_filled * _PROGRESS_BAR_WIDTH)
@@ -129,3 +132,36 @@ def generate_progress_bar(
129
132
  return progress
130
133
 
131
134
  return re.sub(r"\[/?[^\]]+\]", "", progress)
135
+
136
+
137
+ F = TypeVar("F", bound=Callable[..., Any])
138
+
139
+
140
+ def handle_api_errors(prefix: str) -> Callable[[F], F]:
141
+ """Decorator to handle common API errors in CLI commands."""
142
+
143
+ prefix_styled = click.style(f"{prefix}: ", fg="blue")
144
+
145
+ def decorator(f: F) -> F:
146
+ @wraps(f)
147
+ def wrapper(*args: Any, **kwargs: Any) -> Any:
148
+ try:
149
+ return f(*args, **kwargs)
150
+ # User aborted the command
151
+ except click.Abort:
152
+ sys.exit(0)
153
+ except APIError as e:
154
+ click.echo(prefix_styled + click.style("Failed", fg="red"))
155
+ if e.body is not None:
156
+ click.echo(prefix_styled + click.style(getattr(e.body, "message", str(e.body)), fg="red"))
157
+ else:
158
+ click.echo(prefix_styled + click.style(str(e), fg="red"))
159
+ sys.exit(1)
160
+ except Exception as e:
161
+ click.echo(prefix_styled + click.style("Failed", fg="red"))
162
+ click.echo(prefix_styled + click.style(f"An unexpected error occurred - {str(e)}", fg="red"))
163
+ sys.exit(1)
164
+
165
+ return wrapper # type: ignore
166
+
167
+ return decorator # type: ignore
together/lib/cli/cli.py CHANGED
@@ -11,6 +11,7 @@ from together._constants import DEFAULT_TIMEOUT
11
11
  from together.lib.cli.api.evals import evals
12
12
  from together.lib.cli.api.files import files
13
13
  from together.lib.cli.api.models import models
14
+ from together.lib.cli.api.beta.beta import beta
14
15
  from together.lib.cli.api.endpoints import endpoints
15
16
  from together.lib.cli.api.fine_tuning import fine_tuning
16
17
 
@@ -66,6 +67,7 @@ main.add_command(fine_tuning)
66
67
  main.add_command(models)
67
68
  main.add_command(endpoints)
68
69
  main.add_command(evals)
70
+ main.add_command(beta)
69
71
 
70
72
  if __name__ == "__main__":
71
73
  main()
@@ -305,6 +305,9 @@ class FinetuneResponse(BaseModel):
305
305
  updated_at: datetime
306
306
  """Last update timestamp of the fine-tune job"""
307
307
 
308
+ started_at: Optional[datetime] = None
309
+ """Start timestamp of a current stage of the fine-tune job"""
310
+
308
311
  batch_size: Optional[int] = None
309
312
  """Batch size used for training"""
310
313
 
@@ -1,5 +1,13 @@
1
1
  # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
+ from .beta import (
4
+ BetaResource,
5
+ AsyncBetaResource,
6
+ BetaResourceWithRawResponse,
7
+ AsyncBetaResourceWithRawResponse,
8
+ BetaResourceWithStreamingResponse,
9
+ AsyncBetaResourceWithStreamingResponse,
10
+ )
3
11
  from .chat import (
4
12
  ChatResource,
5
13
  AsyncChatResource,
@@ -130,6 +138,12 @@ from .code_interpreter import (
130
138
  )
131
139
 
132
140
  __all__ = [
141
+ "BetaResource",
142
+ "AsyncBetaResource",
143
+ "BetaResourceWithRawResponse",
144
+ "AsyncBetaResourceWithRawResponse",
145
+ "BetaResourceWithStreamingResponse",
146
+ "AsyncBetaResourceWithStreamingResponse",
133
147
  "ChatResource",
134
148
  "AsyncChatResource",
135
149
  "ChatResourceWithRawResponse",
@@ -0,0 +1,33 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from .beta import (
4
+ BetaResource,
5
+ AsyncBetaResource,
6
+ BetaResourceWithRawResponse,
7
+ AsyncBetaResourceWithRawResponse,
8
+ BetaResourceWithStreamingResponse,
9
+ AsyncBetaResourceWithStreamingResponse,
10
+ )
11
+ from .clusters import (
12
+ ClustersResource,
13
+ AsyncClustersResource,
14
+ ClustersResourceWithRawResponse,
15
+ AsyncClustersResourceWithRawResponse,
16
+ ClustersResourceWithStreamingResponse,
17
+ AsyncClustersResourceWithStreamingResponse,
18
+ )
19
+
20
+ __all__ = [
21
+ "ClustersResource",
22
+ "AsyncClustersResource",
23
+ "ClustersResourceWithRawResponse",
24
+ "AsyncClustersResourceWithRawResponse",
25
+ "ClustersResourceWithStreamingResponse",
26
+ "AsyncClustersResourceWithStreamingResponse",
27
+ "BetaResource",
28
+ "AsyncBetaResource",
29
+ "BetaResourceWithRawResponse",
30
+ "AsyncBetaResourceWithRawResponse",
31
+ "BetaResourceWithStreamingResponse",
32
+ "AsyncBetaResourceWithStreamingResponse",
33
+ ]
@@ -0,0 +1,102 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from __future__ import annotations
4
+
5
+ from ..._compat import cached_property
6
+ from ..._resource import SyncAPIResource, AsyncAPIResource
7
+ from .clusters.clusters import (
8
+ ClustersResource,
9
+ AsyncClustersResource,
10
+ ClustersResourceWithRawResponse,
11
+ AsyncClustersResourceWithRawResponse,
12
+ ClustersResourceWithStreamingResponse,
13
+ AsyncClustersResourceWithStreamingResponse,
14
+ )
15
+
16
+ __all__ = ["BetaResource", "AsyncBetaResource"]
17
+
18
+
19
+ class BetaResource(SyncAPIResource):
20
+ @cached_property
21
+ def clusters(self) -> ClustersResource:
22
+ return ClustersResource(self._client)
23
+
24
+ @cached_property
25
+ def with_raw_response(self) -> BetaResourceWithRawResponse:
26
+ """
27
+ This property can be used as a prefix for any HTTP method call to return
28
+ the raw response object instead of the parsed content.
29
+
30
+ For more information, see https://www.github.com/togethercomputer/together-py#accessing-raw-response-data-eg-headers
31
+ """
32
+ return BetaResourceWithRawResponse(self)
33
+
34
+ @cached_property
35
+ def with_streaming_response(self) -> BetaResourceWithStreamingResponse:
36
+ """
37
+ An alternative to `.with_raw_response` that doesn't eagerly read the response body.
38
+
39
+ For more information, see https://www.github.com/togethercomputer/together-py#with_streaming_response
40
+ """
41
+ return BetaResourceWithStreamingResponse(self)
42
+
43
+
44
+ class AsyncBetaResource(AsyncAPIResource):
45
+ @cached_property
46
+ def clusters(self) -> AsyncClustersResource:
47
+ return AsyncClustersResource(self._client)
48
+
49
+ @cached_property
50
+ def with_raw_response(self) -> AsyncBetaResourceWithRawResponse:
51
+ """
52
+ This property can be used as a prefix for any HTTP method call to return
53
+ the raw response object instead of the parsed content.
54
+
55
+ For more information, see https://www.github.com/togethercomputer/together-py#accessing-raw-response-data-eg-headers
56
+ """
57
+ return AsyncBetaResourceWithRawResponse(self)
58
+
59
+ @cached_property
60
+ def with_streaming_response(self) -> AsyncBetaResourceWithStreamingResponse:
61
+ """
62
+ An alternative to `.with_raw_response` that doesn't eagerly read the response body.
63
+
64
+ For more information, see https://www.github.com/togethercomputer/together-py#with_streaming_response
65
+ """
66
+ return AsyncBetaResourceWithStreamingResponse(self)
67
+
68
+
69
+ class BetaResourceWithRawResponse:
70
+ def __init__(self, beta: BetaResource) -> None:
71
+ self._beta = beta
72
+
73
+ @cached_property
74
+ def clusters(self) -> ClustersResourceWithRawResponse:
75
+ return ClustersResourceWithRawResponse(self._beta.clusters)
76
+
77
+
78
+ class AsyncBetaResourceWithRawResponse:
79
+ def __init__(self, beta: AsyncBetaResource) -> None:
80
+ self._beta = beta
81
+
82
+ @cached_property
83
+ def clusters(self) -> AsyncClustersResourceWithRawResponse:
84
+ return AsyncClustersResourceWithRawResponse(self._beta.clusters)
85
+
86
+
87
+ class BetaResourceWithStreamingResponse:
88
+ def __init__(self, beta: BetaResource) -> None:
89
+ self._beta = beta
90
+
91
+ @cached_property
92
+ def clusters(self) -> ClustersResourceWithStreamingResponse:
93
+ return ClustersResourceWithStreamingResponse(self._beta.clusters)
94
+
95
+
96
+ class AsyncBetaResourceWithStreamingResponse:
97
+ def __init__(self, beta: AsyncBetaResource) -> None:
98
+ self._beta = beta
99
+
100
+ @cached_property
101
+ def clusters(self) -> AsyncClustersResourceWithStreamingResponse:
102
+ return AsyncClustersResourceWithStreamingResponse(self._beta.clusters)
@@ -0,0 +1,33 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from .storage import (
4
+ StorageResource,
5
+ AsyncStorageResource,
6
+ StorageResourceWithRawResponse,
7
+ AsyncStorageResourceWithRawResponse,
8
+ StorageResourceWithStreamingResponse,
9
+ AsyncStorageResourceWithStreamingResponse,
10
+ )
11
+ from .clusters import (
12
+ ClustersResource,
13
+ AsyncClustersResource,
14
+ ClustersResourceWithRawResponse,
15
+ AsyncClustersResourceWithRawResponse,
16
+ ClustersResourceWithStreamingResponse,
17
+ AsyncClustersResourceWithStreamingResponse,
18
+ )
19
+
20
+ __all__ = [
21
+ "StorageResource",
22
+ "AsyncStorageResource",
23
+ "StorageResourceWithRawResponse",
24
+ "AsyncStorageResourceWithRawResponse",
25
+ "StorageResourceWithStreamingResponse",
26
+ "AsyncStorageResourceWithStreamingResponse",
27
+ "ClustersResource",
28
+ "AsyncClustersResource",
29
+ "ClustersResourceWithRawResponse",
30
+ "AsyncClustersResourceWithRawResponse",
31
+ "ClustersResourceWithStreamingResponse",
32
+ "AsyncClustersResourceWithStreamingResponse",
33
+ ]