Coder Social home page Coder Social logo

finos / jupyterlab_templates Goto Github PK

View Code? Open in Web Editor NEW
378.0 16.0 66.0 1.9 MB

Support for jupyter notebook templates in jupyterlab

License: Apache License 2.0

Makefile 15.08% Python 50.26% JavaScript 34.31% Shell 0.35%
jupyter jupyterlab jupyterlab-extension notebook data-science machine-learning dataviz

jupyterlab_templates's Introduction

Support for jupyter notebook templates in jupyterlab

Build Status codecov PyPI PyPI npm FINOS Active Binder

Install

PyPI

jupyterlab_templates is available on PyPI:

pip install jupyterlab_templates

Conda

jupyterlab_templates is also available on conda-forge:

conda install -c conda-forge jupyterlab_templates

Jupyter Server/JupyterLab Extension

jupyter labextension install jupyterlab_templates
jupyter server extension enable --py jupyterlab_templates

Adding templates

install the server extension, and add the following to jupyter_notebook_config.py

c.JupyterLabTemplates.allowed_extensions = ["*.ipynb"]
c.JupyterLabTemplates.template_dirs = ['list', 'of', 'template', 'directories']
c.JupyterLabTemplates.include_default = True
c.JupyterLabTemplates.include_core_paths = True
c.JupyterLabTemplates.template_label = "Template"

Templates for libraries

The extension will search subdirectories of each parent directory specified in template_dirs for templates. Note! Templates in the parent directories will be ignored. You must put the templates in subdirectories, in order to keep everything organized.

If include_default = True the notebook_templates directory under the jupyter data folder is one of the default parent directories. Thus, if you have tutorials or guides you'd like to install for users, simply copy them into your jupyter data folder inside the notebook_templates directory, e.g. /usr/local/share/jupyter/notebook_templates/bqplot for bqplot.

If you want to exclude templates from a specific directory, please add a file .jupyterlab_templates_ignore to to this location. All notebooks in this directory will be ignored (but has no effect on subdirectories).

Flags

  • allowed_extensions: a list of extensions to allow templates for. (optional, default ["*.ipynb"])
  • template_dirs: a list of absolute directory paths. All files matching allowed_extensions in any subdirectories of these paths will be listed as templates
  • include_default: include the default Sample template (default True)
  • include_core_paths: include jupyter core paths (see: jupyter --paths) (default True)
  • template_label: set label for template UI icon (default "Template")

Development

See CONTRIBUTING.md for guidelines.

License

This software is licensed under the Apache 2.0 license. See the LICENSE and AUTHORS files for details.

jupyterlab_templates's People

Contributors

ajyeager avatar constantiux avatar dependabot[bot] avatar forest-d avatar fpbattaglia avatar jpetrucciani avatar krassowski avatar maoo avatar martinlarsalbert avatar peterjclaw avatar randolf-scholz avatar samueldy avatar thejuanandonly99 avatar timkpaine avatar toslunar avatar vidartf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jupyterlab_templates's Issues

Trouble Installing

Hi, I do not know what I am doing wrong with the extension and was wondering if you could help me out.

I was able to execute the pip command no problem. I then executed the second direction for installation and got:

$ jupyter labextension install jupyterlab_templates --debug 
Searching ['/mnt/rrio1/home/tabedzki/anaconda3/lib/python3.6/site-packages/jupyterlab_templates/templates', '/mnt/rrio1/home/tabedzki/.jupyter', '/home/tabedzki/anaconda3/etc/jupyter', '/usr/local/etc/jupyter', '/etc/jupyter'] for config files
Looking for jupyter_config in /etc/jupyter
Looking for jupyter_config in /usr/local/etc/jupyter
Looking for jupyter_config in /home/tabedzki/anaconda3/etc/jupyter
Looking for jupyter_config in /mnt/rrio1/home/tabedzki/.jupyter
Looking for jupyter_config in /mnt/rrio1/home/tabedzki/anaconda3/lib/python3.6/site-packages/jupyterlab_templates/templates
> /home/tabedzki/anaconda3/bin/npm pack jupyterlab_templates
jupyterlab_templates-0.1.12.tgz
Fetching URL: https://registry.npmjs.org/jupyterlab_templates
> /home/tabedzki/anaconda3/bin/npm pack [email protected]
jupyterlab_templates-0.1.7.tgz
Incompatible extension:

