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
Metadata
Release files for SeafileContentManager 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| SeafileContentManager-0.1.2.tar.gz | 16.8 kB | Without provenance | Details for SeafileContentManager-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| SeafileContentManager-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for SeafileContentManager-0.1.2-py3-none-any.whl |
Total release size: 46.6 kB
Release files / SeafileContentManager-0.1.2.tar.gz
| Download URL | SeafileContentManager-0.1.2.tar.gz |
|---|---|
| Size | 16.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
969b337030d7c1f9f4f67bcd843f1b9ecb60b3c26a2b63cd857213f4d5724e14
|
|
BLAKE2b-256 checksum How to use checksums |
c6e0aea8bc29b3b31ecccccddcf69025999cbab572e8fd716dbdcd525ccafde5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Release files / SeafileContentManager-0.1.2-py3-none-any.whl
| Download URL | SeafileContentManager-0.1.2-py3-none-any.whl |
|---|---|
| Size | 29.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cb566c87c9dce973467ca0e117b1f1cae33195af699930908c5475ca61029c77
|
|
BLAKE2b-256 checksum How to use checksums |
b446c941b80520bd40ac10fa9cd5dcf946a05334645c7dda53185f961a634bbb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Security for SeafileContentManager 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.