Skip to content

Commit 369cb21

Browse files
committed
public api for notebooks
1 parent 7ce39ff commit 369cb21

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

dataikuapi/dss/project.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import sys
99
import os.path as osp
1010
from .future import DSSFuture
11+
from .notebook import DSSNotebook
1112

1213
class DSSProject(object):
1314
"""
@@ -493,4 +494,20 @@ def sync_datasets_acls(self):
493494
"POST", "/projects/%s/actions/sync" % (self.project_key))
494495
return DSSFuture(self.client, future_response.get('jobId', None), future_response)
495496

496-
497+
########################################################
498+
# Notebooks
499+
########################################################
500+
501+
def list_running_notebooks(self, as_objects=False):
502+
"""
503+
List the currently-running notebooks
504+
505+
Returns:
506+
list of notebooks. Each object contains at least a 'name' field
507+
"""
508+
list = self.client._perform_json("GET", "/projects/%s/notebooks/active" % self.project_key)
509+
if as_objects:
510+
return [DSSNotebook(self.client, notebook['projectKey'], notebook['name'], notebook) for notebook in list]
511+
else:
512+
return list
513+

dataikuapi/dssclient.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from dss.admin import DSSUser, DSSGroup, DSSConnection, DSSGeneralSettings
1010
from dss.meaning import DSSMeaning
1111
from dss.sqlquery import DSSSQLQuery
12+
from dss.notebook import DSSNotebook
1213
import os.path as osp
1314
from .utils import DataikuException
1415

@@ -76,6 +77,24 @@ def get_future(self, job_id):
7677
return DSSFuture(self, job_id)
7778

7879

80+
########################################################
81+
# Notebooks
82+
########################################################
83+
84+
def list_running_notebooks(self, as_objects=False):
85+
"""
86+
List the currently-running notebooks
87+
88+
Returns:
89+
list of notebooks. Each object contains at least a 'name' field
90+
"""
91+
list = self._perform_json("GET", "/admin/notebooks/")
92+
if as_objects:
93+
return [DSSNotebook(self, notebook['projectKey'], notebook['name'], notebook) for notebook in list]
94+
else:
95+
return list
96+
97+
7998
########################################################
8099
# Projects
81100
########################################################

0 commit comments

Comments
 (0)