"[email protected]" is not compatible with the current JupyterLab
Conflicting Dependencies:
JupyterLab              Extension        Package
>=0.16.3 <0.17.0        >=0.18.0 <0.19.0 @jupyterlab/application
>=0.16.4 <0.17.0        >=0.18.0 <0.19.0 @jupyterlab/apputils
>=1.1.3 <2.0.0          >=2.1.0 <3.0.0   @jupyterlab/coreutils
>=0.16.3 <0.17.0        >=0.18.0 <0.19.0 @jupyterlab/docmanager
>=0.16.3 <0.17.0        >=0.18.0 <0.19.0 @jupyterlab/filebrowser
>=0.16.3 <0.17.0        >=0.18.0 <0.19.0 @jupyterlab/launcher

Found compatible version: 0.1.7
> /home/tabedzki/anaconda3/bin/npm pack [email protected]
jupyterlab_templates-0.1.7.tgz
> node /home/tabedzki/anaconda3/lib/python3.6/site-packages/jupyterlab/staging/yarn.js install
yarn install v1.5.1
info No lockfile found.
[1/4] Resolving packages...
warning css-loader > cssnano > postcss-merge-rules > [email protected]: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
warning css-loader > cssnano > autoprefixer > [email protected]: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
warning css-loader > cssnano > postcss-merge-rules > caniuse-api > [email protected]: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
[2/4] Fetching packages...
info [email protected]: The platform "linux" is incompatible with this module.
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
warning "@jupyterlab/json-extension > [email protected]" has incorrect peer dependency "react@^15.0.0".
warning "@jupyterlab/json-extension > [email protected]" has incorrect peer dependency "react-dom@^15.0.0".
warning "@jupyterlab/vdom-extension > @nteract/[email protected]" has incorrect peer dependency "react@^15.6.1".
[4/4] Building fresh packages...
success Saved lockfile.
Done in 111.68s.
> node /home/tabedzki/anaconda3/lib/python3.6/site-packages/jupyterlab/staging/yarn.js run build:prod
yarn run v1.5.1
$ webpack --config webpack.prod.config.js
Hash: 76317631f8acb4d5a0d3
Version: webpack 2.7.0
Time: 60927ms
                                 Asset     Size  Chunks                    Chunk Names
        vendor.4a90d3e960f7c6572d11.js  1.57 MB       2  [emitted]  [big]  vendor
  912ec66d7572ff821749319396470bde.svg   444 kB          [emitted]  [big]  
  674f50d287a8c48dc19ba404d20fe713.eot   166 kB          [emitted]         
 fee66e712a8a08eef5805a46892932ad.woff    98 kB          [emitted]         
af7ae505a9eed503f8b8e6982036873e.woff2  77.2 kB          [emitted]         
             0.279ec850a9242db04c85.js   465 kB       0  [emitted]  [big]  
          main.cb03828baf9db6daf6f8.js  2.29 MB       1  [emitted]  [big]  main
  b06871f281fee6b241d60582ae9369b9.ttf   166 kB          [emitted]         
      manifest.ffebe130e2f5608aba53.js  1.62 kB       3  [emitted]         manifest
         0.279ec850a9242db04c85.js.map  1.35 MB       0  [emitted]         
      main.cb03828baf9db6daf6f8.js.map  7.78 MB       1  [emitted]         main
    vendor.4a90d3e960f7c6572d11.js.map  5.69 MB       2  [emitted]         vendor
  manifest.ffebe130e2f5608aba53.js.map  8.24 kB       3  [emitted]         manifest
                            index.html  1.53 kB          [emitted]         
