|
1 | 1 | import time, warnings, sys, os.path as osp |
2 | 2 | from .dataset import DSSDataset, DSSDatasetListItem, DSSManagedDatasetCreationHelper |
3 | | -from .jupyternotebook import DSSJupyterNotebook, DSSNotebookContent |
| 3 | +from .jupyternotebook import DSSJupyterNotebook |
4 | 4 | from .notebook import DSSNotebook |
5 | 5 | from .streaming_endpoint import DSSStreamingEndpoint, DSSStreamingEndpointListItem, DSSManagedStreamingEndpointCreationHelper |
6 | 6 | from .recipe import DSSRecipeListItem, DSSRecipe |
@@ -829,23 +829,24 @@ def new_job_definition_builder(self, job_type='NON_RECURSIVE_FORCED_BUILD'): |
829 | 829 | # Jupyter Notebooks |
830 | 830 | ######################################################## |
831 | 831 |
|
832 | | - def list_jupyter_notebooks(self, as_objects=True, active=False): |
| 832 | + def list_jupyter_notebooks(self, active=False, as_type="object"): |
833 | 833 | """ |
834 | 834 | List the jupyter notebooks of a project. |
835 | 835 |
|
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". |
838 | 837 | :param bool active: if True, only return currently running jupyter notebooks. |
839 | 838 |
|
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 |
843 | 841 | """ |
844 | 842 | 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": |
846 | 846 | return [DSSJupyterNotebook(self.client, self.project_key, notebook_name) for notebook_name in notebook_names] |
847 | 847 | else: |
848 | | - return notebook_names |
| 848 | + raise ValueError("Unknown as_type") |
| 849 | + |
849 | 850 |
|
850 | 851 | def get_jupyter_notebook(self, notebook_name): |
851 | 852 | """ |
|
0 commit comments