From 8547320e3a31e8f0f756e33782b00cc53c892a94 Mon Sep 17 00:00:00 2001 From: Christina Kim Date: Wed, 14 Jul 2021 13:05:12 -0700 Subject: [PATCH] renaming snapshot to model (#27) * rename snapshot to model in sdk (#48) * updating version --- openai/__init__.py | 2 +- openai/api_resources/__init__.py | 2 +- openai/api_resources/completion.py | 2 +- openai/api_resources/engine.py | 2 +- .../api_resources/{snapshot.py => model.py} | 4 +- openai/cli.py | 39 ++++++++----------- openai/http_client.py | 2 +- openai/object_classes.py | 2 +- openai/version.py | 2 +- 9 files changed, 25 insertions(+), 32 deletions(-) rename openai/api_resources/{snapshot.py => model.py} (59%) diff --git a/openai/__init__.py b/openai/__init__.py index 38fa9a51d7..f9a6bad36e 100644 --- a/openai/__init__.py +++ b/openai/__init__.py @@ -33,7 +33,7 @@ ErrorObject, File, FineTune, - Snapshot, + Model, ) from openai.error import OpenAIError, APIError, InvalidRequestError # noqa: E402,F401 diff --git a/openai/api_resources/__init__.py b/openai/api_resources/__init__.py index 810bfd1725..a6da13b2df 100644 --- a/openai/api_resources/__init__.py +++ b/openai/api_resources/__init__.py @@ -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 diff --git a/openai/api_resources/completion.py b/openai/api_resources/completion.py index f39ef8f9f4..cd0d204370 100644 --- a/openai/api_resources/completion.py +++ b/openai/api_resources/completion.py @@ -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) diff --git a/openai/api_resources/engine.py b/openai/api_resources/engine.py index ec2f6c1e87..bc0b244f55 100644 --- a/openai/api_resources/engine.py +++ b/openai/api_resources/engine.py @@ -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) diff --git a/openai/api_resources/snapshot.py b/openai/api_resources/model.py similarity index 59% rename from openai/api_resources/snapshot.py rename to openai/api_resources/model.py index 41ab51521f..77d0322687 100644 --- a/openai/api_resources/snapshot.py +++ b/openai/api_resources/model.py @@ -4,6 +4,6 @@ ) -class Snapshot(ListableAPIResource, DeletableAPIResource): +class Model(ListableAPIResource, DeletableAPIResource): engine_required = False - OBJECT_NAME = "snapshot" + OBJECT_NAME = "model" diff --git a/openai/cli.py b/openai/cli.py index 2647d314dd..3ba502d766 100644 --- a/openai/cli.py +++ b/openai/cli.py @@ -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: @@ -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) @@ -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") diff --git a/openai/http_client.py b/openai/http_client.py index 0d256c8b16..a25bbd0053 100644 --- a/openai/http_client.py +++ b/openai/http_client.py @@ -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 diff --git a/openai/object_classes.py b/openai/object_classes.py index c3a47577bb..93f3d929e3 100644 --- a/openai/object_classes.py +++ b/openai/object_classes.py @@ -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, } diff --git a/openai/version.py b/openai/version.py index 38ed397f05..412148a32b 100644 --- a/openai/version.py +++ b/openai/version.py @@ -1 +1 @@ -VERSION = "0.9.4" +VERSION = "0.10.0"