Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions gradient/api_sdk/clients/notebook_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class NotebooksClient(TagsSupportMixin, BaseClient):
def create(
self,
machine_type,
project_id=None,
cluster_id=None,
container=None,
container_id=None,
Expand All @@ -30,6 +31,7 @@ def create(

:param str machine_type:
:param int container_id:
:param str|int project_id:
:param str cluster_id:
:param str container:
:param str name:
Expand All @@ -53,6 +55,7 @@ def create(

notebook = models.Notebook(
container_id=container_id,
project_id=project_id,
cluster_id=cluster_id,
container=container,
name=name,
Expand Down
11 changes: 6 additions & 5 deletions gradient/api_sdk/models/notebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ class Notebook(object):
container_user = attr.ib(type=str, default=None)
shutdown_timeout = attr.ib(type=int, default=None)
is_preemptible = attr.ib(type=bool, default=None)
project_id = attr.ib(type=bool, default=None)
state = attr.ib(type=bool, default=None)
vm_type = attr.ib(type=bool, default=None)
fqdn = attr.ib(type=bool, default=None)
project_id = attr.ib(type=str, default=None)
project_handle = attr.ib(type=str, default=None)
state = attr.ib(type=str, default=None)
vm_type = attr.ib(type=str, default=None)
fqdn = attr.ib(type=str, default=None)
namespace = attr.ib(type=str, default=None)
tags = attr.ib(type=list, factory=list)
metrics_url = attr.ib(type=str, default=None)
Expand Down Expand Up @@ -58,7 +59,7 @@ class Notebook(object):

@property
def url(self):
url = concatenate_urls(config.WEB_URL, "/{}/notebook/{}".format(self.namespace, self.project_id))
url = concatenate_urls(config.WEB_URL, "/{}/notebook/{}".format(self.namespace, self.project_handle))
return url


Expand Down
3 changes: 2 additions & 1 deletion gradient/api_sdk/serializers/notebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ class NotebookSchema(BaseSchema):
shutdown_timeout = marshmallow.fields.Int(load_from="shutdownTimeout", dump_to="shutdownTimeout")
is_preemptible = marshmallow.fields.Bool(load_from="isPreemptible", dump_to="isPreemptible")
is_public = marshmallow.fields.Bool(load_from="isPublic", dump_to="isPublic")
project_id = marshmallow.fields.Str(load_from="projectHandle", dump_to="projectHandle")
project_id = marshmallow.fields.Str(load_from="projectId", dump_to="projectId")
project_handle = marshmallow.fields.Str(load_from="projectHandle", dump_to="projectHandle")
state = marshmallow.fields.Str()
token = marshmallow.fields.Str()
job_error = marshmallow.fields.Str(load_from="jobError", dump_to="jobError")
Expand Down
8 changes: 8 additions & 0 deletions gradient/cli/notebooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ def notebook_metrics():
help="Container name",
cls=common.GradientOption,
)
@click.option(
"--projectId",
"project_id",
required=True,
type=str,
help="Project ID",
cls=common.GradientOption,
)
@click.option(
"--clusterId",
"cluster_id",
Expand Down
3 changes: 2 additions & 1 deletion tests/config_files/notebooks_create.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
apiKey: some_key
clusterId: 321
projectId: pr1234
container: "jupyter/notebook"
command: some_entrypoint
containerUser: some_container_user
Expand All @@ -11,4 +12,4 @@ shutdownTimeout: 8
machineType: P5000
environment:
key: val
workspace: https://github.com/fake/repo.git
workspace: https://github.com/fake/repo.git
7 changes: 6 additions & 1 deletion tests/functional/test_notebooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ class TestNotebooksCreate(object):
"create",
"--machineType", "P5000",
"--container", "jupyter/notebook",
"--clusterId", "321"
"--projectId", "pr1234",
"--clusterId", "321",
]
EXPECTED_REQUEST_JSON = {
"machineType": "P5000",
Expand All @@ -62,6 +63,7 @@ class TestNotebooksCreate(object):
"isPreemptible": False,
"isPublic": False,
"workspace": "none",
"projectId": "pr1234",
}
EXPECTED_RESPONSE_JSON = {
"handle": "some_id",
Expand All @@ -79,6 +81,7 @@ class TestNotebooksCreate(object):
"create",
"--machineType", "P5000",
"--container", "jupyter/notebook",
"--projectId", "pr1234",
"--clusterId", "321",
"--apiKey", "some_key",
]
Expand All @@ -88,6 +91,7 @@ class TestNotebooksCreate(object):
"create",
"--machineType", "P5000",
"--container", "jupyter/notebook",
"--projectId", "pr1234",
"--clusterId", "321",
"--name", "some_notebook_name",
"--registryUsername", "some_username",
Expand All @@ -102,6 +106,7 @@ class TestNotebooksCreate(object):
EXPECTED_REQUEST_JSON_WITH_ALL_OPTIONS = {
"machineType": "P5000",
"container": "jupyter/notebook",
"projectId": "pr1234",
"clusterId": "321",
"name": "some_notebook_name",
"registryUsername": "some_username",
Expand Down