Skip to main content

Hybrid Content Manager

Project description

HybridContents

The HybridContentManager was originally created by Quantopian as part of pgcontents; however, the usage of HybridContentsManager was restricted to the compatibility requirements of pgcontents. These restrictions included postgres dependencies and no support for the latest notebook version (>6) even though the HybridContentsManager's had no dependencies on pgcontents. There were open issues related to this:

At Viaduct we used pgcontents exclusively for the HybridContentsManager and wanted to extend its functionality, so we created this fork hybridcontents.

Getting Started

Prerequisites:

Installation:

pip install hybridcontents

Usage

The following code snippet creates a HybridContentsManager with two directories with different content managers.

c = get_config()

c.NotebookApp.contents_manager_class = HybridContentsManager

c.HybridContentsManager.manager_classes = {
    "": FileContentsManager,
    "shared": S3ContentsManager
}

# Each item will be passed to the constructor of the appropriate content manager.
c.HybridContentsManager.manager_kwargs = {
    # Args for root FileContentsManager
    "": {
        "root_dir": read_only_dir
    },
    # Args for the shared S3ContentsManager directory
    "shared": {
        "access_key_id": ...,
        "secret_access_key": ...,
        "endpoint_url":  ...,
        "bucket": ...,
        "prefix": ...
    },
}

def only_allow_notebooks(path):
  return path.endswith('.ipynb')

# Only allow notebook files to be stored in S3
c.HybridContentsManager.path_validators = {
    "shared": only_allow_notebooks
}

Testing

To run unit tests,

tox

This will run all unit tests for python versions 2.7, 3.6, 3.7 and jupyter notebook versions 4, 5, and 6.

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

hybridcontents-0.2.0.tar.gz (13.8 kB view details)

Uploaded Source

File details

Details for the file hybridcontents-0.2.0.tar.gz.

File metadata

  • Download URL: hybridcontents-0.2.0.tar.gz
  • Upload date:
  • Size: 13.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/40.6.2 requests-toolbelt/0.9.1 tqdm/4.40.1 CPython/3.6.9

File hashes

Hashes for hybridcontents-0.2.0.tar.gz
Algorithm Hash digest
SHA256 603c9d82bde508c3f7ac4737534d22db94211ea23a18a75bd42d45868e97b84a
MD5 279216a4bc9a629302ca46374833b492
BLAKE2b-256 45cd337a92a1329b38a86641f29ec3c2c68e40e570e2166ef94ec3689c09a439

See more details on using hashes here.

Supported by

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