Skip to content

Commit

Permalink
renaming snapshot to model (#27)
Browse files Browse the repository at this point in the history
* rename snapshot to model in sdk (#48)

* updating version
  • Loading branch information
christinakim authored Jul 14, 2021
1 parent fc1d9db commit 8547320
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 32 deletions.
2 changes: 1 addition & 1 deletion openai/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
ErrorObject,
File,
FineTune,
Snapshot,
Model,
)

from openai.error import OpenAIError, APIError, InvalidRequestError # noqa: E402,F401
2 changes: 1 addition & 1 deletion openai/api_resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
from openai.api_resources.file import File # noqa: F401
from openai.api_resources.answer import Answer # noqa: F401
from openai.api_resources.classification import Classification # noqa: F401
from openai.api_resources.snapshot import Snapshot # noqa: F401
from openai.api_resources.model import Model # noqa: F401
from openai.api_resources.fine_tune import FineTune # noqa: F401
2 changes: 1 addition & 1 deletion openai/api_resources/completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ def create(cls, *args, **kwargs):
if timeout is not None and time.time() > start + timeout:
raise

util.log_info("Waiting for snapshot to warm up", error=e)
util.log_info("Waiting for model to warm up", error=e)
2 changes: 1 addition & 1 deletion openai/api_resources/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def generate(self, timeout=None, **params):
if timeout is not None and time.time() > start + timeout:
raise

util.log_info("Waiting for snapshot to warm up", error=e)
util.log_info("Waiting for model to warm up", error=e)

def search(self, **params):
return self.request("post", self.instance_url() + "/search", params)
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
)


class Snapshot(ListableAPIResource, DeletableAPIResource):
class Model(ListableAPIResource, DeletableAPIResource):
engine_required = False
OBJECT_NAME = "snapshot"
OBJECT_NAME = "model"
39 changes: 16 additions & 23 deletions openai/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,23 +176,23 @@ def create(cls, args):
sys.stdout.flush()


class Snapshot:
class Model:
@classmethod
def get(cls, args):
resp = openai.Snapshot.retrieve(
resp = openai.Model.retrieve(
engine=args.engine, id=args.id, timeout=args.timeout
)
print(resp)

@classmethod
def delete(cls, args):
snapshot = openai.Snapshot(id=args.id).delete()
print(snapshot)
model = openai.Model(id=args.id).delete()
print(model)

@classmethod
def list(cls, args):
snapshots = openai.Snapshot.list()
print(snapshots)
models = openai.Model.list()
print(models)


class File:
Expand Down Expand Up @@ -536,7 +536,7 @@ def help(args):
"-m",
"--model",
required=False,
help="A model (most commonly a snapshot ID) to generate from. Defaults to the engine's default snapshot.",
help="A model (most commonly a model ID) to generate from. Defaults to the engine's default model.",
)
sub.set_defaults(func=Engine.generate)

Expand Down Expand Up @@ -621,24 +621,17 @@ def help(args):
)
sub.set_defaults(func=Completion.create)

# Snapshots
sub = subparsers.add_parser("snapshots.list")
sub.set_defaults(func=Snapshot.list)
# Models
sub = subparsers.add_parser("models.list")
sub.set_defaults(func=Model.list)

sub = subparsers.add_parser("snapshots.get")
sub.add_argument("-e", "--engine", help="The engine this snapshot is running on")
sub.add_argument("-i", "--id", required=True, help="The snapshot ID")
sub.add_argument(
"-t",
"--timeout",
help="An optional amount of time to block for the snapshot to transition from pending. If the timeout expires, a pending snapshot will be returned.",
type=float,
)
sub.set_defaults(func=Snapshot.get)
sub = subparsers.add_parser("models.get")
sub.add_argument("-i", "--id", required=True, help="The model ID")
sub.set_defaults(func=Model.get)

sub = subparsers.add_parser("snapshots.delete")
sub.add_argument("-i", "--id", required=True, help="The snapshot ID")
sub.set_defaults(func=Snapshot.delete)
sub = subparsers.add_parser("models.delete")
sub.add_argument("-i", "--id", required=True, help="The model ID")
sub.set_defaults(func=Model.delete)

# Files
sub = subparsers.add_parser("files.create")
Expand Down
2 changes: 1 addition & 1 deletion openai/http_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ def _handle_request_error(self, e):

@staticmethod
def _sanitized_url(url):
""" for now just strip all query params from the url for privacy"""
"""for now just strip all query params from the url for privacy"""
url = urlparse(url)
return url.scheme + "://" + url.netloc + url.path

Expand Down
2 changes: 1 addition & 1 deletion openai/object_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
"experimental.completion_config": CompletionConfig,
"file": api_resources.File,
"fine-tune": api_resources.FineTune,
"snapshot": api_resources.Snapshot,
"model": api_resources.Model,
}
2 changes: 1 addition & 1 deletion openai/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION = "0.9.4"
VERSION = "0.10.0"

0 comments on commit 8547320

Please sign in to comment.