Skip to content

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

Merged
merged 8 commits into from
Feb 15, 2021

Conversation

william-lukusa
Copy link
Contributor

Story details : [ch56395]

@william-lukusa william-lukusa added this to the 9.0 milestone Feb 5, 2021
@william-lukusa william-lukusa self-assigned this Feb 5, 2021
@shortcut-integration
Copy link

This pull request has been linked to Clubhouse Story #56395: Public API to list / get Jupyter notebooks.


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",
Copy link
Contributor

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)


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",
Copy link
Contributor

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:

Suggested change
notebook_list = self.client._perform_json("GET",
notebook_states = self.client._perform_json("GET",

@@ -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
Copy link
Contributor

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

Suggested change
Get the status of the notebook
Get the status of the Jupyter notebook

@william-lukusa
Copy link
Contributor Author

william-lukusa commented Feb 8, 2021

⬆️ 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
Copy link
Contributor

@pbailly pbailly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@william-lukusa william-lukusa merged commit f058695 into master Feb 15, 2021
@pbailly pbailly deleted the feature/dss90-jupyter-notebooks-public-api branch February 16, 2021 09:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants