Overview
This interface layer handles the communication between the Apache Zeppelin charm and other charms wishing to register a notebook with Zeppelin.
Usage
Charms Registering a Notebook
Charms that wish to register a notebook with Zeppelin should require this
interface. The interface layer will set the following state when appropriate:
-
{relation_name}.joinedindicates that Apache Zeppelin is present, and thus a notebook can be registered with theregister_notebookmethod. -
{relation_name}.notebook.acceptedindicates that Apache Zeppelin has accepted one or more of the requested notebooks. You can get a list of the accepted notebook filenames with theaccepted_notebooksmethod. -
{relation_name}.notebook.rejectedindicates that Apache Zeppelin has rejected one or more of the requested notebooks. You can get a list of the rejected notebook filenames with therejected_notebooksmethod.
The register_notebook method can be passed either a filename or a contents
string.
An example of how a charm would use this interface would be:
@when('zeppelin.joined')
def register_notebook(zeppelin):
zeppelin.register_notebook(filename='files/notebook.json')
@when('zeppelin.notebook.rejected')
def report_rejected_notebook(zeppelin):
status_set('blocked', 'Zeppelin rejected our notebook')Zeppelin
The Zeppelin charm should provide this interface. The interface layer will
set the following states when appropriate:
-
{relation_name}.notebook.registeredindicates that a client has registered a notebook. The charm would then iterate over theunregistered_notebooks, handle them, and use eitheraccept_notebookorreject_notebookmethods to acknowledge them. -
{relation_name}.notebook.removedindicates that a client has disconnected and so its notebooks should be removed. The charm would then use theunremoved_notebooksmethod to iterate over the notebooks to be removed and callremove_notebookto acknowledge them.
An example of how the Zeppelin charm would use this interface would be:
@when('zeppelin.installed', 'client.notebook.registered')
def register_notebook(client):
api = ZeppelinAPI()
for notebook in client.unregistered_notebooks():
if api.import_notebook(notebook):
client.accept_notebook(notebook)
else:
client.reject_notebook(notebook)
@when('zeppelin.installed', 'client.notebook.removed')
def remove_notebook(client):
api = ZeppelinAPI()
for notebook in client.unremoved_notebooks():
notebook_id = json.loads(notebook)['id']
api.delete_notebook(notebook_id)
client.remove_notebook(notebook)