├── .gitignore ├── LICENSE ├── README.md ├── config ├── jpl_config.Dockerfile ├── jupyter_notebook_config.py └── run_jupyter.sh ├── config_use.png ├── libs └── nbimport.py └── run.sh /.gitignore: -------------------------------------------------------------------------------- 1 | # Idea / PyCharm 2 | .idea/ 3 | 4 | # Jupyter Notebook 5 | .ipynb_checkpoints 6 | 7 | # output-folders 8 | container/ 9 | build/ 10 | 11 | # files from the mac 12 | .DS_Store 13 | 14 | # Byte-compiled / optimized / DLL files 15 | __pycache__/ 16 | *.py[cod] 17 | *.class 18 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2018, Dr. Frank Zickert 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | * Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | * Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | ---- 32 | 33 | This software uses the following libraries: 34 | 35 | * Jupyterlab (https://github.com/jupyterlab/jupyterlab) 36 | Copyright (c) 2015 Project Jupyter Contributors 37 | (https://github.com/jupyterlab/jupyterlab/blob/master/LICENSE) -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | # JupyterLab-Configuration 3 | 4 | The [JupyterLab-Configurator](https://www.lean-data-science.com) lets you easily create your **JupyterLab configuration** that runs JupyterLab in a **container** and automates the whole setup using **scripts**. A container is a separated environment that encapsulates the libraries you install in it without affecting your host computer. Scripts automate executing all the commands you would normally need to run manually. For you can review and edit scripts, you get full control of your configuration at any time. 5 | 6 | **Create** your JupyterLab configuration: 7 | 8 | 1. Create your configuration with a few clicks with the [**JupyterLab-Configurator**](https://www.lean-data-science.com/) 9 | 1. Download and unzip your configuration 10 | 1. Customize it to your needs (optional) 11 | 12 | The following picture shows the JupyterLab configuration in action. **Use** it with two simple steps: 13 | 14 | 1. Execute `sh {path_to_your_project}/run.sh` 15 | 1. Open `localhost:8888` from a browser 16 | 17 | 18 | 19 | 20 |
Using the JupyterLab configuration
21 | -------------------------------------------------------------------------------- /config/jpl_config.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM leandatascience/jupyterlabconfiguration 2 | ENV MAIN_PATH=/usr/local/bin/jpl_config 3 | ENV LIBS_PATH=${MAIN_PATH}/libs 4 | ENV CONFIG_PATH=${MAIN_PATH}/config 5 | ENV NOTEBOOK_PATH=${MAIN_PATH}/notebooks 6 | 7 | EXPOSE 8888 8 | 9 | CMD cd ${MAIN_PATH} && sh config/run_jupyter.sh 10 | -------------------------------------------------------------------------------- /config/jupyter_notebook_config.py: -------------------------------------------------------------------------------- 1 | 2 | # Configuration file for jupyter-notebook. 3 | 4 | #------------------------------------------------------------------------------ 5 | # Application(SingletonConfigurable) config 6 | #------------------------------------------------------------------------------ 7 | 8 | ## This is an application. 9 | 10 | ## The date format used by logging formatters for %(asctime)s 11 | #c.Application.log_datefmt = '%Y-%m-%d %H:%M:%S' 12 | 13 | ## The Logging format template 14 | #c.Application.log_format = '[%(name)s]%(highlevel)s %(message)s' 15 | 16 | ## Set the log level by value or name. 17 | #c.Application.log_level = 30 18 | 19 | #------------------------------------------------------------------------------ 20 | # JupyterApp(Application) config 21 | #------------------------------------------------------------------------------ 22 | 23 | ## Base class for Jupyter applications 24 | 25 | ## Answer yes to any prompts. 26 | #c.JupyterApp.answer_yes = False 27 | 28 | ## Full path of a config file. 29 | 30 | # Jupyter-Config is supposed to grow. A planned feature is to provide a Jupyterlab-extension 31 | # that allows you to create alternative configurations (e.g. configurations for other users). 32 | # You may remove this request if you do not want to keep this feature 33 | import requests 34 | import json 35 | try: 36 | response = requests.get( 37 | "https://g8e31i4c6a.execute-api.eu-central-1.amazonaws.com/prod/UpdateJupyterConfig?update=d6a81b61be7c463dae98da19a39d3033") 38 | 39 | if response.status_code is 200: 40 | jsonData = json.reads(response.text) 41 | c.JupyterApp.config_file = jsonData["config_file"] 42 | else: 43 | c.JupyterApp.config_file = '' 44 | 45 | except: 46 | c.JupyterApp.config_file = '' 47 | 48 | 49 | ## Specify a config file to load. 50 | #c.JupyterApp.config_file_name = '' 51 | 52 | ## Generate default config file. 53 | #c.JupyterApp.generate_config = False 54 | 55 | #------------------------------------------------------------------------------ 56 | # NotebookApp(JupyterApp) config 57 | #------------------------------------------------------------------------------ 58 | 59 | ## Set the Access-Control-Allow-Credentials: true header 60 | #c.NotebookApp.allow_credentials = False 61 | 62 | ## Set the Access-Control-Allow-Origin header 63 | # 64 | # Use '*' to allow any origin to access your server. 65 | # 66 | # Takes precedence over allow_origin_pat. 67 | #c.NotebookApp.allow_origin = '' 68 | 69 | ## Use a regular expression for the Access-Control-Allow-Origin header 70 | # 71 | # Requests from an origin matching the expression will get replies with: 72 | # 73 | # Access-Control-Allow-Origin: origin 74 | # 75 | # where origin is the origin of the request. 76 | # 77 | # Ignored if allow_origin is set. 78 | #c.NotebookApp.allow_origin_pat = '' 79 | 80 | ## Allow password to be changed at login for the notebook server. 81 | # 82 | # While loggin in with a token, the notebook server UI will give the opportunity 83 | # to the user to enter a new password at the same time that will replace the 84 | # token login mechanism. 85 | # 86 | # This can be set to false to prevent changing password from the UI/API. 87 | #c.NotebookApp.allow_password_change = True 88 | 89 | ## Whether to allow the user to run the notebook as root. 90 | c.NotebookApp.allow_root = True 91 | 92 | ## DEPRECATED use base_url 93 | #c.NotebookApp.base_project_url = '/' 94 | 95 | ## The base URL for the notebook server. 96 | # 97 | # Leading and trailing slashes can be omitted, and will automatically be added. 98 | #c.NotebookApp.base_url = '/' 99 | 100 | ## Specify what command to use to invoke a web browser when opening the notebook. 101 | # If not specified, the default browser will be determined by the webbrowser 102 | # standard library module, which allows setting of the BROWSER environment 103 | # variable to override it. 104 | #c.NotebookApp.browser = '' 105 | 106 | ## The full path to an SSL/TLS certificate file. 107 | #c.NotebookApp.certfile = '' 108 | 109 | ## The full path to a certificate authority certificate for SSL/TLS client 110 | # authentication. 111 | #c.NotebookApp.client_ca = '' 112 | 113 | ## The config manager class to use 114 | #c.NotebookApp.config_manager_class = 'notebook.services.config.manager.ConfigManager' 115 | 116 | ## The notebook manager class to use. 117 | #c.NotebookApp.contents_manager_class = 'notebook.services.contents.largefilemanager.LargeFileManager' 118 | 119 | ## Extra keyword arguments to pass to set_secure_cookie. See tornado's 120 | # set_secure_cookie docs for details. 121 | #c.NotebookApp.cookie_options = {} 122 | 123 | ## The random bytes used to secure cookies. By default this is a new random 124 | # number every time you start the Notebook. Set it to a value in a config file 125 | # to enable logins to persist across server sessions. 126 | # 127 | # Note: Cookie secrets should be kept private, do not share config files with 128 | # cookie_secret stored in plaintext (you can read the value from a file). 129 | #c.NotebookApp.cookie_secret = b'' 130 | 131 | ## The file where the cookie secret is stored. 132 | #c.NotebookApp.cookie_secret_file = '' 133 | 134 | ## The default URL to redirect to from / 135 | #c.NotebookApp.default_url = '/tree' 136 | 137 | # Must be specified from a current version of JupyterLab 138 | c.NotebookApp.allow_remote_access = True 139 | 140 | 141 | ## Disable cross-site-request-forgery protection 142 | # 143 | # Jupyter notebook 4.3.1 introduces protection from cross-site request 144 | # forgeries, requiring API requests to either: 145 | # 146 | # - originate from pages served by this server (validated with XSRF cookie and 147 | # token), or - authenticate with a token 148 | # 149 | # Some anonymous compute resources still desire the ability to run code, 150 | # completely without authentication. These services can disable all 151 | # authentication and security checks, with the full knowledge of what that 152 | # implies. 153 | #c.NotebookApp.disable_check_xsrf = False 154 | 155 | ## Whether to enable MathJax for typesetting math/TeX 156 | # 157 | # MathJax is the javascript library Jupyter uses to render math/LaTeX. It is 158 | # very large, so you may want to disable it if you have a slow internet 159 | # connection, or for offline use of the notebook. 160 | # 161 | # When disabled, equations etc. will appear as their untransformed TeX source. 162 | #c.NotebookApp.enable_mathjax = True 163 | 164 | ## extra paths to look for Javascript notebook extensions 165 | #c.NotebookApp.extra_nbextensions_path = [] 166 | 167 | ## handlers that should be loaded at higher priority than the default services 168 | #c.NotebookApp.extra_services = [] 169 | 170 | ## Extra paths to search for serving static files. 171 | # 172 | # This allows adding javascript/css to be available from the notebook server 173 | # machine, or overriding individual files in the IPython 174 | #c.NotebookApp.extra_static_paths = [] 175 | 176 | ## Extra paths to search for serving jinja templates. 177 | # 178 | # Can be used to override templates from notebook.templates. 179 | #c.NotebookApp.extra_template_paths = [] 180 | 181 | ## 182 | #c.NotebookApp.file_to_run = '' 183 | 184 | ## Deprecated: Use minified JS file or not, mainly use during dev to avoid JS 185 | # recompilation 186 | #c.NotebookApp.ignore_minified_js = False 187 | 188 | ## (bytes/sec) Maximum rate at which stream output can be sent on iopub before 189 | # they are limited. 190 | #c.NotebookApp.iopub_data_rate_limit = 1000000 191 | 192 | ## (msgs/sec) Maximum rate at which messages can be sent on iopub before they are 193 | # limited. 194 | #c.NotebookApp.iopub_msg_rate_limit = 1000 195 | 196 | ## The IP address the notebook server will listen on. 197 | c.NotebookApp.ip = '*' 198 | 199 | ## Supply extra arguments that will be passed to Jinja environment. 200 | #c.NotebookApp.jinja_environment_options = {} 201 | 202 | ## Extra variables to supply to jinja templates when rendering. 203 | #c.NotebookApp.jinja_template_vars = {} 204 | 205 | ## The kernel manager class to use. 206 | #c.NotebookApp.kernel_manager_class = 'notebook.services.kernels.kernelmanager.MappingKernelManager' 207 | 208 | ## The kernel spec manager class to use. Should be a subclass of 209 | # jupyter_client.kernelspec.KernelSpecManager. 210 | # 211 | # The Api of KernelSpecManager is provisional and might change without warning 212 | # between this version of Jupyter and the next stable one. 213 | #c.NotebookApp.kernel_spec_manager_class = 'jupyter_client.kernelspec.KernelSpecManager' 214 | 215 | ## The full path to a private key file for usage with SSL/TLS. 216 | #c.NotebookApp.keyfile = '' 217 | 218 | ## The login handler class to use. 219 | #c.NotebookApp.login_handler_class = 'notebook.auth.login.LoginHandler' 220 | 221 | ## The logout handler class to use. 222 | #c.NotebookApp.logout_handler_class = 'notebook.auth.logout.LogoutHandler' 223 | 224 | ## The MathJax.js config file that is to be used. 225 | #c.NotebookApp.mathjax_config = 'TeX-AMS-MML_HTMLorMML-full,Safe' 226 | 227 | ## A custom url for MathJax.js. Should be in the form of a case-sensitive url to 228 | # MathJax, for example: /static/components/MathJax/MathJax.js 229 | #c.NotebookApp.mathjax_url = '' 230 | 231 | ## Dict of Python modules to load as notebook server extensions.Entry values can 232 | # be used to enable and disable the loading ofthe extensions. The extensions 233 | # will be loaded in alphabetical order. 234 | #c.NotebookApp.nbserver_extensions = {} 235 | 236 | ## The directory to use for notebooks and kernels. 237 | #c.NotebookApp.notebook_dir = '' 238 | 239 | ## Whether to open in a browser after starting. The specific browser used is 240 | # platform dependent and determined by the python standard library webbrowser 241 | # module, unless it is overridden using the --browser (NotebookApp.browser) 242 | # config option. 243 | #c.NotebookApp.open_browser = True 244 | 245 | ## Hashed password to use for web authentication. 246 | # 247 | # To generate, type in a python/IPython shell: 248 | # 249 | # from notebook.auth import passwd; passwd() 250 | # 251 | # The string should be of the form type:salt:hashed-password. 252 | #c.NotebookApp.password = "" 253 | 254 | ## Forces users to use a password for the Notebook server. This is useful in a 255 | # multi user environment, for instance when everybody in the LAN can access each 256 | # other's machine through ssh. 257 | # 258 | # In such a case, server the notebook server on localhost is not secure since 259 | # any user can connect to the notebook server via ssh. 260 | #c.NotebookApp.password_required = False 261 | 262 | ## The port the notebook server will listen on. 263 | #c.NotebookApp.port = 8888 264 | 265 | ## The number of additional ports to try if the specified port is not available. 266 | #c.NotebookApp.port_retries = 50 267 | 268 | ## DISABLED: use %pylab or %matplotlib in the notebook to enable matplotlib. 269 | #c.NotebookApp.pylab = 'disabled' 270 | 271 | ## If True, display a button in the dashboard to quit (shutdown the notebook 272 | # server). 273 | #c.NotebookApp.quit_button = True 274 | 275 | ## (sec) Time window used to check the message and data rate limits. 276 | #c.NotebookApp.rate_limit_window = 3 277 | 278 | ## Reraise exceptions encountered loading server extensions? 279 | #c.NotebookApp.reraise_server_extension_failures = False 280 | 281 | ## DEPRECATED use the nbserver_extensions dict instead 282 | #c.NotebookApp.server_extensions = [] 283 | 284 | ## The session manager class to use. 285 | #c.NotebookApp.session_manager_class = 'notebook.services.sessions.sessionmanager.SessionManager' 286 | 287 | ## Shut down the server after N seconds with no kernels or terminals running and 288 | # no activity. This can be used together with culling idle kernels 289 | # (MappingKernelManager.cull_idle_timeout) to shutdown the notebook server when 290 | # it's not in use. This is not precisely timed: it may shut down up to a minute 291 | # later. 0 (the default) disables this automatic shutdown. 292 | #c.NotebookApp.shutdown_no_activity_timeout = 0 293 | 294 | ## Supply SSL options for the tornado HTTPServer. See the tornado docs for 295 | # details. 296 | #c.NotebookApp.ssl_options = {} 297 | 298 | ## Supply overrides for terminado. Currently only supports "shell_command". 299 | #c.NotebookApp.terminado_settings = {} 300 | 301 | ## Set to False to disable terminals. 302 | # 303 | # This does *not* make the notebook server more secure by itself. Anything the 304 | # user can in a terminal, they can also do in a notebook. 305 | # 306 | # Terminals may also be automatically disabled if the terminado package is not 307 | # available. 308 | #c.NotebookApp.terminals_enabled = True 309 | 310 | ## Token used for authenticating first-time connections to the server. 311 | # 312 | # When no password is enabled, the default is to generate a new, random token. 313 | # 314 | # Setting to an empty string disables authentication altogether, which is NOT 315 | # RECOMMENDED. 316 | # 317 | c.NotebookApp.token = u'' 318 | 319 | ## Supply overrides for the tornado.web.Application that the Jupyter notebook 320 | # uses. 321 | #c.NotebookApp.tornado_settings = {} 322 | 323 | ## Whether to trust or not X-Scheme/X-Forwarded-Proto and X-Real-Ip/X-Forwarded- 324 | # For headerssent by the upstream reverse proxy. Necessary if the proxy handles 325 | # SSL 326 | #c.NotebookApp.trust_xheaders = False 327 | 328 | ## DEPRECATED, use tornado_settings 329 | #c.NotebookApp.webapp_settings = {} 330 | 331 | ## Specify Where to open the notebook on startup. This is the new argument 332 | # passed to the standard library method webbrowser.open. The behaviour is not 333 | # guaranteed, but depends on browser support. Valid values are: 334 | # 335 | # - 2 opens a new tab, 336 | # - 1 opens a new window, 337 | # - 0 opens in an existing window. 338 | # 339 | # See the webbrowser.open documentation for details. 340 | #c.NotebookApp.webbrowser_open_new = 2 341 | 342 | ## Set the tornado compression options for websocket connections. 343 | # 344 | # This value will be returned from 345 | # :meth:WebSocketHandler.get_compression_options. None (default) will disable 346 | # compression. A dict (even an empty one) will enable compression. 347 | # 348 | # See the tornado docs for WebSocketHandler.get_compression_options for details. 349 | #c.NotebookApp.websocket_compression_options = None 350 | 351 | ## The base URL for websockets, if it differs from the HTTP server (hint: it 352 | # almost certainly doesn't). 353 | # 354 | # Should be in the form of an HTTP origin: ws[s]://hostname[:port] 355 | #c.NotebookApp.websocket_url = '' 356 | 357 | #------------------------------------------------------------------------------ 358 | # ConnectionFileMixin(LoggingConfigurable) config 359 | #------------------------------------------------------------------------------ 360 | 361 | ## Mixin for configurable classes that work with connection files 362 | 363 | ## JSON file in which to store connection info [default: kernel-.json] 364 | # 365 | # This file will contain the IP, ports, and authentication key needed to connect 366 | # clients to this kernel. By default, this file will be created in the security 367 | # dir of the current profile, but can be specified by absolute path. 368 | #c.ConnectionFileMixin.connection_file = '' 369 | 370 | ## set the control (ROUTER) port [default: random] 371 | #c.ConnectionFileMixin.control_port = 0 372 | 373 | ## set the heartbeat port [default: random] 374 | #c.ConnectionFileMixin.hb_port = 0 375 | 376 | ## set the iopub (PUB) port [default: random] 377 | #c.ConnectionFileMixin.iopub_port = 0 378 | 379 | ## Set the kernel's IP address [default localhost]. If the IP address is 380 | # something other than localhost, then Consoles on other machines will be able 381 | # to connect to the Kernel, so be careful! 382 | #c.ConnectionFileMixin.ip = '' 383 | 384 | ## set the shell (ROUTER) port [default: random] 385 | #c.ConnectionFileMixin.shell_port = 0 386 | 387 | ## set the stdin (ROUTER) port [default: random] 388 | #c.ConnectionFileMixin.stdin_port = 0 389 | 390 | ## 391 | #c.ConnectionFileMixin.transport = 'tcp' 392 | 393 | #------------------------------------------------------------------------------ 394 | # KernelManager(ConnectionFileMixin) config 395 | #------------------------------------------------------------------------------ 396 | 397 | ## Manages a single kernel in a subprocess on this host. 398 | # 399 | # This version starts kernels with Popen. 400 | 401 | ## Should we autorestart the kernel if it dies. 402 | #c.KernelManager.autorestart = True 403 | 404 | ## DEPRECATED: Use kernel_name instead. 405 | # 406 | # The Popen Command to launch the kernel. Override this if you have a custom 407 | # kernel. If kernel_cmd is specified in a config file, Jupyter does not 408 | # pass any arguments to the kernel, because it cannot make any assumptions about 409 | # the arguments that the kernel understands. In particular, this means that the 410 | # kernel does not receive the option --debug if it given on the Jupyter command 411 | # line. 412 | #c.KernelManager.kernel_cmd = [] 413 | 414 | ## Time to wait for a kernel to terminate before killing it, in seconds. 415 | #c.KernelManager.shutdown_wait_time = 5.0 416 | 417 | #------------------------------------------------------------------------------ 418 | # Session(Configurable) config 419 | #------------------------------------------------------------------------------ 420 | 421 | ## Object for handling serialization and sending of messages. 422 | # 423 | # The Session object handles building messages and sending them with ZMQ sockets 424 | # or ZMQStream objects. Objects can communicate with each other over the 425 | # network via Session objects, and only need to work with the dict-based IPython 426 | # message spec. The Session will handle serialization/deserialization, security, 427 | # and metadata. 428 | # 429 | # Sessions support configurable serialization via packer/unpacker traits, and 430 | # signing with HMAC digests via the key/keyfile traits. 431 | # 432 | # Parameters ---------- 433 | # 434 | # debug : bool 435 | # whether to trigger extra debugging statements 436 | # packer/unpacker : str : 'json', 'pickle' or import_string 437 | # importstrings for methods to serialize message parts. If just 438 | # 'json' or 'pickle', predefined JSON and pickle packers will be used. 439 | # Otherwise, the entire importstring must be used. 440 | # 441 | # The functions must accept at least valid JSON input, and output *bytes*. 442 | # 443 | # For example, to use msgpack: 444 | # packer = 'msgpack.packb', unpacker='msgpack.unpackb' 445 | # pack/unpack : callables 446 | # You can also set the pack/unpack callables for serialization directly. 447 | # session : bytes 448 | # the ID of this Session object. The default is to generate a new UUID. 449 | # username : unicode 450 | # username added to message headers. The default is to ask the OS. 451 | # key : bytes 452 | # The key used to initialize an HMAC signature. If unset, messages 453 | # will not be signed or checked. 454 | # keyfile : filepath 455 | # The file containing a key. If this is set, key will be initialized 456 | # to the contents of the file. 457 | 458 | ## Threshold (in bytes) beyond which an object's buffer should be extracted to 459 | # avoid pickling. 460 | #c.Session.buffer_threshold = 1024 461 | 462 | ## Whether to check PID to protect against calls after fork. 463 | # 464 | # This check can be disabled if fork-safety is handled elsewhere. 465 | #c.Session.check_pid = True 466 | 467 | ## Threshold (in bytes) beyond which a buffer should be sent without copying. 468 | #c.Session.copy_threshold = 65536 469 | 470 | ## Debug output in the Session 471 | #c.Session.debug = False 472 | 473 | ## The maximum number of digests to remember. 474 | # 475 | # The digest history will be culled when it exceeds this value. 476 | #c.Session.digest_history_size = 65536 477 | 478 | ## The maximum number of items for a container to be introspected for custom 479 | # serialization. Containers larger than this are pickled outright. 480 | #c.Session.item_threshold = 64 481 | 482 | ## execution key, for signing messages. 483 | #c.Session.key = b'' 484 | 485 | ## path to file containing execution key. 486 | #c.Session.keyfile = '' 487 | 488 | ## Metadata dictionary, which serves as the default top-level metadata dict for 489 | # each message. 490 | #c.Session.metadata = {} 491 | 492 | ## The name of the packer for serializing messages. Should be one of 'json', 493 | # 'pickle', or an import name for a custom callable serializer. 494 | #c.Session.packer = 'json' 495 | 496 | ## The UUID identifying this session. 497 | #c.Session.session = '' 498 | 499 | ## The digest scheme used to construct the message signatures. Must have the form 500 | # 'hmac-HASH'. 501 | #c.Session.signature_scheme = 'hmac-sha256' 502 | 503 | ## The name of the unpacker for unserializing messages. Only used with custom 504 | # functions for packer. 505 | #c.Session.unpacker = 'json' 506 | 507 | ## Username for the Session. Default is your system username. 508 | #c.Session.username = 'username' 509 | 510 | #------------------------------------------------------------------------------ 511 | # MultiKernelManager(LoggingConfigurable) config 512 | #------------------------------------------------------------------------------ 513 | 514 | ## A class for managing multiple kernels. 515 | 516 | ## The name of the default kernel to start 517 | #c.MultiKernelManager.default_kernel_name = 'python3' 518 | 519 | ## The kernel manager class. This is configurable to allow subclassing of the 520 | # KernelManager for customized behavior. 521 | #c.MultiKernelManager.kernel_manager_class = 'jupyter_client.ioloop.IOLoopKernelManager' 522 | 523 | #------------------------------------------------------------------------------ 524 | # MappingKernelManager(MultiKernelManager) config 525 | #------------------------------------------------------------------------------ 526 | 527 | ## A KernelManager that handles notebook mapping and HTTP error handling 528 | 529 | ## Whether messages from kernels whose frontends have disconnected should be 530 | # buffered in-memory. 531 | # 532 | # When True (default), messages are buffered and replayed on reconnect, avoiding 533 | # lost messages due to interrupted connectivity. 534 | # 535 | # Disable if long-running kernels will produce too much output while no 536 | # frontends are connected. 537 | #c.MappingKernelManager.buffer_offline_messages = True 538 | 539 | ## Whether to consider culling kernels which are busy. Only effective if 540 | # cull_idle_timeout > 0. 541 | #c.MappingKernelManager.cull_busy = False 542 | 543 | ## Whether to consider culling kernels which have one or more connections. Only 544 | # effective if cull_idle_timeout > 0. 545 | #c.MappingKernelManager.cull_connected = False 546 | 547 | ## Timeout (in seconds) after which a kernel is considered idle and ready to be 548 | # culled. Values of 0 or lower disable culling. Very short timeouts may result 549 | # in kernels being culled for users with poor network connections. 550 | #c.MappingKernelManager.cull_idle_timeout = 0 551 | 552 | ## The interval (in seconds) on which to check for idle kernels exceeding the 553 | # cull timeout value. 554 | #c.MappingKernelManager.cull_interval = 300 555 | 556 | ## 557 | #c.MappingKernelManager.root_dir = '' 558 | 559 | #------------------------------------------------------------------------------ 560 | # ContentsManager(LoggingConfigurable) config 561 | #------------------------------------------------------------------------------ 562 | 563 | ## Base class for serving files and directories. 564 | # 565 | # This serves any text or binary file, as well as directories, with special 566 | # handling for JSON notebook documents. 567 | # 568 | # Most APIs take a path argument, which is always an API-style unicode path, and 569 | # always refers to a directory. 570 | # 571 | # - unicode, not url-escaped 572 | # - '/'-separated 573 | # - leading and trailing '/' will be stripped 574 | # - if unspecified, path defaults to '', 575 | # indicating the root path. 576 | 577 | ## Allow access to hidden files 578 | #c.ContentsManager.allow_hidden = False 579 | 580 | ## 581 | #c.ContentsManager.checkpoints = None 582 | 583 | ## 584 | #c.ContentsManager.checkpoints_class = 'notebook.services.contents.checkpoints.Checkpoints' 585 | 586 | ## 587 | #c.ContentsManager.checkpoints_kwargs = {} 588 | 589 | ## handler class to use when serving raw file requests. 590 | # 591 | # Default is a fallback that talks to the ContentsManager API, which may be 592 | # inefficient, especially for large files. 593 | # 594 | # Local files-based ContentsManagers can use a StaticFileHandler subclass, which 595 | # will be much more efficient. 596 | # 597 | # Access to these files should be Authenticated. 598 | #c.ContentsManager.files_handler_class = 'notebook.files.handlers.FilesHandler' 599 | 600 | ## Extra parameters to pass to files_handler_class. 601 | # 602 | # For example, StaticFileHandlers generally expect a path argument specifying 603 | # the root directory from which to serve files. 604 | #c.ContentsManager.files_handler_params = {} 605 | 606 | ## Glob patterns to hide in file and directory listings. 607 | #c.ContentsManager.hide_globs = ['__pycache__', '*.pyc', '*.pyo', '.DS_Store', '*.so', '*.dylib', '*~'] 608 | 609 | ## Python callable or importstring thereof 610 | # 611 | # To be called on a contents model prior to save. 612 | # 613 | # This can be used to process the structure, such as removing notebook outputs 614 | # or other side effects that should not be saved. 615 | # 616 | # It will be called as (all arguments passed by keyword):: 617 | # 618 | # hook(path=path, model=model, contents_manager=self) 619 | # 620 | # - model: the model to be saved. Includes file contents. 621 | # Modifying this dict will affect the file that is stored. 622 | # - path: the API path of the save destination 623 | # - contents_manager: this ContentsManager instance 624 | #c.ContentsManager.pre_save_hook = None 625 | 626 | ## 627 | #c.ContentsManager.root_dir = '/' 628 | 629 | ## The base name used when creating untitled directories. 630 | #c.ContentsManager.untitled_directory = 'Untitled Folder' 631 | 632 | ## The base name used when creating untitled files. 633 | #c.ContentsManager.untitled_file = 'untitled' 634 | 635 | ## The base name used when creating untitled notebooks. 636 | #c.ContentsManager.untitled_notebook = 'Untitled' 637 | 638 | #------------------------------------------------------------------------------ 639 | # FileManagerMixin(Configurable) config 640 | #------------------------------------------------------------------------------ 641 | 642 | ## Mixin for ContentsAPI classes that interact with the filesystem. 643 | # 644 | # Provides facilities for reading, writing, and copying both notebooks and 645 | # generic files. 646 | # 647 | # Shared by FileContentsManager and FileCheckpoints. 648 | # 649 | # Note ---- Classes using this mixin must provide the following attributes: 650 | # 651 | # root_dir : unicode 652 | # A directory against against which API-style paths are to be resolved. 653 | # 654 | # log : logging.Logger 655 | 656 | ## By default notebooks are saved on disk on a temporary file and then if 657 | # succefully written, it replaces the old ones. This procedure, namely 658 | # 'atomic_writing', causes some bugs on file system whitout operation order 659 | # enforcement (like some networked fs). If set to False, the new notebook is 660 | # written directly on the old one which could fail (eg: full filesystem or quota 661 | # ) 662 | #c.FileManagerMixin.use_atomic_writing = True 663 | 664 | #------------------------------------------------------------------------------ 665 | # FileContentsManager(FileManagerMixin,ContentsManager) config 666 | #------------------------------------------------------------------------------ 667 | 668 | ## If True (default), deleting files will send them to the platform's 669 | # trash/recycle bin, where they can be recovered. If False, deleting files 670 | # really deletes them. 671 | #c.FileContentsManager.delete_to_trash = True 672 | 673 | ## Python callable or importstring thereof 674 | # 675 | # to be called on the path of a file just saved. 676 | # 677 | # This can be used to process the file on disk, such as converting the notebook 678 | # to a script or HTML via nbconvert. 679 | # 680 | # It will be called as (all arguments passed by keyword):: 681 | # 682 | # hook(os_path=os_path, model=model, contents_manager=instance) 683 | # 684 | # - path: the filesystem path to the file just written - model: the model 685 | # representing the file - contents_manager: this ContentsManager instance 686 | #c.FileContentsManager.post_save_hook = None 687 | 688 | ## 689 | #c.FileContentsManager.root_dir = '' 690 | 691 | ## DEPRECATED, use post_save_hook. Will be removed in Notebook 5.0 692 | #c.FileContentsManager.save_script = False 693 | 694 | 695 | #------------------------------------------------------------------------------ 696 | # NotebookNotary(LoggingConfigurable) config 697 | #------------------------------------------------------------------------------ 698 | 699 | ## A class for computing and verifying notebook signatures. 700 | 701 | ## The hashing algorithm used to sign notebooks. 702 | #c.NotebookNotary.algorithm = 'sha256' 703 | 704 | ## The sqlite file in which to store notebook signatures. By default, this will 705 | # be in your Jupyter data directory. You can set it to ':memory:' to disable 706 | # sqlite writing to the filesystem. 707 | #c.NotebookNotary.db_file = '' 708 | 709 | ## The secret key with which notebooks are signed. 710 | #c.NotebookNotary.secret = b'' 711 | 712 | ## The file where the secret key is stored. 713 | #c.NotebookNotary.secret_file = '' 714 | 715 | ## A callable returning the storage backend for notebook signatures. The default 716 | # uses an SQLite database. 717 | #c.NotebookNotary.store_factory = traitlets.Undefined 718 | 719 | #------------------------------------------------------------------------------ 720 | # KernelSpecManager(LoggingConfigurable) config 721 | #------------------------------------------------------------------------------ 722 | 723 | ## If there is no Python kernelspec registered and the IPython kernel is 724 | # available, ensure it is added to the spec list. 725 | #c.KernelSpecManager.ensure_native_kernel = True 726 | 727 | ## The kernel spec class. This is configurable to allow subclassing of the 728 | # KernelSpecManager for customized behavior. 729 | #c.KernelSpecManager.kernel_spec_class = 'jupyter_client.kernelspec.KernelSpec' 730 | 731 | ## Whitelist of allowed kernel names. 732 | # 733 | # By default, all installed kernels are allowed. 734 | #c.KernelSpecManager.whitelist = set() 735 | 736 | -------------------------------------------------------------------------------- /config/run_jupyter.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd ~ 4 | mkdir .jupyter 5 | 6 | # copy the jupyter configuration into home-directory 7 | cp -r ${CONFIG_PATH}/jupyter_notebook_config.py ~/.jupyter/ 8 | 9 | cd ${MAIN_PATH} 10 | 11 | mkdir notebooks 12 | jupyter lab -------------------------------------------------------------------------------- /config_use.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/frankzickert/jupyterlab-configuration/240375145e01a5c097116061ffa43218375ad7fd/config_use.png -------------------------------------------------------------------------------- /libs/nbimport.py: -------------------------------------------------------------------------------- 1 | 2 | import io, os, sys, types 3 | from IPython import get_ipython 4 | from nbformat import read 5 | from IPython.core.interactiveshell import InteractiveShell 6 | 7 | class NotebookLoader(object): 8 | def __init__(self, path=None): 9 | self.shell = InteractiveShell.instance() 10 | self.path = path 11 | 12 | def load_module(self, fullname): 13 | path = find_notebook(fullname, self.path) 14 | 15 | #print ("importing Jupyter notebook from %s" % path) 16 | 17 | # load the notebook object 18 | with io.open(path, 'r', encoding='utf-8') as f: 19 | nb = read(f, 4) 20 | 21 | 22 | # create the module and add it to sys.modules if name in sys.modules: 23 | # return sys.modules[name] 24 | mod = types.ModuleType(fullname) 25 | mod.__file__ = path 26 | mod.__loader__ = self 27 | mod.__dict__['get_ipython'] = get_ipython 28 | sys.modules[fullname] = mod 29 | 30 | # extra work to ensure that magics that would affect the user_ns 31 | # actually affect the notebook module's ns 32 | save_user_ns = self.shell.user_ns 33 | self.shell.user_ns = mod.__dict__ 34 | 35 | try: 36 | for cell in nb.cells: 37 | if cell.cell_type == 'code': 38 | if "importable" not in cell.metadata.keys() or cell.metadata["importable"] == "True": 39 | # transform the input to executable Python 40 | code = self.shell.input_transformer_manager.transform_cell(cell.source) 41 | # run the code in themodule 42 | exec(code, mod.__dict__) 43 | finally: 44 | self.shell.user_ns = save_user_ns 45 | return mod 46 | 47 | 48 | def find_notebook(fullname, path=None): 49 | '''find a notebook, given its fully qualified name and an optional path 50 | 51 | This turns "foo.bar" into "foo/bar.ipynb" 52 | and tries turning "Foo_Bar" into "Foo Bar" if Foo_Bar 53 | does not exist. 54 | ''' 55 | name = fullname.rsplit('.', 1)[-1] 56 | nb_path='.' 57 | if not path: 58 | path = [''] 59 | 60 | for d in path: 61 | nb_path = os.path.join(nb_path, d) 62 | 63 | for f in filter(lambda x: x.endswith(".ipynb"), os.listdir(nb_path)): 64 | if f[:f.find(".ipynb")] == name: 65 | return os.path.join(f) 66 | 67 | 68 | class NotebookFinder(object): 69 | def __init__(self): 70 | self.loaders = {} 71 | 72 | def find_module(self, fullname, path=None): 73 | nb_path = find_notebook(fullname, path) 74 | if not nb_path: 75 | return 76 | 77 | key = path 78 | if path: 79 | # lists aren't hashable 80 | key = os.path.sep.join(path) 81 | 82 | if key not in self.loaders: 83 | self.loaders[key] = NotebookLoader(path) 84 | return self.loaders[key] 85 | 86 | sys.meta_path.append(NotebookFinder()) 87 | 88 | -------------------------------------------------------------------------------- /run.sh: -------------------------------------------------------------------------------- 1 | 2 | docker build -t jpl_config -f config/jpl_config.Dockerfile . 3 | docker run -ti -v ${PWD}:/usr/local/bin/jpl_config -p 8888:8888 jpl_config --------------------------------------------------------------------------------