Skip to content

edina/nb_empty_trash

Repository files navigation

Empty Trash

Empty Trash extension for jupyter notebook.

It was created because there's a conflict around deleting directories and quota'd home-directories:

  1. Non-empty directories cannot be deleted - you have to delete every file & folder within the directory to be able to delete the folder you want to.

  2. non-empty directories can be deleted by setting c.FileContentsManager.delete_to_trash = True however this actually means the files are moved into a hidden folder.

  3. This hidden folder cannot be accessed via the UI (you need to

    • Open a terminal, and
    • Know where to look

    to delete the files)

  4. The hidden folder is in the users home directory, so counts towards their quota - but they have no [obvious] way to get rid of it.

It is a small extension for Jupyter Notebooks running in a docker notebook, and provides two functions

  1. It displays current disk usage, in line with nbresuse, and
  2. It allows the user to delete trash

Both buttons are displayed in the dashboard [or tree] page, refreshing every 5s.

Screenshot of Empty Trash & Disk usage buttons

Reminder: This version is specific from notebooks running in docker containers.

Installation

You currently install this package by cloning from GitHub. In your dockerfile, add:

USER root
RUN pip install git+git://github.com/edina/nb_empty_trash.git#egg=nb_empty_trash
RUN jupyter nbextension install --sys-prefix --py empty_trash \
    && jupyter nbextension enable empty_trash --py --sys-prefix \
    && jupyter serverextension enable --py empty_trash --sys-prefix

USER $NB_USER

(see CONTRIBUTING.md for running locally)

Configuration

Disk Usage

Empty Trash displays current Disk usage, reporting current & maximum values - and directly copies what nbresuse does (down to using the same configuration variables).

The disk_maximum is defined as the total byte size for the disk partition the directory is on, and that directory defaults to /home/joyan, but can be defined using the evironment variable DISK_DIR or the config variable disk_dir

An artificial limit can be set, using either the DISK_LIMIT environment variable or the config element disk_limit. This limit needs to be set as an integer in Bytes.

If disk_limit is unset, it reports disk_maximum

Trash Size

The Empty Trash tooltip displays the sum-total of file-sizes in the trash folder.

The directory defaults to $HOME/.local/share/Trash/, but can be defined using the evironment variable TRASH_DIR or the config variable trash_dir

Contributing

If you would like to contribute to the project, please read CONTRIBUTING.md. The CONTRIBUTING.md file explains how to set up a development installation and how to run the test suite.