[/sZe] ./~/@phosphor/commands/lib/index.js 33.3 kB {2} [built]
[2Kj9] ./~/@phosphor/widgets/lib/index.js 1.38 kB {2} [built]
[GiK3] ./~/react/index.js 190 bytes {2} [built]
[Js9g] ./build/index.out.js 34.6 kB {1} [built]
[O27J] ./~/react-dom/index.js 1.36 kB {2} [built]
[cYMN] ./~/@phosphor/virtualdom/lib/index.js 21 kB {2} [built]
[dyOy] ./~/url-parse/index.js 11.4 kB {2} [built]
[hKoQ] ./~/es6-promise/dist/es6-promise.js 28.6 kB {2} [built]
[kzCB] ./~/path-posix/index.js 6.94 kB {2} [built]
[ug+F] ./~/xterm/lib/xterm.js 52.7 kB {2} [built]
[wr2+] ./~/@phosphor/properties/lib/index.js 6.58 kB {2} [built]
[wuIn] ./~/comment-json/index.js 103 bytes {2} [built]
   [8] multi @phosphor/algorithm @phosphor/application @phosphor/commands @phosphor/coreutils @phosphor/datagrid @phosphor/disposable @phosphor/domutils @phosphor/dragdrop @phosphor/messaging @phosphor/properties @phosphor/signaling @phosphor/virtualdom @phosphor/widgets ajv ansi_up codemirror comment-json es6-promise marked moment path-posix react react-dom sanitize-html url-parse xterm 328 bytes {2} [built]
[y7VK] ./~/@phosphor/algorithm/lib/index.js 1.03 kB {2} [built]
   [9] multi whatwg-fetch ./build/index.out.js 40 bytes {1} [built]
    + 2226 hidden modules
Child html-webpack-plugin for "index.html":
    [3IRH] (webpack)/buildin/module.js 517 bytes {0} [built]
    [DuR2] (webpack)/buildin/global.js 509 bytes {0} [built]
    [GTAU] ./~/html-loader!./templates/partial.html 420 bytes {0} [built]
    [M4fF] ./~/lodash/lodash.js 540 kB {0} [built]
    [vxCX] ./~/html-webpack-plugin/lib/loader.js!./templates/template.html 1.41 kB {0} [built]
Done in 66.25s.

After I ran that I got the following output

$ jupyter serverextension enable --py jupyterlab_templates
Enabling: jupyterlab_templates.extension
- Writing config: /mnt/rrio1/home/tabedzki/.jupyter
    - Validating...
Error loading server extension jupyterlab_templates.extension
      X is jupyterlab_templates.extension importable?

Do you know what could be done to fix this?

Launcher Error: templates_1 is undefined

Get this error after installing the extension on a Azure remote (Ubuntu 16.04) JupyterLab server.
Jupyter version 4.4.0, Lab version 0.35.3.
I've included the default template flag as well as a template directory where I put a sample file.
I get this error only when trying to open a template from the launcher.
If I click File -> New -> From Template, nothing happens at all.

ujson dependency

ujson is not installed as a dependency which breaks the extension without any indication of why. It wasn't until I tried:

import jupyterlab_templates.extension

did I find the problem.

Is there any reason to use ujson over the standard library's json? I don't think that the tiny performance improvement is worth the extra dependency. I just monkey packed it to use json, and everything works fine.

I found some performance comparisons here. A 33% improvement in dump times (or 7ms over 10,000 dictionaries) isn't worth it IMHO.

License file in pypi archive

The pypi source archive isn't including the LICENSE file. Would it be possible to add it? It is very helpful when packaging this for Linux distributions. Thank you.

Templates not loading jupyterhub

So in my setup we run jupyterhub on kubernetes with custom docker images.

Before we had the GitHub repos embedded onto the docker image and templates would fine. Since then we moved the templates to a read only volume mount and adjusted the path on template_dirs.

The extension picks up the path but it says no notebooks available besides example one

Screen Shot 2019-11-05 at 3 54 56 PM

As you can see the search path is the first one in modelbuilding/templates.

Anyone know why might that be?

Cannot read property 'length' of undefined

I'm trying to use jupyterlab_templates using jupyterlab_hub. I installed it both from pip as well as the local install. The icon appears in the launcher, but whenever I click the 'From Templates' button I get the length error. It works great when using just jupyter lab, but I'd like to get it working in jupyter hub with lab

Does this work in dev-mode ?

It seems the extension is not enabled if I run jupyter lab --dev-mode. Any instructions for configuration would be appreciated.

My JupyterLab version is 0.34.0.

Incomplete installation?

  1. I have successfully run the commands listed in the Install section of the readme file in my active environment, but I do not have a jupyter_notebook_config.py file:
    Is this an error or does it have to be created, and if so where?

What I have is the jupyter_notebook_config.json:

