Skip to content

Commit

Permalink
Useful error handling (#17)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
3 people authored Aug 18, 2023
1 parent 8d6551f commit 430563e
Show file tree
Hide file tree
Showing 9 changed files with 930 additions and 66 deletions.
315 changes: 284 additions & 31 deletions README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "hatchling.build"

[project]
name = "together"
version = "0.1.3"
version = "0.1.4"
authors = [
{ name="Together Computer", email="[email protected]" },
]
Expand Down
10 changes: 10 additions & 0 deletions src/together/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import os
import urllib.parse

from .config import (
finetune_model_names,
jokes_list,
min_samples,
model_info_dict,
)
from .version import VERSION


Expand Down Expand Up @@ -46,4 +52,8 @@
"Files",
"Finetune",
"Image",
"model_info_dict",
"finetune_model_names",
"min_samples",
"jokes_list",
]
44 changes: 43 additions & 1 deletion src/together/commands/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ def add_parser(subparsers: argparse._SubParsersAction[argparse.ArgumentParser])
child_parsers = parser.add_subparsers(required=True)

_add_list(child_parsers)
_add_check(child_parsers)
_add_upload(child_parsers)
_add_delete(child_parsers)
_add_retrieve(child_parsers)
Expand All @@ -24,6 +25,26 @@ def _add_list(parser: argparse._SubParsersAction[argparse.ArgumentParser]) -> No
subparser.set_defaults(func=_run_list)


def _add_check(parser: argparse._SubParsersAction[argparse.ArgumentParser]) -> None:
subparser = parser.add_parser("check")
subparser.add_argument(
"file",
metavar="FILENAME",
help="Local file to upload",
type=str,
)
subparser.add_argument(
"--model",
"-m",
default=None,
metavar="MODELNAME",
help="check data for this model's special tokens",
type=str,
required=False,
)
subparser.set_defaults(func=_run_check)


def _add_upload(parser: argparse._SubParsersAction[argparse.ArgumentParser]) -> None:
subparser = parser.add_parser("upload")
subparser.add_argument(
Expand All @@ -32,6 +53,21 @@ def _add_upload(parser: argparse._SubParsersAction[argparse.ArgumentParser]) ->
help="Local file to upload",
type=str,
)
subparser.add_argument(
"--no-check",
default=False,
action="store_true",
help="Indicates whether to disable checking",
)
subparser.add_argument(
"--model",
"-m",
default=None,
metavar="MODELNAME",
help="check data for this model's special tokens",
type=str,
required=False,
)
subparser.set_defaults(func=_run_upload)


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


def _run_check(args: argparse.Namespace) -> None:
files = Files()
response = files.check(args.file, args.model)
print(json.dumps(response, indent=4))


def _run_upload(args: argparse.Namespace) -> None:
files = Files()
response = files.upload(args.file)
response = files.upload(file=args.file, check=not args.no_check, model=args.model)
print(json.dumps(response, indent=4))


Expand Down
18 changes: 16 additions & 2 deletions src/together/complete.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,14 @@ def create(

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

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

0 comments on commit 430563e

Please sign in to comment.