├── js
├── style
│ ├── index.css
│ └── icon.svg
├── tests
│ ├── styleMock.js
│ ├── fileMock.js
│ ├── assetsTransformer.js
│ ├── activate.test.js
│ ├── export.test.js
│ └── setup.js
├── src
│ ├── common.js
│ ├── icon.js
│ ├── index.js
│ └── widget.js
├── babel.config.js
├── jest.config.js
├── .eslintrc.js
└── package.json
├── binder
├── runtime.txt
├── requirements.txt
└── postBuild
├── jupyterlab_autoversion
├── storage
│ ├── __init__.py
│ ├── s3
│ │ ├── hook.py
│ │ ├── handlers.py
│ │ └── __init__.py
│ ├── sql
│ │ ├── hook.py
│ │ ├── handlers.py
│ │ └── __init__.py
│ └── git
│ │ ├── hook.py
│ │ ├── __init__.py
│ │ ├── diff.py
│ │ └── handlers.py
├── tests
│ ├── __init__.py
│ ├── test_all.py
│ ├── test_init.py
│ ├── test_extension.py
│ └── test_handlers.py
├── extension
│ ├── jupyterlab_autoversion.json
│ └── install.json
├── __init__.py
└── extension.py
├── .vscode
└── settings.json
├── docs
├── diff.gif
└── example.gif
├── .github
├── workflows
│ ├── copier.yaml
│ └── build.yaml
├── dependabot.yaml
├── ISSUE_TEMPLATE
│ ├── feature_request.md
│ └── bug_report.md
└── CODE_OF_CONDUCT.md
├── .gitattributes
├── .copier-answers.yaml
├── README.md
├── .gitignore
├── pyproject.toml
├── Makefile
└── LICENSE
/js/style/index.css:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/binder/runtime.txt:
--------------------------------------------------------------------------------
1 | python-3.9
--------------------------------------------------------------------------------
/jupyterlab_autoversion/storage/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/jupyterlab_autoversion/storage/s3/hook.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/jupyterlab_autoversion/storage/sql/hook.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/jupyterlab_autoversion/tests/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/js/tests/styleMock.js:
--------------------------------------------------------------------------------
1 | module.exports = {};
2 |
--------------------------------------------------------------------------------
/jupyterlab_autoversion/storage/s3/handlers.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/jupyterlab_autoversion/storage/sql/handlers.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/js/tests/fileMock.js:
--------------------------------------------------------------------------------
1 | module.exports = "test-file-stub";
2 |
--------------------------------------------------------------------------------
/binder/requirements.txt:
--------------------------------------------------------------------------------
1 | jupyterlab_autoversion==0.4.0
2 | jupyterlab>=4,<5
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "eslint.workingDirectories": ["./js"]
3 | }
--------------------------------------------------------------------------------
/binder/postBuild:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | jupyter serverextension enable --py jupyterlab
3 |
--------------------------------------------------------------------------------
/jupyterlab_autoversion/tests/test_all.py:
--------------------------------------------------------------------------------
1 | from jupyterlab_autoversion import * # noqa
2 |
--------------------------------------------------------------------------------
/docs/diff.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/timkpaine/jupyterlab_autoversion/HEAD/docs/diff.gif
--------------------------------------------------------------------------------
/docs/example.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/timkpaine/jupyterlab_autoversion/HEAD/docs/example.gif
--------------------------------------------------------------------------------
/jupyterlab_autoversion/storage/s3/__init__.py:
--------------------------------------------------------------------------------
1 | from .handlers import * # noqa: F401, F403
2 | from .hook import * # noqa: F401, F403
3 |
--------------------------------------------------------------------------------
/jupyterlab_autoversion/storage/sql/__init__.py:
--------------------------------------------------------------------------------
1 | from .handlers import * # noqa: F401, F403
2 | from .hook import * # noqa: F401, F403
3 |
--------------------------------------------------------------------------------
/jupyterlab_autoversion/extension/jupyterlab_autoversion.json:
--------------------------------------------------------------------------------
1 | {
2 | "ServerApp": {
3 | "jpserver_extensions": {
4 | "jupyterlab_autoversion": true
5 | }
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/js/tests/assetsTransformer.js:
--------------------------------------------------------------------------------
1 | import {basename} from "path";
2 |
3 | export function process(src, filename) {
4 | return `module.exports = ${JSON.stringify(basename(filename))};`;
5 | }
6 |
--------------------------------------------------------------------------------
/js/src/common.js:
--------------------------------------------------------------------------------
1 | export const AUTOVERSION_COMMAND = "notebook:autoversion";
2 | export const AUTOVERSION_CAPTION = "Restore previous version of notebook";
3 | export const AUTOVERSION_LABEL = "autoversion";
4 |
--------------------------------------------------------------------------------
/js/src/icon.js:
--------------------------------------------------------------------------------
1 | import {LabIcon} from "@jupyterlab/ui-components";
2 |
3 | import svgStr from "../style/icon.svg";
4 |
5 | export const autoversionIcon = new LabIcon({
6 | name: "jupyterlab-autoversion",
7 | svgstr: svgStr,
8 | });
9 |
--------------------------------------------------------------------------------
/js/tests/activate.test.js:
--------------------------------------------------------------------------------
1 | import "isomorphic-fetch";
2 |
3 | import {_activate} from "../src/index";
4 |
5 | describe("Checks activate", () => {
6 | test("Check activate", () => {
7 | expect(_activate);
8 | });
9 | });
10 |
--------------------------------------------------------------------------------
/js/tests/export.test.js:
--------------------------------------------------------------------------------
1 | import "isomorphic-fetch";
2 |
3 | import * as extension from "../src/index";
4 |
5 | describe("Checks exports", () => {
6 | test("Check extension", () => {
7 | expect(extension);
8 | });
9 | });
10 |
--------------------------------------------------------------------------------
/js/babel.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | presets: [
3 | [
4 | "@babel/preset-env",
5 | {
6 | targets: {
7 | node: "current",
8 | },
9 | },
10 | ],
11 | ],
12 | };
--------------------------------------------------------------------------------
/jupyterlab_autoversion/extension/install.json:
--------------------------------------------------------------------------------
1 | {
2 | "packageManager": "python",
3 | "packageName": "jupyterlab-autoversion",
4 | "uninstallInstructions": "Use your Python package manager (pip, conda, etc.) to uninstall the package jupyterlab-autoversion"
5 | }
--------------------------------------------------------------------------------
/jupyterlab_autoversion/tests/test_init.py:
--------------------------------------------------------------------------------
1 | # for Coverage
2 | from jupyterlab_autoversion import _jupyter_server_extension_paths
3 |
4 |
5 | class TestInit:
6 | def test__jupyter_server_extension_paths(self):
7 | assert _jupyter_server_extension_paths() == [{"module": "jupyterlab_autoversion"}]
8 |
--------------------------------------------------------------------------------
/.github/workflows/copier.yaml:
--------------------------------------------------------------------------------
1 | name: Copier Updates
2 |
3 | on:
4 | workflow_dispatch:
5 | schedule:
6 | - cron: "0 5 * * 0"
7 |
8 | jobs:
9 | update:
10 | permissions:
11 | contents: write
12 | pull-requests: write
13 | runs-on: ubuntu-latest
14 | steps:
15 | - uses: actions-ext/copier-update@main
16 | with:
17 | token: ${{ secrets.WORKFLOW_TOKEN }}
18 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | examples/* linguist-documentation
2 | docs/* linguist-documentation
3 | *.ipynb linguist-documentation
4 | Makefile linguist-documentation
5 |
6 | *.css text=auto eol=lf
7 | *.html text=auto eol=lf
8 | *.js text=auto eol=lf
9 | *.json text=auto eol=lf
10 | *.less text=auto eol=lf
11 | *.md text=auto eol=lf
12 | *.py text=auto eol=lf
13 | *.toml text=auto eol=lf
14 | *.ts text=auto eol=lf
15 | *.yaml text=auto eol=lf
16 |
--------------------------------------------------------------------------------
/.copier-answers.yaml:
--------------------------------------------------------------------------------
1 | # Changes here will be overwritten by Copier
2 | _commit: b74d698
3 | _src_path: https://github.com/python-project-templates/base.git
4 | add_docs: false
5 | add_extension: jupyter
6 | add_wiki: false
7 | email: t.paine154@gmail.com
8 | github: timkpaine
9 | project_description: Automatically version jupyter notebooks in JupyterLab
10 | project_name: jupyterlab autoversion
11 | python_version_primary: '3.11'
12 | team: the jupyterlab autoversion authors
13 |
--------------------------------------------------------------------------------
/jupyterlab_autoversion/tests/test_extension.py:
--------------------------------------------------------------------------------
1 | from unittest.mock import MagicMock
2 |
3 | from jupyterlab_autoversion.extension import load_jupyter_server_extension
4 |
5 |
6 | class TestExtension:
7 | def test_load_jupyter_server_extension(self):
8 | m = MagicMock()
9 |
10 | m.web_app.settings = {}
11 | m.web_app.settings["base_url"] = "/test"
12 | m.config = {"JupyterLabAutoversion": {"backend": "git"}}
13 | load_jupyter_server_extension(m)
14 |
--------------------------------------------------------------------------------
/.github/dependabot.yaml:
--------------------------------------------------------------------------------
1 | version: 2
2 | updates:
3 | - package-ecosystem: "github-actions"
4 | directory: "/"
5 | schedule:
6 | interval: "weekly"
7 | labels:
8 | - "part: github_actions"
9 |
10 | - package-ecosystem: "pip"
11 | directory: "/"
12 | schedule:
13 | interval: "monthly"
14 | labels:
15 | - "lang: python"
16 | - "part: dependencies"
17 |
18 | - package-ecosystem: "npm"
19 | directory: "/js"
20 | schedule:
21 | interval: "monthly"
22 | labels:
23 | - "lang: javascript"
24 | - "part: dependencies"
25 |
--------------------------------------------------------------------------------
/js/style/icon.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/js/tests/setup.js:
--------------------------------------------------------------------------------
1 | Object.defineProperty(window, "DragEvent", {
2 | value: class DragEvent {},
3 | });
4 |
5 | Object.defineProperty(window, "matchMedia", {
6 | writable: true,
7 | value: jest.fn().mockImplementation((query) => ({
8 | matches: false,
9 | media: query,
10 | onchange: null,
11 | addListener: jest.fn(), // Deprecated
12 | removeListener: jest.fn(), // Deprecated
13 | addEventListener: jest.fn(),
14 | removeEventListener: jest.fn(),
15 | dispatchEvent: jest.fn(),
16 | })),
17 | });
18 |
19 | jest.mock("@jupyterlab/notebook", () => ({
20 | INotebookTracker: "notebook-tracker",
21 | }));
22 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea for this project
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Is your feature request related to a problem? Please describe.**
11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12 |
13 | **Describe the solution you'd like**
14 | A clear and concise description of what you want to happen.
15 |
16 | **Describe alternatives you've considered**
17 | A clear and concise description of any alternative solutions or features you've considered.
18 |
19 | **Additional context**
20 | Add any other context or screenshots about the feature request here.
21 |
--------------------------------------------------------------------------------
/jupyterlab_autoversion/__init__.py:
--------------------------------------------------------------------------------
1 | from .extension import load_jupyter_server_extension
2 |
3 | __version__ = "0.4.0"
4 |
5 |
6 | def _jupyter_server_extension_paths():
7 | return [{"module": "jupyterlab_autoversion"}]
8 |
9 |
10 | def _jupyter_server_extension_points():
11 | return [{"module": "jupyterlab_autoversion"}]
12 |
13 |
14 | def _load_jupyter_server_extension(serverapp, nb6_entrypoint=False):
15 | """
16 | Called when the extension is loaded.
17 |
18 | Args:
19 | nb_server_app (NotebookWebApplication): handle to the Notebook webserver instance.
20 | """
21 | load_jupyter_server_extension(serverapp)
22 |
23 |
24 | # def _jupyter_nbextension_paths():
25 | # return [
26 | # {
27 | # "section": "tree",
28 | # "src": "nbextension/static",
29 | # "dest": "jupyterlab_autoversion",
30 | # "require": "jupyterlab_autoversion/notebook",
31 | # }
32 | # ]
33 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a report to help us improve
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Describe the bug**
11 | A clear and concise description of what the bug is.
12 |
13 | **To Reproduce**
14 | Steps to reproduce the behavior:
15 | 1. Go to '...'
16 | 2. Click on '....'
17 | 3. Scroll down to '....'
18 | 4. See error
19 |
20 | **Expected behavior**
21 | A clear and concise description of what you expected to happen.
22 |
23 | **Screenshots**
24 | If applicable, add screenshots to help explain your problem.
25 |
26 | **Desktop (please complete the following information):**
27 | - OS: [e.g. iOS]
28 | - Browser [e.g. chrome, safari]
29 | - Version [e.g. 22]
30 |
31 | **Smartphone (please complete the following information):**
32 | - Device: [e.g. iPhone6]
33 | - OS: [e.g. iOS8.1]
34 | - Browser [e.g. stock browser, safari]
35 | - Version [e.g. 22]
36 |
37 | **Additional context**
38 | Add any other context about the problem here.
39 |
--------------------------------------------------------------------------------
/js/jest.config.js:
--------------------------------------------------------------------------------
1 | const esModules = [
2 | "@finos",
3 | "@jupyter",
4 | "@jupyterlab",
5 | "@jupyter-widgets",
6 | "@lumino",
7 | "@microsoft",
8 | "@rjsf",
9 | "delaunator",
10 | "exenv-es6",
11 | "internmap",
12 | "lib0",
13 | "lodash-es",
14 | "nanoid",
15 | "nbdime",
16 | "robust-predicates",
17 | "vscode-ws-jsonrpc",
18 | "y-protocols",
19 | ].join("|");
20 |
21 | module.exports = {
22 | moduleDirectories: ["node_modules", "src", "tests"],
23 | moduleNameMapper: {
24 | "\\.(css|less|sass|scss)$": "/tests/styleMock.js",
25 | "\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "/tests/fileMock.js",
26 | },
27 | reporters: [ "default", "jest-junit" ],
28 | setupFiles: ["/tests/setup.js"],
29 | testEnvironment: "jsdom",
30 | transform: {
31 | "^.+\\.jsx?$": "babel-jest",
32 | ".+\\.(css|styl|less|sass|scss)$": "jest-transform-css",
33 | },
34 | transformIgnorePatterns: [`/node_modules/.pnpm/(?!(${esModules}))`],
35 | };
36 |
--------------------------------------------------------------------------------
/jupyterlab_autoversion/storage/git/hook.py:
--------------------------------------------------------------------------------
1 | import hashlib
2 | import json
3 | import os
4 | import os.path
5 |
6 |
7 | def post_save_autocommit_git(repo, model, *args, **kwargs):
8 | """convert notebooks to Python script after save with nbconvert
9 | replaces `jupyter notebook --script`
10 | """
11 | if model["type"] != "notebook":
12 | return
13 |
14 | if model.get("content") and model.get("path"):
15 | id = model["content"]["metadata"].get("autoversion", "")
16 |
17 | if not id:
18 | sha = hashlib.sha256()
19 | sha.update(model["path"].encode())
20 | id = sha.hexdigest()
21 |
22 | path = os.path.join(repo.working_tree_dir, id)
23 |
24 | if not os.path.exists(path):
25 | os.mkdir(path)
26 |
27 | nb = os.path.join(path, "NOTEBOOK")
28 | with open(nb, "w") as fp:
29 | fp.write(json.dumps(model["content"]))
30 |
31 | last = len([x for x in repo.tags if id in x.name])
32 |
33 | repo.index.add([nb])
34 | repo.index.commit("%s-%d" % (id, last))
35 | repo.create_tag("%s-%d" % (id, last))
36 |
--------------------------------------------------------------------------------
/jupyterlab_autoversion/extension.py:
--------------------------------------------------------------------------------
1 | from jupyter_server.utils import url_path_join
2 |
3 |
4 | def load_jupyter_server_extension(nb_server_app):
5 | """
6 | Called when the extension is loaded.
7 |
8 | Args:
9 | nb_server_app (NotebookWebApplication): handle to the Notebook webserver instance.
10 | """
11 | web_app = nb_server_app.web_app
12 | base_url = web_app.settings["base_url"]
13 | host_pattern = ".*$"
14 |
15 | backend = nb_server_app.config.get("JupyterLabAutoversion", {}).get("backend", "git")
16 |
17 | if backend not in ("git", "s3", "sql"):
18 | raise Exception("jupyterlab_autoversion backend not recognized: {}".format(backend))
19 |
20 | if backend == "s3":
21 | from .storage.s3 import initialize
22 | elif backend == "sql":
23 | from .storage.sql import initialize
24 | else:
25 | from .storage.git import initialize
26 |
27 | hook, handlers = initialize(nb_server_app)
28 |
29 | print("Installing jupyterlab_autoversion handler on path %s" % url_path_join(base_url, "autoversion"))
30 |
31 | web_app.add_handlers(host_pattern, handlers)
32 | nb_server_app.contents_manager.register_pre_save_hook(hook)
33 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # jupyterlab autoversion
2 |
3 | Automatically version jupyter notebooks in JupyterLab
4 |
5 | [](https://github.com/timkpaine/jupyterlab-autoversion/actions/workflows/build.yaml)
6 | [](https://codecov.io/gh/timkpaine/jupyterlab-autoversion)
7 | [](https://github.com/timkpaine/jupyterlab-autoversion)
8 | [](https://pypi.python.org/pypi/jupyterlab-autoversion)
9 | [](https://mybinder.org/v2/gh/timkpaine/jupyterlab-autoversion/main?urlpath=lab)
10 |
11 | ## Save every notebook revision
12 |
13 | Enhanced checkpoints, versioned and persistent between restarts on every save
14 |
15 | 
16 |
17 | Diff notebooks to previously saved versions:
18 | 
19 |
20 | ## License
21 |
22 | This software is licensed under the Apache 2.0 license. See the
23 | [LICENSE](LICENSE) file for details.
24 |
25 | > [!NOTE]
26 | > This library was generated using [copier](https://copier.readthedocs.io/en/stable/) from the [Base Python Project Template repository](https://github.com/python-project-templates/base).
27 |
--------------------------------------------------------------------------------
/jupyterlab_autoversion/storage/git/__init__.py:
--------------------------------------------------------------------------------
1 | import os
2 | import os.path
3 | from functools import partial
4 |
5 | from git import Repo
6 | from jupyter_server.utils import url_path_join
7 |
8 | from .diff import GitDiffHandler
9 | from .handlers import GitGetHandler, GitRestoreHandler
10 | from .hook import post_save_autocommit_git
11 |
12 |
13 | def initialize(nb_server_app):
14 | web_app = nb_server_app.web_app
15 | base_url = web_app.settings["base_url"]
16 |
17 | repo_root = os.path.join(os.path.abspath(os.curdir), ".autoversion")
18 | if not os.path.exists(repo_root):
19 | os.mkdir(repo_root)
20 | repo = Repo.init(repo_root)
21 | else:
22 | repo = Repo(repo_root)
23 |
24 | ignore_root = os.path.join(os.path.abspath(os.curdir), ".gitignore")
25 | if os.path.exists(ignore_root):
26 | with open(ignore_root, "r+") as fp:
27 | add = True
28 | for line in fp:
29 | if ".autoversion" in line:
30 | add = False
31 | if add:
32 | fp.write("\n.autoversion\n")
33 | else:
34 | with open(ignore_root, "w") as fp:
35 | fp.write("\n.autoversion\n")
36 |
37 | context = {"repo": repo}
38 | handlers = [
39 | (url_path_join(base_url, "autoversion/get"), GitGetHandler, context),
40 | (url_path_join(base_url, "autoversion/restore"), GitRestoreHandler, context),
41 | (url_path_join(base_url, "autoversion/diff"), GitDiffHandler, context),
42 | ]
43 |
44 | return partial(post_save_autocommit_git, repo=repo), handlers
45 |
--------------------------------------------------------------------------------
/js/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | parser: "@babel/eslint-parser",
3 | extends: ["airbnb-base", "prettier", "plugin:json/recommended"],
4 | plugins: ["prettier", "jest"],
5 | env: {
6 | browser: true,
7 | commonjs: true,
8 | es6: true,
9 | node: true,
10 | jasmine: true,
11 | jest: true,
12 | "jest/globals": true,
13 | },
14 | parserOptions: {
15 | ecmaVersion: 2017,
16 | ecmaFeatures: {},
17 | sourceType: "module",
18 | experimentalObjectRestSpread: true,
19 | },
20 | rules: {
21 | "prettier/prettier": [
22 | "error",
23 | {
24 | printWidth: 200,
25 | tabWidth: 2,
26 | bracketSpacing: false,
27 | },
28 | ],
29 | "max-len": [
30 | "warn",
31 | {
32 | code: 200,
33 | comments: 200,
34 | ignoreTrailingComments: true,
35 | },
36 | ],
37 | camelcase: "off",
38 | "class-methods-use-this": "off",
39 | "constructor-super": "error",
40 | indent: "off",
41 | "linebreak-style": ["error", "unix"],
42 | "no-const-assign": "error",
43 | "no-nested-ternary": "warn",
44 | "no-this-before-super": "error",
45 | "no-undef": "error",
46 | "no-underscore-dangle": "off",
47 | "no-unreachable": "error",
48 | "no-unused-vars": "warn",
49 | "object-curly-spacing": "off",
50 | quotes: "off",
51 | "spaced-comment": "off",
52 | "valid-typeof": "error",
53 |
54 | "import/extensions": "off",
55 | "import/no-unresolved": "off",
56 | "import/prefer-default-export": "off",
57 | "import/no-extraneous-dependencies": "off",
58 | },
59 | };
--------------------------------------------------------------------------------
/js/src/index.js:
--------------------------------------------------------------------------------
1 | /* eslint-disable max-classes-per-file */
2 | import {ToolbarButton} from "@jupyterlab/apputils";
3 | import {INotebookTracker} from "@jupyterlab/notebook";
4 | import {IRenderMimeRegistry} from "@jupyterlab/rendermime";
5 | import {DisposableDelegate} from "@lumino/disposable";
6 |
7 | import {autoversion} from "./widget";
8 | import {AUTOVERSION_CAPTION, AUTOVERSION_LABEL, AUTOVERSION_COMMAND} from "./common";
9 | import {autoversionIcon} from "./icon";
10 |
11 | import "../style/index.css";
12 |
13 | export class AutoversionExtension {
14 | commands;
15 |
16 | constructor(commands) {
17 | this.commands = commands;
18 | }
19 |
20 | /**
21 | * Create a new extension object.
22 | */
23 | createNew(panel) {
24 | const button = new ToolbarButton({
25 | className: "autoversionButton",
26 | tooltip: AUTOVERSION_CAPTION,
27 | icon: autoversionIcon,
28 | onClick: () => {
29 | this.commands.execute(AUTOVERSION_COMMAND);
30 | },
31 | });
32 |
33 | panel.toolbar.insertAfter("restart-and-run", AUTOVERSION_LABEL, button);
34 |
35 | return new DisposableDelegate(() => {
36 | button.dispose();
37 | });
38 | }
39 | }
40 |
41 | function activate(app, tracker, rendermime) {
42 | const {commands} = app;
43 | app.docRegistry.addWidgetExtension("Notebook", new AutoversionExtension(commands));
44 |
45 | commands.addCommand(AUTOVERSION_COMMAND, {
46 | caption: AUTOVERSION_CAPTION,
47 | execute: async () => {
48 | const current = tracker.currentWidget;
49 | if (!current) {
50 | return;
51 | }
52 | await app.commands.execute("docmanager:save");
53 | autoversion(app, rendermime, current.context);
54 | },
55 | icon: autoversionIcon,
56 | isEnabled: () => tracker && tracker.currentWidget !== undefined && tracker.currentWidget !== null,
57 | label: AUTOVERSION_CAPTION,
58 | });
59 |
60 | // eslint-disable-next-line no-console
61 | console.log("JupyterLab extension jupyterlab-autoversion is activated!");
62 | }
63 |
64 | const extension = {
65 | activate,
66 | autoStart: true,
67 | id: "jupyterlab-autoversion",
68 | requires: [INotebookTracker, IRenderMimeRegistry],
69 | };
70 |
71 | export default extension;
72 | export {activate as _activate};
73 |
--------------------------------------------------------------------------------
/.github/workflows/build.yaml:
--------------------------------------------------------------------------------
1 | name: Build Status
2 |
3 | on:
4 | push:
5 | branches:
6 | - main
7 | tags:
8 | - v*
9 | paths-ignore:
10 | - LICENSE
11 | - README.md
12 | pull_request:
13 | branches:
14 | - main
15 | workflow_dispatch:
16 |
17 | concurrency:
18 | group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
19 | cancel-in-progress: true
20 |
21 | permissions:
22 | contents: read
23 | checks: write
24 | pull-requests: write
25 |
26 | jobs:
27 | build:
28 | runs-on: ${{ matrix.os }}
29 |
30 | strategy:
31 | matrix:
32 | os: [ubuntu-latest]
33 | python-version: ["3.11"]
34 | node-version: [20.x]
35 |
36 | steps:
37 | - uses: actions/checkout@v6
38 |
39 | - uses: actions-ext/python/setup@main
40 | with:
41 | version: ${{ matrix.python-version }}
42 |
43 | - uses: actions-ext/node/setup@main
44 | with:
45 | version: 22.x
46 |
47 | - name: Install dependencies
48 | run: make develop
49 |
50 | - name: Lint
51 | run: make lint
52 | if: matrix.os == 'ubuntu-latest'
53 |
54 | - name: Checks
55 | run: make checks
56 | if: matrix.os == 'ubuntu-latest'
57 |
58 | - name: Build
59 | run: make build
60 |
61 | - name: Test
62 | run: make coverage
63 | if: matrix.os == 'ubuntu-latest'
64 |
65 | - name: Upload test results (Python)
66 | uses: actions/upload-artifact@v6
67 | with:
68 | name: test-results-${{ matrix.os }}-${{ matrix.python-version }}-${{ matrix.node-version }}
69 | path: '**/junit.xml'
70 | if: ${{ always() }}
71 |
72 | - name: Publish Unit Test Results
73 | uses: EnricoMi/publish-unit-test-result-action@v2
74 | with:
75 | files: '**/junit.xml'
76 | if: matrix.os == 'ubuntu-latest'
77 |
78 | - name: Upload coverage
79 | uses: codecov/codecov-action@v5
80 | with:
81 | token: ${{ secrets.CODECOV_TOKEN }}
82 |
83 | - name: Make dist
84 | run: make dist
85 | if: matrix.os == 'ubuntu-latest'
86 |
87 | - uses: actions/upload-artifact@v6
88 | with:
89 | name: dist-${{matrix.os}}
90 | path: dist
91 | if: matrix.os == 'ubuntu-latest'
92 |
93 |
--------------------------------------------------------------------------------
/jupyterlab_autoversion/storage/git/diff.py:
--------------------------------------------------------------------------------
1 | import hashlib
2 | import os
3 | import os.path
4 |
5 | import nbformat
6 | import tornado.web
7 | from git import Git
8 | from jupyter_server.base.handlers import JupyterHandler
9 | from nbdime import diff_notebooks
10 |
11 |
12 | class GitDiffHandler(JupyterHandler):
13 | def initialize(self, repo):
14 | self.repo = repo
15 |
16 | @tornado.web.authenticated
17 | def get(self):
18 | path = self.get_argument("path", "")
19 | id = self.get_argument("id", "")
20 | version = int(self.get_argument("version", 0))
21 |
22 | if not id and not path:
23 | self.finish({"id": "", "version": -1, "base": {}, "remote": {}, "diff": {}})
24 | return
25 |
26 | if not id and path:
27 | sha = hashlib.sha256()
28 | sha.update(path.encode())
29 | id = sha.hexdigest()
30 |
31 | try:
32 | tag = self.repo.tags[f"{id}-{version}"]
33 | except IndexError:
34 | self.finish({"id": "", "version": -1, "base": {}, "remote": {}, "diff": {}})
35 | return
36 |
37 | # original head index
38 | past = sorted(self.repo.tags, key=lambda t: t.commit.committed_datetime)[-1]
39 |
40 | # connect to git repo
41 | git = Git(self.repo.working_tree_dir)
42 |
43 | # read the current version of the notebook
44 | # NOTE: it is expected that we just saved
45 | base_path = os.path.join(self.repo.working_tree_dir, id)
46 | nb_path = os.path.join(base_path, "NOTEBOOK")
47 | if os.path.exists(base_path):
48 | if os.path.exists(nb_path):
49 | nb_current = nbformat.read(nb_path, 4)
50 | else:
51 | nb_current = {}
52 | else:
53 | nb_current = {}
54 |
55 | # checkout the tag we want to look at
56 | git.checkout(tag)
57 |
58 | # read the old version of the notebook
59 | if os.path.exists(base_path):
60 | if os.path.exists(nb_path):
61 | nb_old = nbformat.read(nb_path, 4)
62 | else:
63 | nb_old = {}
64 | else:
65 | nb_old = {}
66 |
67 | # diff the old notebook to the new notebook
68 | diff = diff_notebooks(nb_old, nb_current)
69 |
70 | # return the rendered html
71 | self.finish({"id": id, "version": version, "base": nb_old, "remote": nb_current, "diff": diff})
72 |
73 | # go back to head
74 | git.checkout(past)
75 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Byte-compiled / optimized / DLL files
2 | __pycache__/
3 | *.py[cod]
4 | *$py.class
5 |
6 | # C extensions
7 | *.a
8 | *.so
9 | *.obj
10 | *.dll
11 | *.exp
12 | *.lib
13 |
14 | # Distribution / packaging
15 | .Python
16 | build/
17 | develop-eggs/
18 | dist/
19 | downloads/
20 | eggs/
21 | .eggs/
22 | lib/
23 | lib64/
24 | parts/
25 | sdist/
26 | var/
27 | wheels/
28 | pip-wheel-metadata/
29 | share/python-wheels/
30 | *.egg-info/
31 | .installed.cfg
32 | *.egg
33 | MANIFEST
34 |
35 | # PyInstaller
36 | *.manifest
37 | *.spec
38 |
39 | # Installer logs
40 | pip-log.txt
41 | pip-delete-this-directory.txt
42 |
43 | # Unit test / coverage reports
44 | htmlcov/
45 | .tox/
46 | .nox/
47 | .coverage
48 | .coverage.*
49 | .cache
50 | nosetests.xml
51 | coverage.xml
52 | junit.xml
53 | *.cover
54 | *.py,cover
55 | .hypothesis/
56 | .pytest_cache/
57 |
58 | # Translations
59 | *.mo
60 | *.pot
61 |
62 | # Django stuff:
63 | *.log
64 | local_settings.py
65 | db.sqlite3
66 | db.sqlite3-journal
67 |
68 | # Flask stuff:
69 | instance/
70 | .webassets-cache
71 |
72 | # Scrapy stuff:
73 | .scrapy
74 |
75 | # PyBuilder
76 | target/
77 |
78 | # IPython
79 | profile_default/
80 | ipython_config.py
81 |
82 | # pyenv
83 | .python-version
84 |
85 | # pipenv
86 | Pipfile.lock
87 |
88 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow
89 | __pypackages__/
90 |
91 | # Celery stuff
92 | celerybeat-schedule
93 | celerybeat.pid
94 |
95 | # SageMath parsed files
96 | *.sage.py
97 |
98 | # Environments
99 | .env
100 | .venv
101 | env/
102 | venv/
103 | ENV/
104 | env.bak/
105 | venv.bak/
106 |
107 | # Spyder project settings
108 | .spyderproject
109 | .spyproject
110 |
111 | # Rope project settings
112 | .ropeproject
113 |
114 | # mkdocs documentation
115 | /site
116 |
117 | # mypy
118 | .mypy_cache/
119 | .dmypy.json
120 | dmypy.json
121 |
122 | # Pyre type checker
123 | .pyre/
124 |
125 | # Documentation
126 | /site
127 | index.md
128 | docs/_build/
129 | docs/src/_build/
130 | docs/api
131 | docs/index.md
132 | docs/html
133 | docs/jupyter_execute
134 | index.md
135 |
136 | # JS
137 | js/coverage
138 | js/dist
139 | js/lib
140 | js/node_modules
141 | js/test-results
142 | js/playwright-report
143 | js/*.tgz
144 | jupyterlab_autoversion/extension
145 |
146 | # Jupyter
147 | .ipynb_checkpoints
148 | .autoversion
149 | Untitled*.ipynb
150 | !jupyterlab_autoversion/extension/jupyterlab_autoversion.json
151 | !jupyterlab_autoversion/extension/install.json
152 | jupyterlab_autoversion/nbextension
153 | jupyterlab_autoversion/labextension
154 |
155 | # Mac
156 | .DS_Store
157 |
158 | # Rust
159 | target
160 |
--------------------------------------------------------------------------------
/jupyterlab_autoversion/storage/git/handlers.py:
--------------------------------------------------------------------------------
1 | import hashlib
2 | import os
3 | import os.path
4 |
5 | import nbformat
6 | import tornado.web
7 | from git import Git
8 | from jupyter_server.base.handlers import JupyterHandler
9 |
10 |
11 | class GitGetHandler(JupyterHandler):
12 | def initialize(self, repo):
13 | self.repo = repo
14 |
15 | @tornado.web.authenticated
16 | def get(self):
17 | path = self.get_argument("path", "")
18 | id = self.get_argument("id", "")
19 |
20 | if not id and not path:
21 | self.finish({"id": "", "last": ""})
22 | return
23 |
24 | if not id and path:
25 | sha = hashlib.sha256()
26 | sha.update(path.encode())
27 | id = sha.hexdigest()
28 |
29 | last = [
30 | [x.commit.hexsha, x.commit.authored_date * 1000] + x.name.split("-")
31 | for x in reversed(sorted(self.repo.tags, key=lambda t: t.commit.committed_datetime))
32 | if id in x.name
33 | ]
34 |
35 | self.finish({"id": id, "versions": last})
36 | return
37 |
38 |
39 | class GitRestoreHandler(JupyterHandler):
40 | def initialize(self, repo):
41 | self.repo = repo
42 |
43 | @tornado.web.authenticated
44 | def get(self):
45 | path = self.get_argument("path", "")
46 | id = self.get_argument("id", "")
47 | version = int(self.get_argument("version", 0))
48 |
49 | if not id and not path:
50 | self.finish({"id": "", "version": -1, "contents": {}})
51 | return
52 |
53 | if not id and path:
54 | sha = hashlib.sha256()
55 | sha.update(path.encode())
56 | id = sha.hexdigest()
57 |
58 | try:
59 | tag = self.repo.tags[f"{id}-{version}"]
60 | except IndexError:
61 | self.finish({"id": "", "version": -1, "contents": {}})
62 | return
63 |
64 | # original head index
65 | past = sorted(self.repo.tags, key=lambda t: t.commit.committed_datetime)[-1]
66 |
67 | # connect to git repo
68 | git = Git(self.repo.working_tree_dir)
69 |
70 | # checkout the tag we want to look at
71 | git.checkout(tag)
72 |
73 | # read the old version of the notebook
74 | base_path = os.path.join(self.repo.working_tree_dir, id)
75 | nb_path = os.path.join(base_path, "NOTEBOOK")
76 | if os.path.exists(base_path):
77 | if os.path.exists(nb_path):
78 | nb = nbformat.read(nb_path, 4)
79 | else:
80 | nb = {}
81 | else:
82 | nb = {}
83 |
84 | # return the old notebook
85 | self.finish({"id": id, "version": version, "nb": nb})
86 |
87 | # go back to head
88 | git.checkout(past)
89 |
--------------------------------------------------------------------------------
/js/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "jupyterlab-autoversion",
3 | "version": "0.4.0",
4 | "description": "Automatically version jupyter notebooks in JupyterLab",
5 | "repository": "git@github.com:timkpaine/jupyterlab-autoversion.git",
6 | "author": "the jupyterlab autoversion authors ",
7 | "license": "Apache-2.0",
8 | "keywords": [
9 | "jupyter",
10 | "jupyterlab",
11 | "jupyterlab-extension"
12 | ],
13 | "main": "lib/index.js",
14 | "files": [
15 | "lib/**/*.{d.ts,eot,gif,html,jpg,js,js.map,json,png,svg,woff2,ttf}",
16 | "style/**/*.css"
17 | ],
18 | "jupyterlab": {
19 | "extension": "lib/index.js",
20 | "outputDir": "../jupyterlab_autoversion/labextension",
21 | "discovery": {
22 | "server": {
23 | "base": {
24 | "name": "jupyterlab_autoversion"
25 | },
26 | "managers": [
27 | "pip"
28 | ]
29 | }
30 | }
31 | },
32 | "scripts": {
33 | "build:babel": "babel src/ --source-maps --out-dir lib/",
34 | "build:labextension": "rimraf ../jupyterlab_autoversion/labextension && jupyter labextension build .",
35 | "build": "pnpm clean && pnpm build:babel && pnpm build:labextension",
36 | "clean": "rimraf lib",
37 | "fix": "pnpm lint --fix",
38 | "lint": "eslint -c .eslintrc.js --ext .js src/ tests/",
39 | "preinstall": "npx only-allow pnpm",
40 | "prepublishOnly": "pnpm run build",
41 | "test": "jest --coverage --collectCoverageFrom=src/*.{js}"
42 | },
43 | "dependencies": {
44 | "@jupyterlab/application": "^4.4.10",
45 | "@jupyterlab/apputils": "^4.6.0",
46 | "@jupyterlab/coreutils": "^6.4.10",
47 | "@jupyterlab/docmanager": "^4.5.0",
48 | "@jupyterlab/filebrowser": "^4.4.10",
49 | "@jupyterlab/launcher": "^4.4.10",
50 | "@jupyterlab/mainmenu": "^4.5.0",
51 | "@jupyterlab/mathjax2": "^3.6.8",
52 | "@jupyterlab/notebook": "^4.5.0",
53 | "@jupyterlab/rendermime": "^4.4.10",
54 | "@jupyterlab/services": "^7.4.10",
55 | "@lumino/disposable": "^2.1.4",
56 | "nbdime": "^7.0.2"
57 | },
58 | "devDependencies": {
59 | "@babel/cli": "^7.28.3",
60 | "@babel/core": "^7.28.5",
61 | "@babel/eslint-parser": "^7.28.5",
62 | "@babel/preset-env": "^7.28.5",
63 | "@jupyterlab/builder": "^4.4.10",
64 | "babel-jest": "^30.2.0",
65 | "cpy-cli": "^6.0.0",
66 | "eslint": "^8.57.1",
67 | "eslint-config-airbnb": "^19.0.4",
68 | "eslint-config-airbnb-base": "^15.0.0",
69 | "eslint-config-prettier": "^10.1.8",
70 | "eslint-plugin-import": "^2.32.0",
71 | "eslint-plugin-jest": "^29.0.1",
72 | "eslint-plugin-json": "^3.1.0",
73 | "eslint-plugin-prettier": "^5.5.4",
74 | "isomorphic-fetch": "^3.0.0",
75 | "jest": "^30.2.0",
76 | "jest-environment-jsdom": "^30.2.0",
77 | "jest-junit": "^16.0.0",
78 | "jest-transform-css": "^6.0.3",
79 | "jsdom-testing-mocks": "^1.16.0",
80 | "mkdirp": "^3.0.1",
81 | "prettier": "^3.7.3",
82 | "rimraf": "^6.1.0"
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/.github/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Contributor Covenant Code of Conduct
2 |
3 | ## Our Pledge
4 |
5 | In the interest of fostering an open and welcoming environment, we as
6 | contributors and maintainers pledge to making participation in our project and
7 | our community a harassment-free experience for everyone, regardless of age, body
8 | size, disability, ethnicity, sex characteristics, gender identity and expression,
9 | level of experience, education, socio-economic status, nationality, personal
10 | appearance, race, religion, or sexual identity and orientation.
11 |
12 | ## Our Standards
13 |
14 | Examples of behavior that contributes to creating a positive environment
15 | include:
16 |
17 | * Using welcoming and inclusive language
18 | * Being respectful of differing viewpoints and experiences
19 | * Gracefully accepting constructive criticism
20 | * Focusing on what is best for the community
21 | * Showing empathy towards other community members
22 |
23 | Examples of unacceptable behavior by participants include:
24 |
25 | * The use of sexualized language or imagery and unwelcome sexual attention or
26 | advances
27 | * Trolling, insulting/derogatory comments, and personal or political attacks
28 | * Public or private harassment
29 | * Publishing others' private information, such as a physical or electronic
30 | address, without explicit permission
31 | * Other conduct which could reasonably be considered inappropriate in a
32 | professional setting
33 |
34 | ## Our Responsibilities
35 |
36 | Project maintainers are responsible for clarifying the standards of acceptable
37 | behavior and are expected to take appropriate and fair corrective action in
38 | response to any instances of unacceptable behavior.
39 |
40 | Project maintainers have the right and responsibility to remove, edit, or
41 | reject comments, commits, code, wiki edits, issues, and other contributions
42 | that are not aligned to this Code of Conduct, or to ban temporarily or
43 | permanently any contributor for other behaviors that they deem inappropriate,
44 | threatening, offensive, or harmful.
45 |
46 | ## Scope
47 |
48 | This Code of Conduct applies both within project spaces and in public spaces
49 | when an individual is representing the project or its community. Examples of
50 | representing a project or community include using an official project e-mail
51 | address, posting via an official social media account, or acting as an appointed
52 | representative at an online or offline event. Representation of a project may be
53 | further defined and clarified by project maintainers.
54 |
55 | ## Enforcement
56 |
57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be
58 | reported by contacting the project team at t.paine154@gmail.com. All
59 | complaints will be reviewed and investigated and will result in a response that
60 | is deemed necessary and appropriate to the circumstances. The project team is
61 | obligated to maintain confidentiality with regard to the reporter of an incident.
62 | Further details of specific enforcement policies may be posted separately.
63 |
64 | Project maintainers who do not follow or enforce the Code of Conduct in good
65 | faith may face temporary or permanent repercussions as determined by other
66 | members of the project's leadership.
67 |
68 | ## Attribution
69 |
70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71 | available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
72 |
73 | [homepage]: https://www.contributor-covenant.org
74 |
75 | For answers to common questions about this code of conduct, see
76 | https://www.contributor-covenant.org/faq
77 |
--------------------------------------------------------------------------------
/jupyterlab_autoversion/tests/test_handlers.py:
--------------------------------------------------------------------------------
1 | # for Coverage
2 | import os
3 | import os.path
4 | from tempfile import TemporaryDirectory
5 | from unittest.mock import MagicMock
6 |
7 | import tornado.web
8 | from git import Repo
9 |
10 | from jupyterlab_autoversion.storage.git.handlers import GitGetHandler, GitRestoreHandler
11 |
12 |
13 | class TestExtension:
14 | def test_git_get_handler(self):
15 | app = tornado.web.Application()
16 | m = MagicMock()
17 |
18 | with TemporaryDirectory() as d:
19 | repo_root = os.path.join(d, ".autoversion")
20 | if not os.path.exists(repo_root):
21 | os.mkdir(repo_root)
22 |
23 | repo = Repo.init(repo_root)
24 |
25 | def get_argument(name, default):
26 | if name == "id":
27 | return ""
28 | if name == "path":
29 | return ""
30 |
31 | h = GitGetHandler(app, m, repo=repo)
32 | h._transforms = []
33 | h.current_user = h._jupyter_current_user = "blerg"
34 | h.get_argument = get_argument
35 | h.get()
36 |
37 | def get_argument(name, default):
38 | if name == "id":
39 | return ""
40 | if name == "path":
41 | return "test"
42 |
43 | h = GitGetHandler(app, m, repo=repo)
44 | h.current_user = h._jupyter_current_user = "blerg"
45 | h._transforms = []
46 | h.get_argument = get_argument
47 | h.get()
48 |
49 | def get_argument(name, default):
50 | if name == "id":
51 | return "test"
52 | if name == "path":
53 | return "test"
54 |
55 | h = GitGetHandler(app, m, repo=repo)
56 | h.current_user = h._jupyter_current_user = "blerg"
57 | h._transforms = []
58 | h.get_argument = get_argument
59 | h.get()
60 |
61 | def test_git_restore(self):
62 | app = tornado.web.Application()
63 | m = MagicMock()
64 |
65 | with TemporaryDirectory() as d:
66 | repo_root = os.path.join(d, ".autoversion")
67 | if not os.path.exists(repo_root):
68 | os.mkdir(repo_root)
69 |
70 | repo = Repo.init(repo_root)
71 |
72 | def get_argument(name, default):
73 | if name == "id":
74 | return ""
75 | if name == "path":
76 | return ""
77 | else:
78 | return 0
79 |
80 | h = GitRestoreHandler(app, m, repo=repo)
81 | h.current_user = h._jupyter_current_user = "blerg"
82 | h._transforms = []
83 | h.get_argument = get_argument
84 | h.get()
85 |
86 | def get_argument(name, default):
87 | if name == "id":
88 | return ""
89 | if name == "path":
90 | return "test"
91 | else:
92 | return 0
93 |
94 | h = GitRestoreHandler(app, m, repo=repo)
95 | h.current_user = h._jupyter_current_user = "blerg"
96 | h._transforms = []
97 | h.get_argument = get_argument
98 | h.get()
99 |
100 | def get_argument(name, default):
101 | if name == "id":
102 | return "test"
103 | if name == "path":
104 | return "test"
105 | else:
106 | return 0
107 |
108 | h = GitRestoreHandler(app, m, repo=repo)
109 | h.current_user = h._jupyter_current_user = "blerg"
110 | h._transforms = []
111 | h.get_argument = get_argument
112 | h.get()
113 |
--------------------------------------------------------------------------------
/pyproject.toml:
--------------------------------------------------------------------------------
1 | [build-system]
2 | requires = ["hatchling", "hatch-js", "jupyterlab>=4,<5"]
3 | build-backend="hatchling.build"
4 |
5 | [project]
6 | name = "jupyterlab-autoversion"
7 | authors = [{name = "the jupyterlab autoversion authors", email = "t.paine154@gmail.com"}]
8 | description = "Automatically version jupyter notebooks in JupyterLab"
9 | readme = "README.md"
10 | license = { text = "Apache-2.0" }
11 | version = "0.4.0"
12 | requires-python = ">=3.10"
13 | keywords = []
14 |
15 | classifiers = [
16 | "Development Status :: 3 - Alpha",
17 | "Framework :: Jupyter",
18 | "Framework :: Jupyter :: JupyterLab",
19 | "Programming Language :: Python",
20 | "Programming Language :: Python :: Implementation :: CPython",
21 | "Programming Language :: Python :: Implementation :: PyPy",
22 | "Programming Language :: Python :: 3",
23 | "Programming Language :: Python :: 3.10",
24 | "Programming Language :: Python :: 3.11",
25 | "Programming Language :: Python :: 3.12",
26 | "Programming Language :: Python :: 3.13",
27 | "Programming Language :: Python :: 3.14",
28 | ]
29 |
30 | dependencies = [
31 | "GitPython>=2.1.11",
32 | "jupyterlab>=4,<5",
33 | "nbdime",
34 | ]
35 |
36 | [project.optional-dependencies]
37 | develop = [
38 | "build",
39 | "bump-my-version",
40 | "check-manifest",
41 | "codespell>=2.4,<2.5",
42 | "hatch-js",
43 | "hatchling",
44 | "mdformat>=0.7.22,<1.1",
45 | "mdformat-tables>=1",
46 | "jupyterlab>=4,<5",
47 | "pytest",
48 | "pytest-cov",
49 | "ruff>=0.9,<0.15",
50 | "twine",
51 | "wheel",
52 | ]
53 |
54 | [project.scripts]
55 |
56 | [project.urls]
57 | Repository = "https://github.com/timkpaine/jupyterlab-autoversion"
58 | Homepage = "https://github.com/timkpaine/jupyterlab-autoversion"
59 |
60 | [tool.bumpversion]
61 | current_version = "0.4.0"
62 | commit = true
63 | tag = true
64 | commit_args = "-s"
65 |
66 | [[tool.bumpversion.files]]
67 | filename = "jupyterlab_autoversion/__init__.py"
68 | search = '__version__ = "{current_version}"'
69 | replace = '__version__ = "{new_version}"'
70 |
71 | [[tool.bumpversion.files]]
72 | filename = "pyproject.toml"
73 | search = 'version = "{current_version}"'
74 | replace = 'version = "{new_version}"'
75 |
76 | [[tool.bumpversion.files]]
77 | filename = "js/package.json"
78 | search = '"version": "{current_version}"'
79 | replace = '"version": "{new_version}"'
80 |
81 | [tool.check-manifest]
82 | ignore = [
83 | ".copier-answers.yaml",
84 | "js/pnpm-lock.yaml",
85 | "Makefile",
86 | ".vscode/*",
87 | "jupyterlab_autoversion/extension/**",
88 | "jupyterlab_autoversion/labextension/**",
89 | "binder/**/*",
90 | "docs/**/*",
91 | "js/dist/**/*",
92 | "js/lib/*",
93 | ]
94 |
95 | [tool.coverage.run]
96 | branch = true
97 | omit = [
98 | "jupyterlab_autoversion/tests/integration/",
99 | ]
100 | [tool.coverage.report]
101 | exclude_also = [
102 | "raise NotImplementedError",
103 | "if __name__ == .__main__.:",
104 | "@(abc\\.)?abstractmethod",
105 | ]
106 | ignore_errors = true
107 | fail_under = 50
108 |
109 | [tool.hatch.build]
110 | artifacts = [
111 | "jupyterlab_autoversion/labextension",
112 | ]
113 |
114 | [tool.hatch.build.sources]
115 | src = "/"
116 |
117 | [tool.hatch.build.targets.sdist]
118 | packages = ["jupyterlab_autoversion", "js"]
119 | exclude = [
120 | "/binder",
121 | "/js/dist",
122 | "/js/node_modules",
123 | ]
124 |
125 | [tool.hatch.build.targets.wheel]
126 | packages = ["jupyterlab_autoversion"]
127 | exclude = [
128 | "/binder",
129 | "/js"
130 | ]
131 |
132 | [tool.hatch.build.targets.wheel.shared-data]
133 | "jupyterlab_autoversion/labextension" = "share/jupyter/labextensions/jupyterlab-autoversion"
134 | "jupyterlab_autoversion/extension/install.json" = "share/jupyter/labextensions/jupyterlab-autoversion/install.json"
135 | "jupyterlab_autoversion/extension/jupyterlab_autoversion.json" = "etc/jupyter/jupyter_server_config.d/jupyterlab_autoversion.json"
136 |
137 | [tool.hatch.build.hooks.hatch-js]
138 | path = "js"
139 | build_cmd = "build"
140 | tool = "pnpm"
141 | targets = [
142 | "jupyterlab_autoversion/labextension/package.json",
143 | ]
144 |
145 | [tool.pytest.ini_options]
146 | addopts = ["-vvv", "--junitxml=junit.xml"]
147 | testpaths = "jupyterlab_autoversion/tests"
148 |
149 | [tool.ruff]
150 | line-length = 150
151 |
152 | [tool.ruff.lint]
153 | extend-select = ["I"]
154 |
155 | [tool.ruff.lint.isort]
156 | combine-as-imports = true
157 | default-section = "third-party"
158 | known-first-party = ["jupyterlab_autoversion"]
159 | section-order = ["future", "standard-library", "third-party", "first-party", "local-folder"]
160 |
161 | [tool.ruff.lint.per-file-ignores]
162 | "__init__.py" = ["F401", "F403"]
163 |
--------------------------------------------------------------------------------
/js/src/widget.js:
--------------------------------------------------------------------------------
1 | import {Dialog, showDialog} from "@jupyterlab/apputils";
2 | import {ServerConnection} from "@jupyterlab/services";
3 | import {Panel, Widget} from "@lumino/widgets";
4 | import {createEditorFactory} from "nbdime/lib/common/editor";
5 | import {NotebookDiffModel} from "nbdime/lib/diff/model";
6 | import {NotebookDiffWidget} from "nbdime/lib/diff/widget";
7 |
8 | import "../style/index.css";
9 |
10 | export class AutoversionWidget extends Widget {
11 | constructor(app, context, id, path) {
12 | /* Create version selector */
13 | const body = document.createElement("div");
14 | body.style.display = "flex";
15 | body.style.flexDirection = "column";
16 |
17 | const default_none = document.createElement("option");
18 | default_none.selected = false;
19 | default_none.disabled = true;
20 | default_none.hidden = false;
21 | default_none.style.display = "none";
22 | default_none.value = "";
23 |
24 | const type = document.createElement("select");
25 | type.appendChild(default_none);
26 |
27 | const settings = ServerConnection.makeSettings();
28 | ServerConnection.makeRequest(`${settings.baseUrl}autoversion/get?id=${id}&path=${path}`, {}, settings).then(async (res) => {
29 | if (res.ok) {
30 | const versions = await res.json();
31 | versions.versions.forEach((record) => {
32 | const option = document.createElement("option");
33 | option.value = record;
34 | const timestamp = new Date(record[1]);
35 |
36 | option.textContent = `${record[0].slice(0, 6)} - ${timestamp}`;
37 | type.appendChild(option);
38 | });
39 | }
40 | });
41 | type.style.marginBottom = "15px";
42 | type.style.minHeight = "25px";
43 | body.appendChild(type);
44 |
45 | super({node: body});
46 | }
47 |
48 | getValue() {
49 | return this.inputNode.value;
50 | }
51 |
52 | get inputNode() {
53 | return this.node.getElementsByTagName("select")[0];
54 | }
55 | }
56 |
57 | export function revision(app, context, id, version) {
58 | const settings = ServerConnection.makeSettings();
59 | ServerConnection.makeRequest(`${settings.baseUrl}autoversion/restore?id=${id}&path=${context.path}&version=${version}`, {}, settings).then(async (res) => {
60 | if (res.ok) {
61 | const data = await res.json();
62 | if (data.version.toString() === version) {
63 | context.model.fromJSON(data.nb);
64 | }
65 | }
66 | });
67 | }
68 |
69 | export function diff(app, rendermime, context, id, version) {
70 | const settings = ServerConnection.makeSettings();
71 | ServerConnection.makeRequest(`${settings.baseUrl}autoversion/diff?id=${id}&path=${context.path}&version=${version}`, {}, settings).then(async (res) => {
72 | if (res.ok) {
73 | const data = await res.json();
74 | const nbdModel = new NotebookDiffModel(data.base, data.diff);
75 | const nbdWidget = new NotebookDiffWidget({
76 | model: nbdModel,
77 | rendermime,
78 | editorFactory: createEditorFactory(),
79 | collapseIdentical: true,
80 | });
81 |
82 | const work = nbdWidget.init();
83 | await work;
84 |
85 | const {shell} = app;
86 | nbdWidget.id = id;
87 |
88 | /* mimic what nbdime does to match */
89 | const outer = new Panel();
90 | outer.id = id;
91 | outer.title.closable = true;
92 | outer.title.label = `Diff to ${id}`;
93 | outer.addClass("nbdime-Widget");
94 |
95 | const scroller = new Panel();
96 | scroller.addClass("nbdime-root");
97 | scroller.node.tabIndex = -1;
98 |
99 | shell.add(outer);
100 | outer.addWidget(scroller);
101 | scroller.addWidget(nbdWidget);
102 | shell.activateById(outer.id);
103 | // showDialog({
104 | // body: nbdWidget,
105 | // buttons: [Dialog.okButton({label: "Ok"})],
106 | // focusNodeSelector: "input",
107 | // title: "Diff:",
108 | // });
109 | }
110 | });
111 | }
112 |
113 | export function autoversion(app, rendermime, context) {
114 | const {model} = context;
115 | const id = model.metadata.autoversion || "";
116 |
117 | showDialog({
118 | body: new AutoversionWidget(app, context, id, context.path),
119 | buttons: [Dialog.cancelButton(), Dialog.okButton({label: "Diff"}), Dialog.okButton({label: "Ok"})],
120 | focusNodeSelector: "input",
121 | title: "Autoversion:",
122 | }).then((result) => {
123 | if (result.button.label === "Ok") {
124 | // narrow typing of .value since body.getValue != null
125 | const val = result.value.split(",");
126 | revision(app, context, val[2], val[3]);
127 | } else if (result.button.label === "Diff") {
128 | const val = result.value.split(",");
129 | diff(app, rendermime, context, val[2], val[3]);
130 | }
131 | });
132 | }
133 |
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | #########
2 | # BUILD #
3 | #########
4 | .PHONY: develop-py develop-js develop
5 | develop-py:
6 | uv pip install -e .[develop]
7 |
8 | develop-js: requirements-js
9 |
10 | develop: develop-js develop-py ## setup project for development
11 |
12 | .PHONY: requirements-py requirements-js requirements
13 | requirements-py: ## install prerequisite python build requirements
14 | python -m pip install --upgrade pip toml
15 | python -m pip install `python -c 'import toml; c = toml.load("pyproject.toml"); print("\n".join(c["build-system"]["requires"]))'`
16 | python -m pip install `python -c 'import toml; c = toml.load("pyproject.toml"); print(" ".join(c["project"]["optional-dependencies"]["develop"]))'`
17 |
18 | requirements-js: ## install prerequisite javascript build requirements
19 | cd js; pnpm install && npx playwright install
20 |
21 | requirements: requirements-js requirements-py ## setup project for development
22 |
23 | .PHONY: build-py build-js build
24 | build-py:
25 | python -m build -w -n
26 |
27 | build-js:
28 | cd js; pnpm build
29 |
30 | build: build-js build-py ## build the project
31 |
32 | .PHONY: install
33 | install: ## install python library
34 | uv pip install .
35 |
36 | #########
37 | # LINTS #
38 | #########
39 | .PHONY: lint-py lint-js lint-docs lint lints
40 | lint-py: ## run python linter with ruff
41 | python -m ruff check jupyterlab_autoversion
42 | python -m ruff format --check jupyterlab_autoversion
43 |
44 | lint-js: ## run js linter
45 | cd js; pnpm lint
46 |
47 | lint-docs: ## lint docs with mdformat and codespell
48 | python -m mdformat --check README.md
49 | python -m codespell_lib README.md
50 |
51 | lint: lint-js lint-py lint-docs ## run project linters
52 |
53 | # alias
54 | lints: lint
55 |
56 | .PHONY: fix-py fix-js fix-docs fix format
57 | fix-py: ## fix python formatting with ruff
58 | python -m ruff check --fix jupyterlab_autoversion
59 | python -m ruff format jupyterlab_autoversion
60 |
61 | fix-js: ## fix js formatting
62 | cd js; pnpm fix
63 |
64 | fix-docs: ## autoformat docs with mdformat and codespell
65 | python -m mdformat README.md
66 | python -m codespell_lib --write README.md
67 |
68 | fix: fix-js fix-py fix-docs ## run project autoformatters
69 |
70 | # alias
71 | format: fix
72 |
73 | ################
74 | # Other Checks #
75 | ################
76 | .PHONY: check-manifest checks check
77 |
78 | check-manifest: ## check python sdist manifest with check-manifest
79 | check-manifest -v
80 |
81 | checks: check-manifest
82 |
83 | # alias
84 | check: checks
85 |
86 | #########
87 | # TESTS #
88 | #########
89 | .PHONY: test-py tests-py coverage-py
90 | test-py: ## run python tests
91 | python -m pytest -v jupyterlab_autoversion/tests
92 |
93 | # alias
94 | tests-py: test-py
95 |
96 | coverage-py: ## run python tests and collect test coverage
97 | python -m pytest -v jupyterlab_autoversion/tests --cov=jupyterlab_autoversion --cov-report term-missing --cov-report xml
98 |
99 | .PHONY: test-js tests-js coverage-js
100 | test-js: ## run js tests
101 | cd js; pnpm test
102 |
103 | # alias
104 | tests-js: test-js
105 |
106 | coverage-js: test-js ## run js tests and collect test coverage
107 |
108 | .PHONY: test coverage tests
109 | test: test-py test-js ## run all tests
110 | coverage: coverage-py coverage-js ## run all tests and collect test coverage
111 |
112 | # alias
113 | tests: test
114 |
115 | ###########
116 | # VERSION #
117 | ###########
118 | .PHONY: show-version patch minor major
119 |
120 | show-version: ## show current library version
121 | @bump-my-version show current_version
122 |
123 | patch: ## bump a patch version
124 | @bump-my-version bump patch
125 |
126 | minor: ## bump a minor version
127 | @bump-my-version bump minor
128 |
129 | major: ## bump a major version
130 | @bump-my-version bump major
131 |
132 | ########
133 | # DIST #
134 | ########
135 | .PHONY: dist dist-py dist-js dist-check publish
136 |
137 | dist-py: ## build python dists
138 | python -m build -w -s
139 |
140 | dist-js: # build js dists
141 | cd js; pnpm pack
142 |
143 | dist-check: ## run python dist checker with twine
144 | python -m twine check dist/*
145 |
146 | dist: clean build dist-js dist-py dist-check ## build all dists
147 |
148 | publish: dist ## publish python assets
149 |
150 | #########
151 | # CLEAN #
152 | #########
153 | .PHONY: deep-clean clean
154 |
155 | deep-clean: ## clean everything from the repository
156 | git clean -fdx
157 |
158 | clean: ## clean the repository
159 | rm -rf .coverage coverage cover htmlcov logs build dist *.egg-info
160 |
161 | ############################################################################################
162 |
163 | .PHONY: help
164 |
165 | # Thanks to Francoise at marmelab.com for this
166 | .DEFAULT_GOAL := help
167 | help:
168 | @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
169 |
170 | print-%:
171 | @echo '$*=$($*)'
172 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright 2025 the jupyterlab autoversion authors
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------