ContentManager using Seafile's WebAPI
Project description
SeafileContentManager
A custom ContentManger for Jupyter Notebooks based on Seafiles WebAPI following the notes on Custom ContentManagers.
The ContentManger works for both Jupyter Notebook and Lab. Checkpoints for files, folders and notebooks are are based on the Seafile Commit History. Thus, checkpoints are available for a predefined period of time ('retention period', e.g. 30 days, can also be infinite, see here).
Since for Python IO operations (e.g. open('file.txt','r') as file
) the underlying file system is used, there is an additional
drop-in replacement for those operations
from SeafileContentManager import SeafileFS
fs = SeafileFS()
file = fs.open('/text.txt','r')
file.read()
Ideally, notebooks should be written with this replacement from the start.
Status
Currently under active development.
What works?
- In JupyterLab or Notebook GUI:
- Folder view
- Opening and saving notebooks
- Opening and saving text files (.txt,.md)
- Creating new folder, file or notebook
- Download
- Duplicate
- Renaming
- Moving files
- Using the SeafileFS drop-in replacement for io operations:
- Opening files in all modes (r,a,w,x, or adding b, +)
- Reading
- Writing (not yet a+, a+b modes)
- listdir
- listdir_attrib (with file size, creation date, etc.)
- mkdir
What does not work?
- Drag and Drop Upload in JupyterLab
- Files end up b64 encoded on the Seafile FS
- Relative paths in the SeafileFS
- All paths are taken from the root, i.e. the at startup selected SeaFile library
Testing
To test the content manager, clone the repository, create a new virtual environment
virtualenv -p python3 env
in the cloned directory, activate it
source env/bin/activate
and install the development version
pip install -U .
Export the following environment variables
- SEAFILE_URL: The url to access your SeaFile instance
- SEAFILE_ACCESS_TOKEN: Your access token
- SEAFILE_LIBRARY: The name of the library, where all
e.g. by having a file env
in your testing folder (don't forget to add it to gitignore!)
with the following content
#!/bin/bash
export SEAFILE_URL=https://my.seafile.instance
export SEAFILE_LIBRARY=notebooks
export SEAFILE_ACCESS_TOKEN=12341234124124
and then sourcing the file (source testing/env
) before running the command below.
Jupyter Notebook
To start Jupyter notebook from the activated environment run
jupyter notebook \
--NotebookApp.contents_manager_class=SeafileContentManager.SeafileContentManager \
--ContentsManager.checkpoints_class=SeafileContentManager.SeafileCheckpoints \
--debug
This should start Jupyter notebooks with the Seafile API contents and checkpoints manager.
JupyterLab
To use the ContentManger with Jupyter Lab, create a settings file with the following content
from SeafileContentManager import SeafileContentManager, SeafileCheckpoints
c = get_config()
c.NotebookApp.contents_manager_class = SeafileContentManager
c.ContentsManager.checkpoints_class = SeafileCheckpoints
and run
jupyter-lab --config /path/to/config/jupyter_notebook_config.py --debug
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file SeafileContentManager-0.1.2.tar.gz
.
File metadata
- Download URL: SeafileContentManager-0.1.2.tar.gz
- Upload date:
- Size: 16.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 969b337030d7c1f9f4f67bcd843f1b9ecb60b3c26a2b63cd857213f4d5724e14 |
|
MD5 | eb9f930b69ef8abe33aa3ce9d7fe3ef5 |
|
BLAKE2b-256 | c6e0aea8bc29b3b31ecccccddcf69025999cbab572e8fd716dbdcd525ccafde5 |
File details
Details for the file SeafileContentManager-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: SeafileContentManager-0.1.2-py3-none-any.whl
- Upload date:
- Size: 29.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cb566c87c9dce973467ca0e117b1f1cae33195af699930908c5475ca61029c77 |
|
MD5 | 7eb5ff1e64457775a02df2db5acd542d |
|
BLAKE2b-256 | b446c941b80520bd40ac10fa9cd5dcf946a05334645c7dda53185f961a634bbb |