{ "info": { "author": "Marc Wouts", "author_email": "marc.wouts@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Environment :: Console", "Framework :: Jupyter", "Intended Audience :: Developers", "Intended Audience :: Science/Research", "License :: OSI Approved :: MIT License", "Programming Language :: Python", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Topic :: Text Processing :: Markup" ], "description": "# Parametrize and run scripts as notebooks with jupytext and papermill\n\n[![Build Status](https://travis-ci.com/mwouts/papermill_jupytext.svg?branch=master)](https://travis-ci.com/mwouts/papermill_jupytext)\n[![codecov.io](https://codecov.io/github/mwouts/papermill_jupytext/coverage.svg?branch=master)](https://codecov.io/github/mwouts/papermill_jupytext?branch=master)\n[![Language grade: Python](https://img.shields.io/badge/lgtm-A+-brightgreen.svg)](https://lgtm.com/projects/g/mwouts/papermill_jupytext/context:python)\n[![Pypi](https://img.shields.io/pypi/v/papermill_jupytext.svg)](https://pypi.python.org/pypi/papermill_jupytext)\n[![pyversions](https://img.shields.io/pypi/pyversions/papermill_jupytext.svg)](https://pypi.python.org/pypi/papermill_jupytext)\n[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/mwouts/papermill_jupytext/master?filepath=README.md)\n\nThis is on-going research on how to run scripts as notebooks using Jupytext and Papermill. \n\nThe corresponding GitHub issues are [Jupytext #231](https://github.com/mwouts/jupytext/issues/231) and [Papermill #365](https://github.com/nteract/papermill/issues/365).\n\nNote that the below is a Bash Jupyter notebook that is [tested on our CI](https://github.com/mwouts/papermill_jupytext/blob/10dd863304614dd0c6328c859a077b52ba3c9822/.travis.yml#L29). If you wish, you can also open and run it interactively on [Binder](https://mybinder.org/v2/gh/mwouts/papermill_jupytext/master?filepath=README.md).\n\n```bash\ncd demo\n```\n\n## Jupytext and Papermill\n\nIt is possible to convert a script to a notebook using Jupytext, and then to run it using Papermill. Here we use `--set-kernel -` to use the kernel that matches the current Python environment.\n\n```bash\njupytext script.py -o notebook.ipynb --set-kernel -\n```\n\n```bash\npapermill notebook.ipynb executed_notebook.ipynb -p integer 2 -p text 'updated text'\n```\n\n```bash\npython -c \"import nbformat\nwith open('executed_notebook.ipynb') as fp:\n nb = nbformat.read(fp, as_version=4)\nprint(nb.cells[-1]['outputs'][0]['text'])\"\n```\n\n## Inject parameters in a script using Papermill\n\nPapermill needs the language information in the kernel to inject the parameters in the notebooks, so in this case we also need to set a kernel for the notebook.\n\n```bash\njupytext script.py -o notebook.ipynb --set-kernel -\n```\n\n```bash\npapermill notebook.ipynb notebook_with_parameters.ipynb --prepare-only -p integer 3 -p text 'updated text, v3'\n```\n\nOnce the parameters have been injected, we can convert back the notebook to a script, and drop the kernel information:\n\n```bash\njupytext notebook_with_parameters.ipynb -o script_with_parameters.py --update-metadata '{\"kernelspec\":null, \"jupytext\":null}'\n```\n\n```bash\ncat script_with_parameters.py\n```\n\nAnd finally, we run the script using the Python interpreter:\n\n```bash\npython script_with_parameters.py\n```\n\n## Towards Papermill + Jupytext?\n\nWith the `papermill_jupytext` package, we can open Jupytext scripts with the `txt://` address. A kernel pointing to the current Python environment is injected in the documents that have no kernel.\n\n```bash\npapermill txt://script.py executed_notebook.ipynb -p integer 4 -p text 'updated text, v4'\n```\n\n```bash\npython -c \"import nbformat\nwith open('executed_notebook.ipynb') as fp:\n nb = nbformat.read(fp, as_version=4)\nprint(nb.cells[-1]['outputs'][0]['text'])\"\n```", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/mwouts/papermill_jupytext", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "papermill-jupytext", "package_url": "https://pypi.org/project/papermill-jupytext/", "platform": "", "project_url": "https://pypi.org/project/papermill-jupytext/", "project_urls": { "Homepage": "https://github.com/mwouts/papermill_jupytext" }, "release_url": "https://pypi.org/project/papermill-jupytext/0.0.1/", "requires_dist": null, "requires_python": "", "summary": "Parametrize and run scripts as notebooks with jupytext and papermill", "version": "0.0.1" }, "last_serial": 5564934, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "641dc12bc73808207a2186be38ecf721", "sha256": "e959c868498debd557316fd265483d104708255fd7d6c19708821b1e86b502bf" }, "downloads": -1, "filename": "papermill_jupytext-0.0.1.tar.gz", "has_sig": false, "md5_digest": "641dc12bc73808207a2186be38ecf721", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3653, "upload_time": "2019-07-21T22:37:52", "url": "https://files.pythonhosted.org/packages/e0/a6/11a5c9193f66644724b8ad22f40230d2fff5097dc5bdf98516fd122a1ac0/papermill_jupytext-0.0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "641dc12bc73808207a2186be38ecf721", "sha256": "e959c868498debd557316fd265483d104708255fd7d6c19708821b1e86b502bf" }, "downloads": -1, "filename": "papermill_jupytext-0.0.1.tar.gz", "has_sig": false, "md5_digest": "641dc12bc73808207a2186be38ecf721", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3653, "upload_time": "2019-07-21T22:37:52", "url": "https://files.pythonhosted.org/packages/e0/a6/11a5c9193f66644724b8ad22f40230d2fff5097dc5bdf98516fd122a1ac0/papermill_jupytext-0.0.1.tar.gz" } ] }