Skip to content

Instantly share code, notes, and snippets.

@bmmalone
Last active November 28, 2024 12:55
Show Gist options
  • Save bmmalone/b5a0f44412d693d332b3e319f369bb06 to your computer and use it in GitHub Desktop.
Save bmmalone/b5a0f44412d693d332b3e319f369bb06 to your computer and use it in GitHub Desktop.
def add_home_dir(*fn):
import os.path
return os.path.join(os.path.expanduser('~'), *fn)
c.ServerApp.ip = '*'
c.ServerApp.port = 9999
c.ServerApp.certfile = add_home_dir('certs', 'mycert.pem')
c.ServerApp.keyfile = add_home_dir('certs', 'mykey.key')
c.NotebookApp.open_browser = False
c.LabApp.open_browser = False
c.ServerApp.open_browser = False
c.PasswordIdentityProvider.hashed_password = u'sha1:5f2cf85d2872:e9b52b2240cbcde307b5907e5c3848f3f9fd8a92' # 31KT
#------------------------------------------------------------------------------
# Configurable configuration
#------------------------------------------------------------------------------
# templates
c.JupyterLabTemplates.template_dirs = [add_home_dir('jupyter-templates')]
c.JupyterLabTemplates.include_default = False
conda create --name "jupyterlab" pip wheel jupyter ipykernel
conda activate jupyterlab
conda install -c conda-forge jupyterlab
conda install -c conda-forge nodejs
conda install -c conda-forge jupyterlab_templates
#jupyter serverextension enable --py jupyterlab_templates
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Getting start\n",
"\n",
"1. Given the notebook a meaningful name.\n",
"2. Select an appropriate kernel."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Imports"
]
},
{
"cell_type": "markdown",
"metadata": {
"Collapsed": "false"
},
"source": [
"#### Standard pydata imports\n",
"\n",
"This also creates a default `logger` for use in the notebook."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"Collapsed": "false"
},
"outputs": [],
"source": [
"%load_ext autoreload\n",
"%autoreload 2\n",
"%matplotlib inline\n",
"\n",
"from argparse import Namespace\n",
"\n",
"try:\n",
" import pyllars.logging_utils as logging_utils\n",
" logger = logging_utils.get_ipython_logger()\n",
" logger.setLevel('INFO')\n",
"except:\n",
" pass\n",
"\n",
"# standard pydata imports\n",
"import joblib\n",
"import matplotlib.pyplot as plt\n",
"import networkx as nx\n",
"import numpy as np\n",
"import pandas as pd\n",
"import pathlib\n",
"import seaborn as sns; sns.set(style='white', color_codes=True)\n",
"import tqdm\n",
"import yaml"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Typing imports"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from typing import Mapping"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Custom imports"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import pyllars.collection_utils as collection_utils\n",
"import pyllars.mpl_utils as mpl_utils\n",
"import pyllars.pandas_utils as pd_utils"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Constants"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"BASE = pathlib.Path(\"/prj/\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Functions"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"def load_data():\n",
" path = BASE / \"to\" / \"data.csv\"\n",
" df = pd.read_csv(path)\n",
" return df"
]
},
{
"cell_type": "markdown",
"metadata": {
"Collapsed": "false"
},
"source": [
"## Start code"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"Collapsed": "false"
},
"outputs": [],
"source": [
"args = Namespace()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"Collapsed": "false"
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
@bmmalone
Copy link
Author

The template should likely be placed at $HOME/jupyter-templates/templates.

@bmmalone
Copy link
Author

bmmalone commented Jul 28, 2021

The certificate and key are self-signed using the method described here. Namely, the following command is used:

openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout mykey.key -out mycert.pem

The config file expects these to be located in $HOME/certs.


Update:

The following command also specifies the certificate details from the command line and requires no user input:

openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout mykey.key -out mycert.pem -subj "/C=DE/ST= /L= /O= /OU= /CN= "

The password specified in the template to access the server is 31KT.

@bmmalone
Copy link
Author

The config file should be located in $HOME/.jupyter

@bmmalone
Copy link
Author

The following error message (and similar) is common when using Chrome to access the server:

SSL Error on 8 ('::1', 53988, 0, 0): [SSL: SSLV3_ALERT_CERTIFICATE_UNKNOWN] ssl/tls alert certificate unknown (_ssl.c:1000)

This appears to be specific to Chrome. If it does not appear when using some other browser, then it can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment