Skip to main content

datasette powered notebook search

Project description

nbsearch

Datasette based notebook search extension, originally inspired by Simon Willison's Fast Autocomplete Search for Your Website.

Binder

Related: Sketching a datasette powered Jupyter Notebook Search Engine: nbsearch

Installation

pip3 install --upgrade git+https://github.com/ouseful-testing/nbsearch.git

Usage - inside Jupyter notebook environment

This is still very much a work in progress. I think it works in Binder (erm, maybe...)

Installing the extension and restarting the Jupyter server should make a Jupyter proxy served version of the search form available from the New menu.

At the moment, I think you need to create the index explicitly. From the command line:

nbsearch index -p PATH

(From a notebook command cell, prefix with !. Default path is .).

The sqlite db that stores the results is in ~/.nbsearch/notebooks.sqlite.

All notebooks down from PATH will be indexed.

When you have generated an index, launch the nbsearch panel from the notebook homepage New menu.

Usage - from the command line

  • create a database by passing a path to some notebook files, eg:
    • nbsearch index -p "/Users/myuser/Documents/content/notebooks"
  • run the server, eg:
    • nbsearch serve

datasette should start up and display a server port number. (To kill it, I look for process IDs: ps -al |grep datasette; there is probably a better way... It might be nice if CLI kept track of process IDs and let you kill from a selection?)

UI

Old screenshot

A copy button on a code cell lets you copy code from the code cell.

Results are limited in length; the Show all cell button expands the result cell to its full length. The Show previous cell and Show next cell buttons display the full previous / next cell (repeatedly clicking these buttons grab the next next and previous previous cells etc.)

Clicking on the notebook structure visualisation graphic (the pink/blue image: the colours representent cell type and relative length) will collapse / reveal the display of the result block.

Known Issues

The links to notebooks may well be broken in the search results: I need to think about how to index and handle paths in links, particular in proxy server case.

The app requires the latest version of datasette from the repo, not pypi.

The index is not updated ever unless you rerun the indexer, although I've started trying to ponder a filesystem watchdog here. Another possibility my be a Jupyter notebook content manager or post-save hook to update records as the notebook server saves them but this would not catch filesystem operations (dragging new notebooks to a folder, deleting notebooks etc?)

If the sqlite db is updated, I assume by some magic that the datasette server queries over the updated content?

Useful

Quick way to kill datasette processes: ps aux | grep datasette | grep -v grep | awk '{print $2}' | xargs kill

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nbsearch-0.0.3.tar.gz (8.9 kB view details)

Uploaded Source

Built Distribution

nbsearch-0.0.3-py3-none-any.whl (42.6 kB view details)

Uploaded Python 3

File details

Details for the file nbsearch-0.0.3.tar.gz.

File metadata

  • Download URL: nbsearch-0.0.3.tar.gz
  • Upload date:
  • Size: 8.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.6

File hashes

Hashes for nbsearch-0.0.3.tar.gz
Algorithm Hash digest
SHA256 0dfb0392cedf31e8b414ed62c931cf6fc25cec86bb533e437d5af31d49831fa1
MD5 e5a935c84cd369f86ec36546a101d831
BLAKE2b-256 7f94fa028f7c5455c5e642a6aa94b269d4021e19ad6bb6cf9cb6f28680622ee2

See more details on using hashes here.

File details

Details for the file nbsearch-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: nbsearch-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 42.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.6

File hashes

Hashes for nbsearch-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 5382e15f0789f86d46fca94add0f2a4e9c42322cfd7eb26e3580e7998d3c01d6
MD5 20acade32235cf979e3a4f589940a3b3
BLAKE2b-256 f9cf146f8fd0e96af20678417bd01f8df1928c4d16b33f34b7dd373711817eb0

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page