{
  "NotebookApp": {
    "nbserver_extensions": {
      "jupyter_nbextensions_configurator": true,
      "jupyterlab_templates.extension": true
    }
  }
}
  1. I launched jupyter lab at the command line and the File | New menu does not list the new option From template.

Here is the logged information following the launch:

(dsml) C:\Users\me\Documents\folder>jupyter lab
[x] [jupyter_nbextensions_configurator] enabled 0.4.1
[x] JupyterLab extension loaded from C:\Users\me\Anaconda3\envs\dsml\lib\site-packages\jupyterlab
[x] JupyterLab application directory is C:\Users\me\Anaconda3\envs\dsml\share\jupyter\lab
Installing jupyterlab_templates handler on path /templates
Search paths:
        C:\Users\me\Anaconda3\envs\dsml\lib\site-packages\jupyterlab_templates\templates
        C:\Users\me\AppData\Roaming\jupyter\notebook_templates
        C:\Users\me\Anaconda3\envs\dsml\share\jupyter\notebook_templates
        C:\ProgramData\jupyter\notebook_templates
Available templates:
        \jupyterlab_templates\Sample.ipynb
[...]

Note: the full path to the Sample.ipynb referenced in the log is:

C:\Users\me\Anaconda3\envs\dsml\Lib\site-packages\jupyterlab_templates\templates\jupyterlab_templates\Sample.ipynb

Platform: jupyterlab: 1.0.4 python: 3.6.7 [MSC v.1900 64 bit (AMD64)]

Is there a fix on my side? Thanks for your help.

Standard location for templates

It would be really cool if jupyter_lab_templates always listed files in e.g.

PREFIX/share/jupyter/notebook_templates/

Then a package like bqplot or ipyvolume could install all of their example notebooks as data files into

PREFIX/share/jupyter/notebook_templates/bqplot PREFIX/share/jupyter/notebook_templates/ipyvolume

respectively. These would be automatically picked up by jupyterlab_templates.

At the moment, there is not simple means for packages to include examples in such a way that it cannot be modified by accident...

Template bundles/folders in Launcher window

Hi,
It would be great if we could specify template folders in (Jupyterlab) Launcher window, like this:

image

Config could look like this:

c.JupyterLabTemplates.launcher = [
  {
    "name": "all_templates", # internal name for this object entry
    "folder_paths": ['/usr/local/jupyter/templates', '/etc/jupyter/templates', '/home/$NB_USER/jupyter/templates'],  # locations for .ipynb templates
    "recursive_folders": "true", # include subfolders?
    "file_filters": ["*.ipynb"], # further filter files in the template folders
    "label": "All Templates", # label to display in the Jupyterlab Viewer page
    "icon": "/etc/icons/all_templates.png" #file path or base64 encoded string
  },
  {
    "name": "user_templates",
    "folder_paths": ['/home/$NB_USER/jupyter/templates'], # specific single folder
    "recursive_folders": "true",
    "file_filters": ["*.ipynb"],
    "label": "My Templates",
    "icon": "/etc/icons/user.jpeg"
  },
  {
    "name": "machine_learning",
    "folder_paths": ['/etc/jupyter/templates/machine_learning'],
    "recursive_folders": "true",
    "file_filters": ["*ml*.ipynb"], # file name filter for only entries that have 'ml'
    "label": "Machine Learning",
    "icon": "/etc/icons/ml.svg"
  }
]

A step further would be to pull sub folders from user template folder ['/home/$NB_USER/jupyter/templates'] and output them as separate folders in the Launcher page, like:

 ['/home/$NB_USER/jupyter/templates/my_reports']
 ['/home/$NB_USER/jupyter/templates/project_x']
 ['/home/$NB_USER/jupyter/templates'/twitter_scrapping]

if folder contained a icon.png file, it would be displayed as that folder's icon.


If it's too much work for now, for now can I ask for a config entry to customize the [Template] icon? The current default one isn't too appealing (to me), and I think people would benefit from being able to choose their own, especially if the templates they made are of specific theme/topic

something like this:
c.JupyterLabTemplates.icon = ['/etc/icons/report_templates.svg']
image
I know I can dig into CSS files and change it there, but I think doing so programmatically in config would be more logical way.

Thanks in advance!

Add support for multi-file templates

Hi @timkpaine, thanks for your work on this super useful extension.

