together 1.1.4__py3-none-any.whl → 1.2.0__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.
together/cli/api/files.py CHANGED
@@ -32,12 +32,17 @@ def files(ctx: click.Context) -> None:
32
32
  default=FilePurpose.FineTune.value,
33
33
  help="Purpose of file upload. Acceptable values in enum `together.types.FilePurpose`. Defaults to `fine-tunes`.",
34
34
  )
35
- def upload(ctx: click.Context, file: pathlib.Path, purpose: str) -> None:
35
+ @click.option(
36
+ "--check/--no-check",
37
+ default=True,
38
+ help="Whether to check the file before uploading.",
39
+ )
40
+ def upload(ctx: click.Context, file: pathlib.Path, purpose: str, check: bool) -> None:
36
41
  """Upload file"""
37
42
 
38
43
  client: Together = ctx.obj
39
44
 
40
- response = client.files.upload(file=file, purpose=purpose)
45
+ response = client.files.upload(file=file, purpose=purpose, check=check)
41
46
 
42
47
  click.echo(json.dumps(response.model_dump(), indent=4))
43
48
 
together/error.py CHANGED
@@ -23,9 +23,12 @@ class TogetherException(Exception):
23
23
  if isinstance(message, TogetherErrorResponse)
24
24
  else message
25
25
  )
26
- self._message = f"Error code: {http_status} - {_message}"
26
+ if http_status is not None:
27
+ self._message = f"Error code: {http_status} - {_message}"
28
+ else:
29
+ self._message = str(_message)
27
30
 
28
- super(TogetherException, self).__init__(self._message)
31
+ super().__init__(self._message)
29
32
 
30
33
  self.http_status = http_status
31
34
  self.headers = headers or {}
