-
Notifications
You must be signed in to change notification settings - Fork 27
Python wrapper for Jupyter Notebooks Public API #121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Python wrapper for Jupyter Notebooks Public API #121
Conversation
This pull request has been linked to Clubhouse Story #56395: Public API to list / get Jupyter notebooks. |
dataikuapi/dss/notebook.py
Outdated
|
||
def get_state(self): | ||
""" | ||
Get the status of the notebook | ||
""" | ||
if self.state is None: | ||
self.state = self.client._perform_json("GET", "/projects/%s/notebooks/" % self.project_key, params={'notebookName' : self.notebook_name}) | ||
notebook_list = self.client._perform_json("GET", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we keep the cache mechanism?
(If you put back the cache, maybe you should add with an optional parameter clear_cache = false
for when the user know the cache is wrong. Or a clear_cache()
method)
dataikuapi/dss/notebook.py
Outdated
|
||
def get_state(self): | ||
""" | ||
Get the status of the notebook | ||
""" | ||
if self.state is None: | ||
self.state = self.client._perform_json("GET", "/projects/%s/notebooks/" % self.project_key, params={'notebookName' : self.notebook_name}) | ||
notebook_list = self.client._perform_json("GET", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This variable contains the metadata of the notebook, not a notebook.
The java object is names JupyterNotebookListItem
which is super confusing so maybe let's not use that.
Maybe something like:
notebook_list = self.client._perform_json("GET", | |
notebook_states = self.client._perform_json("GET", |
dataikuapi/dss/notebook.py
Outdated
@@ -27,14 +28,20 @@ def unload(self, session_id=None): | |||
raise Exception("Several sessions of the notebook are running, choose one") | |||
else: | |||
session_id = state['activeSessions'][0].get('sessionId', None) | |||
return self.client._perform_json("DELETE", "/projects/%s/notebooks/" % self.project_key, params={'notebookName' : self.notebook_name, 'sessionId' : session_id}) | |||
return self.client._perform_json("DELETE", | |||
"/projects/%s/jupyter-notebooks/%s/sessions/%s" % (self.project_key, self.notebook_name, session_id)) | |||
|
|||
def get_state(self): | |||
""" | |||
Get the status of the notebook |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is (and was) not compatible with SQL notebooks
Get the status of the notebook | |
Get the status of the Jupyter notebook |
⬆️ I created a new PR based on the suggested changes to add an endpoint for sessions and return the object on create/update |
* Use new sessions endpoint in get_sessions call * Put back cache for state with a refresh parameter to get the state directly from backend * Return created notebook as object
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Story details : [ch56395]