I am currently working on a Notebook which uses multiple data files (that I can't get using any API), and some Python modules I have written to keep the workflow more user-friendly (while not polluting the notebook with stuff that could confuse the users).

I'd love to be able to include all of these files in a template (It only has a single ipynb file).

I think a great way to do this would be to support the following extensions too: {"tar", "tar.gz", "zip"}. Essentially, we could put those files alongside the ipynb templates, and if they are selected, extract them instead of simply copying them.

I'd be happy to contribute this in a PR if that sounds like something you'd welcome.

Folder name options

  • notebooks
  • notebook_templates (current)
  • templates (likely to conflict with nbconvert/voila)
  • tutorials (seems like a subset, not a superset)

icon or image broken on the launcher

Hello

the icon or picture seems to be broken on the launcher panel. This is what I get if I use the view image option of FireFox web browser:

XML Parsing Error: no root element found
Location: data:image/svg+xml;utf8,<svg%20xmlns="http://www.w3.org/2000/svg"%20viewBox="0%200%20203%20226"><style>.cls-1{fill:#ff780a;}.cls-2,.cls-3{fill:#fff;}.cls-3{font-size:6px;font-family:MyriadPro-Regular,%20Myriad%20Pro;letter-spacing:0.01em;}.cls-4{letter-spacing:0em;}.cls-5{fill:#3fa9f5;}.cls-6{fill:#7ac943;}.cls-7{fill:#ff931e;}.cls-8{fill:#ff7bac;}.cls-10,.cls-9{fill:none;stroke-miterlimit:10;}.cls-9{stroke:#ff1d25;}.cls-10{stroke:#000;stroke-width:2px;}.cls-11{font-size:26px;font-family:HelveticaNeue-Italic,%20Helvetica%20Neue;font-style:italic;}.cls-12{letter-spacing:-0.09em;}</style><title>Asset%203</title><g%20id="Layer_2"%20data-name="Layer%202"><g%20id="Layer_1-2"%20data-name="Layer%201"><rect%20class="cls-1"%20x="0.5"%20y="0.5"%20width="202"%20height="225"/><path%20d="M202,1V225H1V1H202m1-1H0V226H203V0Z"/><rect%20class="cls-2"%20x="32.5"%20y="15.5"%20width="137"%20height="32"/><path%20d="M169,16V47H33V16H169m1-1H32V48H170V15Z"/><text%20class="cls-3"%20transform="translate(11.33%2023.33)">I<tspan%20class="cls-4"%20x="1.49"%20y="0">n%20[1]:<text%20class="cls-3"%20transform="translate(11.33%2065.33)">I<tspan%20class="cls-4"%20x="1.49"%20y="0">n%20[2]:<rect%20class="cls-2"%20x="19.5"%20y="104"%20width="160"%20height="103.48"/><path%20d="M179,104.5V207H20V104.5H179m1-1H19V208H180V103.5Z"/><rect%20class="cls-5"%20x="38.7"%20y="179.72"%20width="13.7"%20height="22.27"/><rect%20class="cls-6"%20x="74.66"%20y="150.6"%20width="13.7"%20height="51.38"/><rect%20class="cls-7"%20x="110.63"%20y="159.16"%20width="13.7"%20height="42.82"/><rect%20class="cls-8"%20x="146.6"%20y="136.9"%20width="13.7"%20height="65.09"/><line%20class="cls-9"%20x1="45.55"%20y1="169.44"%20x2="81.52"%20y2="119.77"/><line%20class="cls-9"%20x1="117.48"%20y1="140.32"%20x2="81.52"%20y2="119.77"/><line%20class="cls-9"%20x1="153.45"%20y1="109.49"%20x2="117.48"%20y2="140.32"/><rect%20class="cls-2"%20x="32.5"%20y="58.5"%20width="137"%20height="36"/><path%20d="M169,59V94H33V59H169m1-1H32V95H170V58Z"/><line%20class="cls-10"%20x1="40.5"%20y1="62.55"%20x2="71"%20y2="62.55"/><line%20class="cls-10"%20x1="41"%20y1="68.31"%20x2="90"%20y2="68.31"/><line%20class="cls-10"%20x1="41"%20y1="74.38"%20x2="152"%20y2="74.38"/><line%20class="cls-10"%20x1="41"%20y1="80.44"%20x2="152"%20y2="80.44"/><line%20class="cls-10"%20x1="41"%20y1="86.51"%20x2="90"%20y2="86.51"/><text%20class="cls-11"%20transform="translate(34.75%2041)">TEMPL<tspan%20class="cls-12"%20x="84.73"%20y="0">A<tspan%20x="99.68"%20y="0">TE
Line Number 1, Column 88:<style>.cls-1{fill:
---------------------------------------------------------------------------------------^

let me know how I could fix it or even better if you could publish an update for this nice JLAB extension.

Thank you in advance.

JM

Beter explanation about how set paths to get templates.

Hi! I has some troubles trying set the path to get the inside notebooks as templates because is not clear the needed to be in sub dirs and without checkpoints (.ipynb_checkpoints). Could you note that in Readme.m? Many thanks!

Missing template names in select box (firefox only)

Hi,

I installed and played around with jupyterlab_templates (version 0.0.3 via pip) and came across the following issue:

On Firefox, the template names are not displayed in the selection box.
It seems that there's a firefox issue, that prevents labels from being shown if the option element's content is empty.
(https://bugzilla.mozilla.org/show_bug.cgi?id=40545)

I fixed it locally by copying the label into the option's content.
(It's a one-liner. Would you like me to create a PR?)

cheers,
Ansgar

Serverextension enable error

Hi,
Latest npm and jupyterlab.

On the third step of installation, I get the following error in the terminal:

(py36) λ jupyter serverextension enable --py jupyterlab_templates
Enabling: jupyterlab_templates.extension
- Writing config: C:\Users\thomasaar\.jupyter
    - Validating...
Error loading server extension jupyterlab_templates.extension
      X is jupyterlab_templates.extension importable?

The Template icon appears in jupyter lab, but clicking it, I get a popup error:

Cannot read property 'length' of undefined

Any suggestions?

Total Control of the Template Dirs

Hi,

Thanks for the great extension! Would it be possible to add the ability to completely control the template lookup dirs? Even when I set c.JupyterLabTemplates.template_dirs, it adds the core paths. Ideally, I could opt out of that.

Thanks!

Extension doesn't seem to start up

Hello, I have tried to install the extension both from the browser interface and from the command line as explained in the README in this repo, but I can't seem to get the menu item for "New from template".

In the jupyter lab startup logo I get this suspicious warning
[W 14:32:25.409 LabApp] 404 GET /templates/names (::1) 78.35ms referer=http://localhost:8888/lab

I am working from a fresh conda environment, installed node.js from conda-forge, under MacOS Catalina

Thanks

Question about jupyter_notebook_config.py

I am psyched to try out the Jupterlab templates!
I had one question—when you say

"""
...and add the following to jupyter_notebook_config.py

c.JupyterLabTemplates.template_dirs = ['list', 'of', 'template', 'directories']
"""

Do I need to create a jupiter_notebook_config.py file myself? If I look in my home
directory, I see a .jupyter folder, but not existing jupiter_notebook_config.py file anywhere on my system.

I’m guessing that I should just create the file and add a line like

c.JupyterLabTemplates.template_dirs = [‘~.jupyter/templates/‘]

Is that the case?

Ignore checkpoint directory

Is it possible to ignore .ipynb-checkpoint directories when specifying a template path?

Currently, it doesn't seem as if there's an elegant process for editing template files from inside Jupyterlab. If a notebook template file is edited from within Jupyter, a checkpoint file is automatically created and these clutter the template menu.

One workaround is to change the checkpoint directory ([https://github.com/jupyterlab/jupyterlab/issues/5809]), but this has its own challenges - like having two notebooks with the same name in any directory.

No icon on launcher or template under file after upgrade to Jupyter Lab 1.0.1

I had the extension working on Jupyter Lab 0.35.6, and pointing to two templates on a defined location. After updating to Jupyter Lab 1.1.1, updating all extension and building, I don't have an icon for templates in the Launcher and I can't also find an option under "File".

image

Under 0.35.6 I could use the templates via the launcher ( I never tried using "File"). In the anaconda launcher, I get a message that:
Installing jupyterlab_templates handler on path /templates
Available templates: T1.ipynb,T2.ipynb

I can access the location of the templates in Jupyter Lab.

The extension shows under my extension list, and I did try enabling/disabling:
image

Reload templates periodically

Thanks a lot for this extension! It removes a lot of friction for my JupyterHub users to get started.

This is what my setup looks like: I provide a JupyterLab environment to a lot of user through JupyterHub. I also of repo of template notebooks that I regularly deploy to the JupyterHub server and I have installed the templates extension to load templates from that folder.

Now, whenever I push an update to the templates folder, users need to restart their server to pick up the updates. This is because we only load templates once when the server extension get loaded.

It would be great if these templates could be reloaded periodically instead. I'm imagining something like having a dedicated class to serve templates. That class would have a function to load the templates from disk and that function would be cached with a TTL. Each call to TemplatesHandler or TemplateNamesHandler would get templates from that cached function.

Say something like

import cachetools.func

class TemplatesLoader():
    def __init__(self, template_dirs=None):
        self. template_dirs = template_dirs

    @cachetools.func.ttl_cache(maxsize=1, ttl=60)
    def get_templates(self):
        # load templates from disk
        return templates

class TemplateNamesHandler(IPythonHandler):
    def initialize(self, templates_loader):
        self.templates_loader = templates_loader

    def get(self, template=None):
        self.finish(json.dumps(sorted(self.templates_loader.get_templates().keys())))

Let me know if that makes sense and I can push a PR 👍

Installation via PyPi (pip) is outdated

The set of features described in the readme, (notably the disabling of the default template via the c.JupyterLabTemplates.include_default = True setting) are not available if one follows the the installation advice and uses pip.
pip install jupyterlab_templates
The current PyPi version is outdated and doesn't match the current state of the repository. I believe a new release is needed.

Very useful extension btw!

Getting error "Cannot read property 'length' of undefined"

I am getting a Cannot read property 'length' of undefined error when trying to launch templates. I am running Jupyter lab locally. On launch I get the following:

[I 14:19:59.177 LabApp] JupyterLab extension loaded from /usr/local/anaconda3/lib/python3.7/site-packages/jupyterlab
[I 14:19:59.177 LabApp] JupyterLab application directory is /usr/local/anaconda3/share/jupyter/lab
Installing jupyterlab_templates handler on path /templates
Search paths:
	/Users/9te/.startup/jupyter/templates
	/usr/local/anaconda3/lib/python3.7/site-packages/jupyterlab_templates/templates
	/Users/9te/Library/Jupyter/notebook_templates
	/usr/local/anaconda3/share/jupyter/notebook_templates
	/usr/local/share/jupyter/notebook_templates
	/usr/share/jupyter/notebook_templates
Available templates:
	basic.ipynb
	geometry.ipynb
	analysis.ipynb
	/jupyterlab_templates/Sample.ipynb
[I 14:19:59.180 LabApp] Serving notebooks from local directory: /data/notebook
[I 14:19:59.180 LabApp] The Jupyter Notebook is running at:
[I 14:19:59.180 LabApp] http://localhost:8888/?token=1b0c42b4e3f631deb082f6d47c45e9a0befb803251fd4e93
[I 14:19:59.180 LabApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 14:19:59.192 LabApp]

    To access the notebook, open this file in a browser:
        file:///Users/9te/Library/Jupyter/runtime/nbserver-364-open.html
    Or copy and paste one of these URLs:
        http://localhost:8888/?token=1b0c42b4e3f631deb082f6d47c45e9a0befb803251fd4e93
[I 14:20:01.885 LabApp] Node v12.9.0

[W 14:20:02.126 LabApp] 404 GET /templates/get (::1) 269.53ms referer=http://localhost:8888/lab
[I 14:20:02.128 LabApp] Build is up to date

So it appears that the server extension is enabled (as opposed to the issue in #6). Any ideas? The Jupyter versions are:

jupyter                   1.0.0                    py37_7
jupyter_client            5.2.4                    py37_0
jupyter_console           6.0.0                    py37_0
jupyter_core              4.4.0                    py37_0
jupyterlab                0.35.4           py37hf63ae98_0
jupyterlab-templates      0.2.0                    pypi_0    pypi
jupyterlab_server         0.2.0                    py37_0

install issue?

what might cause "jupyterlab_templates" is not a valid npm package" error when installing the extension (ie jupyter labextension install jupyterlab_templates(

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.