together/filemanager.py CHANGED
@@ -103,13 +103,8 @@ def _prepare_output(
103
103
  if "x-tar" in content_type.lower():
104
104
  remote_name += ".tar.gz"
105
105
 
106
- elif "zstd" in content_type.lower() or step != -1:
107
- remote_name += ".tar.zst"
108
-
109
106
  else:
110
- raise FileTypeError(
111
- f"Unknown file type {content_type} found. Aborting download."
112
- )
107
+ remote_name += ".tar.zst"
113
108
 
114
109
  return Path(remote_name)
115
110
 
together/legacy/files.py CHANGED
@@ -53,9 +53,11 @@ class Files:
53
53
 
54
54
  client = together.Together(api_key=api_key)
55
55
 
56
- response = client.files.upload(file=file).model_dump()
56
+ # disabling the check, because it was run previously
57
+ response = client.files.upload(file=file, check=False).model_dump()
57
58
 
58
- response["report_dict"] = report_dict
59
+ if check:
60
+ response["report_dict"] = report_dict
59
61
 
60
62
  return response
61
63
 
@@ -1,8 +1,10 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  from pathlib import Path
4
+ from pprint import pformat
4
5
 
5
6
  from together.abstract import api_requestor
7
+ from together.error import FileTypeError
6
8
  from together.filemanager import DownloadManager, UploadManager
7
9
  from together.together_response import TogetherResponse
8
10
  from together.types import (
@@ -14,7 +16,7 @@ from together.types import (
14
16
  TogetherClient,
15
17
  TogetherRequest,
16
18
  )
17
- from together.utils import normalize_key
19
+ from together.utils import check_file, normalize_key
18
20
 
19
21
 
20
22
  class Files:
@@ -22,10 +24,21 @@ class Files:
22
24
  self._client = client
23
25
 
24
26
  def upload(
25
- self, file: Path | str, *, purpose: FilePurpose | str = FilePurpose.FineTune
27
+ self,
28
+ file: Path | str,
29
+ *,
30
+ purpose: FilePurpose | str = FilePurpose.FineTune,
31
+ check: bool = True,
26
32
  ) -> FileResponse:
27
33
  upload_manager = UploadManager(self._client)
28
34
 
35
+ if check:
36
+ report_dict = check_file(file)
37
+ if not report_dict["is_check_passed"]:
38
+ raise FileTypeError(
39
+ f"Invalid file supplied, failed to upload. Report:\n{pformat(report_dict)}"
40
+ )
41
+
29
42
  if isinstance(file, str):
30
43
  file = Path(file)
31
44
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: together
3
- Version: 1.1.4
3
+ Version: 1.2.0
4
4
  Summary: Python client for Together's Cloud Platform!
5
5
  Home-page: https://github.com/togethercomputer/together-python
6
6
  License: Apache-2.0
@@ -5,20 +5,20 @@ together/cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
5
  together/cli/api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
6
  together/cli/api/chat.py,sha256=qmDcYohGe1ODfvYEDN6Z2eZO3qODgmeUTll8P5qoKYQ,9170
7
7
  together/cli/api/completions.py,sha256=v6KvGsXnPCdSM7WIu_QmKXOA4iVjW93k3dLwfIBkxPQ,4199
8
- together/cli/api/files.py,sha256=1iOZpCDC-R2s7sOxWe539DU9KKJcrZGayeeksQLutRk,3186
8
+ together/cli/api/files.py,sha256=hOiN1ftwbSAs3gcVqwmPymhmzDYiIUrFWXFHVcWWom8,3329
9
9
  together/cli/api/finetune.py,sha256=mSQSasmVQLtNzjJLeoEEwvewfEcpSkjKyozWqwb-7p0,5417
10
10
  together/cli/api/images.py,sha256=01dFYa2sK1HqUwVCD9FlwcjqkYWLoNxFZkzok13EriE,2363
11
11
  together/cli/api/models.py,sha256=xWEzu8ZpxM_Pz9KEjRPRVuv_v22RayYZ4QcgiezT5tE,1126
12
12
  together/cli/cli.py,sha256=RC0tgapkSOFjsRPg8p-8dx9D2LDzm8YmVCHUjk_aVyQ,1977
13
13
  together/client.py,sha256=7QT5lwn7-QGf0vtgbhslQujm4986CgfE2spyMYP4JyU,4774
14
14
  together/constants.py,sha256=WHe6JA9TliwgErkCnovWPS9w9xXfA3X5PtKJv_y2JxQ,908
15
- together/error.py,sha256=cILzwDde18INNFYgbYdgvVfOhEjRZM9sg9I8Rl6nc_Y,5329
16
- together/filemanager.py,sha256=tBr9LOqiv6G63rH7HYePKeKhyylJXfZFHW5Aybk8UUw,11438
15
+ together/error.py,sha256=IWomy3KpDyuWS7uK4US2a4CkG4HC3oQEGQvVtul4nM8,5402
16
+ together/filemanager.py,sha256=QHhBn73oVFdgUpSYXYLmJzHJ9c5wYEMJC0ur6ZgDeYo,11269
17
17
  together/legacy/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
18
18
  together/legacy/base.py,sha256=ehrX1SCfRbK5OA83wL1q7-tfF-yuZOUxzjxYfFtdvvQ,727
19
19
  together/legacy/complete.py,sha256=8itEMlyuora2EIO-b-tvjvpHfKhxckDEiqaN-z6ccQs,2343
20
20
  together/legacy/embeddings.py,sha256=Sm4XNVBm00JUNQT65hlZE5tIwsKar2PdmK0_lZ4dw_4,591
21
- together/legacy/files.py,sha256=Xi5hUnfiZX2IqHkoKLjG3PUWrVuVYDcNCvH1FmBbrmo,3863
21
+ together/legacy/files.py,sha256=TFIJZvHlAY-SxQ4PJuCr-A4uRPL2znDhsbSTaTklCD0,3959
22
22
  together/legacy/finetune.py,sha256=Uujbmo_wdCko84mZbDTXMkNBySgMUvVXtULb0w96rDI,4917
23
23
  together/legacy/images.py,sha256=An5dmwU6Mo8mU-CJmI51J9EhOnYwcG9YXF8UgDcIm8E,582
24
24
  together/legacy/models.py,sha256=EEyRNw7AuMoKNXm1nWfT-k2wsAFq213WoyDVGRjwJWs,1053
@@ -27,7 +27,7 @@ together/resources/chat/__init__.py,sha256=RsTptdP8MeGjcdIjze896-J27cRvCbUoMft0X
27
27
  together/resources/chat/completions.py,sha256=QGrg0fGsn16k6jpxbQGoIBRivHWgEimPWAEVdKSAVGk,14084
28
28
  together/resources/completions.py,sha256=5s-jly2vbpI1rWhFwVijCmCOyhEZuDuwJblrm3HD0Gs,11353
29
29
  together/resources/embeddings.py,sha256=yRG0JaF4u_MEynQ4TBgCOVf9bKSvGI1fRaQx3CHUiB0,2546
30
- together/resources/files.py,sha256=_9mM5e49mMs4BCwW07-dnoxagvPPFhq1oUnsMsLMIYA,4593
30
+ together/resources/files.py,sha256=bnPbaF25e4InBRPvHwXHXT-oSX1Z1sZRsnQW5wq82U4,4990
31
31
  together/resources/finetune.py,sha256=DcA0A3I9khS8nMv2KpVNjDVI92knnI2o-O_93Z8gP-U,12416
32
32
  together/resources/images.py,sha256=gFzXy7gLzr20KsXJXHEsOZtJJpuR6pH1d8XHCd6Dl9E,4775
33
33
  together/resources/models.py,sha256=2dtHhXAqTDOOpwSbYLzWcKTC0-m2Szlb7LDYvp7Jr4w,1786
@@ -49,8 +49,8 @@ together/utils/api_helpers.py,sha256=RSF7SRhbjHzroMOSWAXscflByM1r1ta_1SpxkAT22iE
49
49
  together/utils/files.py,sha256=gMLthqfP5hKxVAerHMdy7gLXzdfY6lyOXdpW24Y4X3I,7165
50
50
  together/utils/tools.py,sha256=3-lXWP3cBCzOVSZg9tr5zOT1jaVeKAKVWxO2fcXZTh8,1788
51
51
  together/version.py,sha256=p03ivHyE0SyWU4jAnRTBi_sOwywVWoZPU4g2gzRgG-Y,126
52
- together-1.1.4.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
53
- together-1.1.4.dist-info/METADATA,sha256=t74AKUbStH9MAjck5ZIr55jsZOiPr7rQOyjwEzXKvIU,11812
54
- together-1.1.4.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
55
- together-1.1.4.dist-info/entry_points.txt,sha256=G-b5NKW6lUUf1V1fH8IPTBb7jXnK7lhbX9H1zTEJXPs,50
56
- together-1.1.4.dist-info/RECORD,,
52
+ together-1.2.0.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
53
+ together-1.2.0.dist-info/METADATA,sha256=stIBXOH6i0IqAnq1dB8CNdO40Edf4WVNSEUqiaMfVYM,11812
54
+ together-1.2.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
55
+ together-1.2.0.dist-info/entry_points.txt,sha256=G-b5NKW6lUUf1V1fH8IPTBb7jXnK7lhbX9H1zTEJXPs,50
56
+ together-1.2.0.dist-info/RECORD,,