Commit be66df0a authored by vermeul's avatar vermeul
Browse files

Merge branch 'release/0.4.0'

parents 5019bf8a 81671560
## jupyter-openbis-server 0.4.0
- added jupyter-openbis-conn utility to create a connection file
- made server compatible with Jupyter Lab 3.0
## jupyter-openbis-server 0.3.0
- removed fixed tornado version (5.1.1) to make it compatible with jupyter lab
......
......@@ -6,5 +6,5 @@ include LICENSE
# Include all files
recursive-include jupyter-openbis-server *.py
recursive-include openbis_connection *.py
recursive-include jupyter-config *.json
......@@ -9,13 +9,51 @@ This extension has been successfully tested with Safari 12.0.3, Chrome 72.0 and
The server extension will be automatically installed when you install the Jupyter Notebook Extension (the «classic» Jupyter Notebook):
```
pip install --upgrade jupyter-openbis-extension
$ pip install --upgrade jupyter-openbis-extension
```
If you need to install or upgrade the server extension alone, you can do so by:
```
pip install --upgrade jupyter-openbis-server
$ pip install --upgrade jupyter-openbis-server
```
Make sure your extension is recognised by Jupyter and enabled (your output may vary, but ensure you see the line: `jupyter-openbis-server.main OK`)
```
$ jupyter serverextension list
config dir: /Users/your_username/.pyenv/versions/3.6.9/etc/jupyter
jupyter-openbis-server.main enabled
- Validating...
jupyter-openbis-server.main OK
```
## Create a connection configuration file
When the module is installed, you can create a connection configuration file.
```bash
$ jupyter-openbis-conn --help
Usage: jupyter-openbis [OPTIONS]
Generate an openBIS connection file for use in Jupyter notebooks.
Options:
-n, --name TEXT
-h, --hostname TEXT
--verfiy / --no-verify
--https / --no-https
-u, --username TEXT
-p, --password TEXT
-d, --destination [/Users/your_username/.jupyter|/Users/your_username/.pyenv/versions/3.6.9/etc/jupyter|/usr/local/etc/jupyter|/etc/your_username]
[default: /Users/your_username/.jupyter]
--help Show this message and exit.
```
You can start the utility as-is to get prompted for every parameter. Username and password are optional.
````
$ jupyter-openbis-conn
```
## install Jupyter extension manually
......
name = 'jupyter-openbis-server.server'
__author__ = 'Swen Vermeul'
__email__ = 'swen@ethz.ch'
__version__ = '0.3.0'
__version__ = '0.4.0'
def _jupyter_server_extension_paths():
return [{
......
......@@ -157,3 +157,6 @@ def load_jupyter_server_extension(nb_server_app):
Requirements
)]
)
_load_jupyter_server_extension = load_jupyter_server_extension
import click
import yaml
import pathlib
from notebook import notebookapp
filepaths = notebookapp.jupyter_config_path()
@click.command()
@click.option('--name', '-n', prompt="Name of the connection")
@click.option('--hostname', '-h', prompt="Hostname of your openBIS instance")
@click.option('--verfiy/--no-verify', default=True, prompt="Verify server certificate")
@click.option('--https/--no-https', default=True, prompt="Use secure connection?")
@click.option('--username', '-u', default='', prompt="Username to connect to the openBIS instance")
@click.option('--password', '-p', default='', prompt="Password to connect to the openBIS instance")
@click.option('--destination', '-d', type=click.Choice(filepaths), show_default=True, default=filepaths[0], prompt="Destination where you want to store the configuration")
@click.pass_context
def cli(ctx, name=None, hostname=None, verfiy=True, https=True, username=None, password=None, destination=None):
"""Generate an openBIS connection file for use in Jupyter notebooks.
"""
config_filepath = pathlib.Path(destination) / 'openbis-connections.yaml'
if config_filepath.exists():
if not click.confirm(f"A configuration file already exists in {config_filepath}. Do you want to overwrite?"):
ctx.exit(code=0)
connection = {
"name" : name,
"url" : hostname,
"verify_certificates" : verfiy,
}
if username: connection['username'] = username
if password: connection['password'] = password
if not https: connection['http_only'] = True
template = {}
template['connections'] = [connection]
yaml_object = yaml.dump(template)
with open(config_filepath, "w") as outfile:
outfile.write(yaml_object)
print(f"sample openBIS connection file written to {config_filepath}")
if __name__ == '__main__':
cli()
......@@ -11,16 +11,18 @@ with open("README.md", "r", encoding="utf-8") as fh:
setup(
name='jupyter-openbis-server',
version= '0.3.0',
version= '0.4.0',
author='Swen Vermeul | ID SIS | ETH Zürich',
author_email='swen@ethz.ch',
description='Server Extension for Jupyter notebooks to connect to openBIS and download/upload datasets, inluding the notebook itself',
long_description=long_description,
long_description_content_type="text/markdown",
url='https://sissource.ethz.ch/sispub/jupyter-openbis-server',
packages=find_packages(),
packages=['jupyter-openbis-server', 'openbis_connection'],
license='Apache Software License Version 2.0',
install_requires=[
'click',
'pyyaml',
'jupyter-nbextensions-configurator',
'jupyter',
'pybis>=1.14.5',
......@@ -37,9 +39,19 @@ setup(
include_package_data=True,
data_files=[
# like `jupyter serverextension enable --sys-prefix`
("etc/jupyter/jupyter_notebook_config.d", [
"jupyter-config/jupyter_notebook_config.d/jupyter_openbis_extension.json"
])
(
"etc/jupyter/jupyter_server_config.d",
["jupyter-config/jupyter_server_config.d/jupyter_openbis_extension.json"]
),
(
"etc/jupyter/jupyter_notebook_config.d",
["jupyter-config/jupyter_notebook_config.d/jupyter_openbis_extension.json"]
)
],
entry_points={
'console_scripts' : [
'jupyter-openbis-conn=openbis_connection.main:cli',
]
},
zip_safe=False,
)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment