笔记本电脑的存储工作流
depositor的Python项目详细描述
存管
此存储库为存储、计划和发布笔记本提供工具和工作流建议。
自动笔记本版本控制
每次保存笔记本都会在对象存储上创建笔记本的不可变副本。
为了简化实现,我们将依赖s3作为对象存储,使用versioned buckets。
存储路径
所有笔记本都存档到一个单一版本的s3存储桶中,该存储桶具有表示笔记本生命周期的特定前缀:
/workspace
-用户编辑的位置/scheduled
-当前计划的笔记本/published
-公共笔记本(对组织而言)
每个笔记本路径都是外部服务绑定到计划中的命名空间。我们归档版本,保持路径完整(直到用户更改它们)。
Prefix | Intent |
---|---|
^{ | Notebook in “draft” |
^{ | Current scheduled copy |
^{ | Current published copy |
转换到此存储计划
由于大多数人都在一个常规文件系统中,我们将从写入/workspace
前缀作为存档存储开始(使用jupyter内容管理器的post_save_hook
在保存时写入)。
配置
fromdepositoryimportdepositoryContentsArchiver# jupyter config# At ~/.jupyter/jupyter_notebook_config.py for user installs# At __ for system installsc=get_config()c.NotebookApp.contents_manager_class=depositoryContentsArchiverc.depository.workspace_prefix="/workspace/kylek/notebooks"c.depository.published_prefix="/published/kylek/notebooks"c.depository.scheduled_prefix="/scheduled/kylek/notebooks"# Optional, in case you're using a different contents manager# This defaults to notebook.services.contents.manager.ContentsManager# c.depository.Archiver.underlying_contents_manager_class = ADifferentContentsManagerc.depository.Backend="s3"c.depository.S3.bucket="<bucket-name>"# Note: if depository is used from an EC2 instance with the right IAM role, you don't# have to specify thesec.depository.S3.access_key_id=<AWSAccessKeyID/IAMAccessKeyID>c.depository.S3.secret_access_key=<AWSSecretAccessKey/IAMSecretAccessKey>