Skip to content

Commit 21b8227

Browse files
authored
Merge pull request #136 from dataiku/fix/dss90-jupyter-contents
[Jupyter notebook] use "as_type" instead of "as_object"
2 parents c39d1ab + 6b00a3e commit 21b8227

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

dataikuapi/dss/project.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import time, warnings, sys, os.path as osp
22
from .dataset import DSSDataset, DSSDatasetListItem, DSSManagedDatasetCreationHelper
3-
from .jupyternotebook import DSSJupyterNotebook, DSSNotebookContent
3+
from .jupyternotebook import DSSJupyterNotebook
44
from .notebook import DSSNotebook
55
from .streaming_endpoint import DSSStreamingEndpoint, DSSStreamingEndpointListItem, DSSManagedStreamingEndpointCreationHelper
66
from .recipe import DSSRecipeListItem, DSSRecipe
@@ -829,23 +829,24 @@ def new_job_definition_builder(self, job_type='NON_RECURSIVE_FORCED_BUILD'):
829829
# Jupyter Notebooks
830830
########################################################
831831

832-
def list_jupyter_notebooks(self, as_objects=True, active=False):
832+
def list_jupyter_notebooks(self, active=False, as_type="object"):
833833
"""
834834
List the jupyter notebooks of a project.
835835
836-
:param bool as_objects: if True, return the jupyter notebooks as a :class:`dataikuapi.dss.notebook.DSSNotebook`
837-
notebook handles instead of raw JSON
836+
:param bool as_type: How to return the list. Supported values are "names" and "objects".
838837
:param bool active: if True, only return currently running jupyter notebooks.
839838
840-
841-
:returns: The list of the notebooks - see as_objects for more information
842-
:rtype: list
839+
:returns: The list of the notebooks. If "as_type" is "names", each one as a string, if "as_type" is "objects", each one as a :class:`dataikuapi.dss.notebook.DSSJupyterNotebook`
840+
:rtype: list of :class:`dataikuapi.dss.notebook.DSSJupyterNotebook` or list of String
843841
"""
844842
notebook_names = self.client._perform_json("GET", "/projects/%s/jupyter-notebooks/" % self.project_key, params={"active": active})
845-
if as_objects:
843+
if as_type == "names" or as_type == "name":
844+
return notebook_names
845+
elif as_type == "objects" or as_type == "object":
846846
return [DSSJupyterNotebook(self.client, self.project_key, notebook_name) for notebook_name in notebook_names]
847847
else:
848-
return notebook_names
848+
raise ValueError("Unknown as_type")
849+
849850

850851
def get_jupyter_notebook(self, notebook_name):
851852
"""

dataikuapi/dssclient.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
import json
2-
import warnings
32

43
from requests import Session
54
from requests import exceptions
65
from requests.auth import HTTPBasicAuth
76

8-
from dataikuapi.dss.jupyternotebook import DSSJupyterNotebook
97
from dataikuapi.dss.notebook import DSSNotebook
108
from .dss.future import DSSFuture
119
from .dss.projectfolder import DSSProjectFolder

0 commit comments

Comments
 (0)