From c934bc15a102ba006e3a36bfddb8207b34da855d Mon Sep 17 00:00:00 2001 From: Ben Batha Date: Fri, 29 May 2020 10:53:54 -0400 Subject: [PATCH 1/2] feat(notebooks): support normalized command argument instead of defaultEntrypoint PS-13616 --- gradient/api_sdk/clients/notebook_client.py | 3 +++ gradient/api_sdk/models/notebook.py | 1 + gradient/api_sdk/serializers/notebook.py | 2 ++ gradient/cli/notebooks.py | 2 +- tests/config_files/notebooks_create.yaml | 3 +-- tests/functional/test_notebooks.py | 2 +- 6 files changed, 9 insertions(+), 4 deletions(-) diff --git a/gradient/api_sdk/clients/notebook_client.py b/gradient/api_sdk/clients/notebook_client.py index 5365c9e2..2808fab0 100644 --- a/gradient/api_sdk/clients/notebook_client.py +++ b/gradient/api_sdk/clients/notebook_client.py @@ -15,6 +15,7 @@ def create( name=None, registry_username=None, registry_password=None, + command=None, default_entrypoint=None, container_user=None, shutdown_timeout=None, @@ -32,6 +33,7 @@ def create( :param str name: :param str registry_username: :param str registry_password: + :param str command: :param str default_entrypoint: :param str container_user: :param int shutdown_timeout: @@ -50,6 +52,7 @@ def create( name=name, registry_username=registry_username, registry_password=registry_password, + command=command, default_entrypoint=default_entrypoint, container_user=container_user, shutdown_timeout=shutdown_timeout, diff --git a/gradient/api_sdk/models/notebook.py b/gradient/api_sdk/models/notebook.py index a5522d81..17f23cb8 100644 --- a/gradient/api_sdk/models/notebook.py +++ b/gradient/api_sdk/models/notebook.py @@ -17,6 +17,7 @@ class Notebook(object): cluster_id = attr.ib(type=str, default=None) registry_username = attr.ib(type=str, default=None) registry_password = attr.ib(type=str, default=None) + command = attr.ib(type=str, default=None) default_entrypoint = attr.ib(type=str, default=None) container_user = attr.ib(type=str, default=None) shutdown_timeout = attr.ib(type=int, default=None) diff --git a/gradient/api_sdk/serializers/notebook.py b/gradient/api_sdk/serializers/notebook.py index 285f4820..261d7401 100644 --- a/gradient/api_sdk/serializers/notebook.py +++ b/gradient/api_sdk/serializers/notebook.py @@ -17,6 +17,7 @@ class NotebookSchema(BaseSchema): cluster_id = marshmallow.fields.Str(load_from="clusterId", dump_to="clusterId") registry_username = marshmallow.fields.Str(load_from="registryUsername", dump_to="registryUsername") registry_password = marshmallow.fields.Str(load_from="registryPassword", dump_to="registryPassword") + command = marshmallow.fields.Str(load_from="command", dump_to="command") default_entrypoint = marshmallow.fields.Str(load_from="defaultEntrypoint", dump_to="defaultEntrypoint") container_user = marshmallow.fields.Str(load_from="containerUser", dump_to="containerUser") shutdown_timeout = marshmallow.fields.Int(load_from="shutdownTimeout", dump_to="shutdownTimeout") @@ -52,6 +53,7 @@ class NotebookSchema(BaseSchema): def preprocess(self, data, **kwargs): data = copy.copy(data) + utils.base64_encode_attribute(data, "command") utils.base64_encode_attribute(data, "default_entrypoint") return data diff --git a/gradient/cli/notebooks.py b/gradient/cli/notebooks.py index dc8448c2..56d436d4 100644 --- a/gradient/cli/notebooks.py +++ b/gradient/cli/notebooks.py @@ -77,7 +77,7 @@ def notebook_metrics(): ) @click.option( "--command", - "default_entrypoint", + "command", type=str, help="Command (executed as `/bin/sh -c 'YOUR COMMAND'`)", cls=common.GradientOption, diff --git a/tests/config_files/notebooks_create.yaml b/tests/config_files/notebooks_create.yaml index 43a12dd3..49c9f781 100644 --- a/tests/config_files/notebooks_create.yaml +++ b/tests/config_files/notebooks_create.yaml @@ -1,9 +1,8 @@ apiKey: some_key clusterId: 321 container: "jupyter/notebook" -command: "some_entrypoint" +command: some_entrypoint containerUser: some_container_user -defaultEntrypoint: some_entrypoint isPreemptible: true name: some_notebook_name registryPassword: some_password diff --git a/tests/functional/test_notebooks.py b/tests/functional/test_notebooks.py index 3607edf4..db44fc11 100644 --- a/tests/functional/test_notebooks.py +++ b/tests/functional/test_notebooks.py @@ -103,7 +103,7 @@ class TestNotebooksCreate(object): "name": "some_notebook_name", "registryUsername": "some_username", "registryPassword": "some_password", - "defaultEntrypoint": "c29tZV9lbnRyeXBvaW50", + "command": "c29tZV9lbnRyeXBvaW50", "containerUser": "some_container_user", "shutdownTimeout": 8, "isPreemptible": True, From 598874ad68ccbc392ef916e959db4b8e42fa2a99 Mon Sep 17 00:00:00 2001 From: Ben Batha Date: Wed, 3 Jun 2020 16:30:51 -0400 Subject: [PATCH 2/2] fixup! feat(notebooks): support normalized command argument instead of defaultEntrypoint PS-13616 --- gradient/api_sdk/clients/notebook_client.py | 3 --- gradient/api_sdk/serializers/notebook.py | 1 - 2 files changed, 4 deletions(-) diff --git a/gradient/api_sdk/clients/notebook_client.py b/gradient/api_sdk/clients/notebook_client.py index 2808fab0..b5adbd59 100644 --- a/gradient/api_sdk/clients/notebook_client.py +++ b/gradient/api_sdk/clients/notebook_client.py @@ -16,7 +16,6 @@ def create( registry_username=None, registry_password=None, command=None, - default_entrypoint=None, container_user=None, shutdown_timeout=None, is_preemptible=None, @@ -34,7 +33,6 @@ def create( :param str registry_username: :param str registry_password: :param str command: - :param str default_entrypoint: :param str container_user: :param int shutdown_timeout: :param bool is_preemptible: @@ -53,7 +51,6 @@ def create( registry_username=registry_username, registry_password=registry_password, command=command, - default_entrypoint=default_entrypoint, container_user=container_user, shutdown_timeout=shutdown_timeout, is_preemptible=is_preemptible, diff --git a/gradient/api_sdk/serializers/notebook.py b/gradient/api_sdk/serializers/notebook.py index 261d7401..428c0ff7 100644 --- a/gradient/api_sdk/serializers/notebook.py +++ b/gradient/api_sdk/serializers/notebook.py @@ -54,7 +54,6 @@ def preprocess(self, data, **kwargs): data = copy.copy(data) utils.base64_encode_attribute(data, "command") - utils.base64_encode_attribute(data, "default_entrypoint") return data