Skip to content

Commit 430563e

Browse files
clam004Carson Lamjustusc
authored
Useful error handling (#17)
* init * black ruff fixes * better readme completion * type fix * simpler feedback check * black ruff changes * no_implicit_optional * mypy errors addressed * different mypy version * black ruff * typo in readme fixed * typo in readme fixed * typo in readme fixed * update example * Update README.md Co-authored-by: Justus Calvin <[email protected]> * unrealted typo wether to whether in complete.py * Update src/together/commands/files.py Co-authored-by: Justus Calvin <[email protected]> * Update src/together/complete.py Co-authored-by: Justus Calvin <[email protected]> * Update src/together/files.py Co-authored-by: Justus Calvin <[email protected]> * Update src/together/files.py Co-authored-by: Justus Calvin <[email protected]> * Update src/together/finetune.py Co-authored-by: Justus Calvin <[email protected]> * remove logger * incorporate justus's suggestions * reconcile suggestions * ruf black fixes to reverse of cleanup --------- Co-authored-by: Carson Lam <[email protected]> Co-authored-by: Justus Calvin <[email protected]>
1 parent 8d6551f commit 430563e

File tree

9 files changed

+930
-66
lines changed

9 files changed

+930
-66
lines changed

README.md

Lines changed: 284 additions & 31 deletions
Large diffs are not rendered by default.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "together"
7-
version = "0.1.3"
7+
version = "0.1.4"
88
authors = [
99
{ name="Together Computer", email="[email protected]" },
1010
]

src/together/__init__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
import os
22
import urllib.parse
33

4+
from .config import (
5+
finetune_model_names,
6+
jokes_list,
7+
min_samples,
8+
model_info_dict,
9+
)
410
from .version import VERSION
511

612

@@ -46,4 +52,8 @@
4652
"Files",
4753
"Finetune",
4854
"Image",
55+
"model_info_dict",
56+
"finetune_model_names",
57+
"min_samples",
58+
"jokes_list",
4959
]

src/together/commands/files.py

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ def add_parser(subparsers: argparse._SubParsersAction[argparse.ArgumentParser])
1313
child_parsers = parser.add_subparsers(required=True)
1414

1515
_add_list(child_parsers)
16+
_add_check(child_parsers)
1617
_add_upload(child_parsers)
1718
_add_delete(child_parsers)
1819
_add_retrieve(child_parsers)
@@ -24,6 +25,26 @@ def _add_list(parser: argparse._SubParsersAction[argparse.ArgumentParser]) -> No
2425
subparser.set_defaults(func=_run_list)
2526

2627

28+
def _add_check(parser: argparse._SubParsersAction[argparse.ArgumentParser]) -> None:
29+
subparser = parser.add_parser("check")
30+
subparser.add_argument(
31+
"file",
32+
metavar="FILENAME",
33+
help="Local file to upload",
34+
type=str,
35+
)
36+
subparser.add_argument(
37+
"--model",
38+
"-m",
39+
default=None,
40+
metavar="MODELNAME",
41+
help="check data for this model's special tokens",
42+
type=str,
43+
required=False,
44+
)
45+
subparser.set_defaults(func=_run_check)
46+
47+
2748
def _add_upload(parser: argparse._SubParsersAction[argparse.ArgumentParser]) -> None:
2849
subparser = parser.add_parser("upload")
2950
subparser.add_argument(
@@ -32,6 +53,21 @@ def _add_upload(parser: argparse._SubParsersAction[argparse.ArgumentParser]) ->
3253
help="Local file to upload",
3354
type=str,
3455
)
56+
subparser.add_argument(
57+
"--no-check",
58+
default=False,
59+
action="store_true",
60+
help="Indicates whether to disable checking",
61+
)
62+
subparser.add_argument(
63+
"--model",
64+
"-m",
65+
default=None,
66+
metavar="MODELNAME",
67+
help="check data for this model's special tokens",
68+
type=str,
69+
required=False,
70+
)
3571
subparser.set_defaults(func=_run_upload)
3672

3773

@@ -87,9 +123,15 @@ def _run_list(args: argparse.Namespace) -> None:
87123
print(json.dumps(response, indent=4))
88124

89125

126+
def _run_check(args: argparse.Namespace) -> None:
127+
files = Files()
128+
response = files.check(args.file, args.model)
129+
print(json.dumps(response, indent=4))
130+
131+
90132
def _run_upload(args: argparse.Namespace) -> None:
91133
files = Files()
92-
response = files.upload(args.file)
134+
response = files.upload(file=args.file, check=not args.no_check, model=args.model)
93135
print(json.dumps(response, indent=4))
94136

95137

src/together/complete.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,14 @@ def create(
6565

6666
if response.status_code == 429:
6767
logger.critical(
68-
f"No running instances for {model}. You can start an instance by navigating to the Together Playground at api.together.ai"
68+
f"""No running instances for {model}.
69+
You can start an instance with one of the following methods:
70+
1. navigating to the Together Playground at api.together.ai
71+
2. starting one in python using together.Models.start(model_name)
72+
3. `$ together models start <MODLE_NAME>` at the command line.
73+
See `together.Models.list()` in python or `$ together models list` in command line
74+
to get an updated list of valid model names.
75+
"""
6976
)
7077
raise together.InstanceError(model=model)
7178

@@ -140,7 +147,14 @@ def create_streaming(
140147
yield text
141148
elif response.status_code == 429:
142149
logger.critical(
143-
f"No running instances for {model}. You can start an instance by navigating to the Together Playground at api.together.ai"
150+
f"""No running instances for {model}.
151+
You can start an instance with one of the following methods:
152+
1. navigating to the Together Playground at api.together.ai
153+
2. starting one in python using together.Models.start(model_name)
154+
3. `$ together models start <MODLE_NAME>` at the command line.
155+
See `together.Models.list()` in python or `$ together models list` in command line
156+
to get an updated list of valid model names.
157+
"""
144158
)
145159
raise together.InstanceError(model=model)
146160
else:

0 commit comments

Comments
 (0)