-
Notifications
You must be signed in to change notification settings - Fork 513
Allow plain text .qmd files as source notebooks
#1521
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
bhoov
wants to merge
36
commits into
AnswerDotAI:main
Choose a base branch
from
bhoov:qmd_support
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
c93ea72
Add .qmd read functionality to processor
bhoov bf8c091
Fix file glob for nbdev to detect .qmd files as source nbs
bhoov fceff8f
Don't clean .qmd files
bhoov f113f14
Simplify `read_qmd` in style of nbdev code
bhoov 3a8d61b
Allow custom directives in `.qmd` files
bhoov c7389eb
Attempt .qmd to generate good looking docs
bhoov c477249
Update sidebar.yml to look for .ipynb instead of .qmd in cache folder
bhoov 82d3205
Execute .qmd files when rendering
bhoov b98f5ee
Cleanup function in succinct style of nbdev
bhoov 6109227
Cleanup debugging statements
bhoov 8a32180
Enable back-syncing qmd from changes in .py files
bhoov 98f118d
Only use official frontmatter for .qmd documents
bhoov 8b98a61
Add documentation for no custom YAML for qmd
bhoov d43cf36
Move qmd processing to 15_qmd.ipynb
bhoov adf7039
Allow .qmd frontmatter to still auto-calc title and description, but …
bhoov e025097
Create script to convert .ipynb to .qmd
bhoov 19788db
Add script to convert ipynb to qmd
bhoov 33ad5f1
Allow markdown after custom frontmatter
bhoov b124c76
Pre-compile fm regex
bhoov 33a10cb
Improve converting from .ipynb to .qmd (account for backticks in pyth…
bhoov bdfb1db
.qmd files now read custom KV yaml
bhoov 86354d9
Custom frontmatter now parsed correctly for docs
bhoov 04c87d5
Cleanup frontmatter code
bhoov deebd53
Copy .qmd for docs
bhoov f49bd4b
Update nbs
bhoov 90db296
Allow frontmatter keys to contain hyphens
bhoov c503fc4
Fix index.qmd not found
bhoov cb5a410
Initial draft of .qmd file tutorial
bhoov f27e408
Add annotations to custom functions
bhoov e510a85
Update tutorial
bhoov 4f23ca8
Cleanup
bhoov f893026
Merge branch 'main' into qmd_support
bhoov f10b4e9
Allow qmd to ipynb conversion
bhoov 2e425db
Add support for ipynb in qmd directory
bhoov f96f3f8
Merge branch 'main' into qmd_support
bhoov bc2043c
Merge branch 'main' into qmd_support
bhoov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -149,4 +149,3 @@ checklink/cookies.txt | |
|
|
||
| # .gitconfig is now autogenerated | ||
| .gitconfig | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,140 @@ | ||
| { | ||
| "cells": [ | ||
| { | ||
| "cell_type": "raw", | ||
| "metadata": {}, | ||
| "source": [ | ||
| "---\n", | ||
| "output-file: index.html\n", | ||
| "title: HAMUX\n", | ||
| "\n", | ||
| "---\n", | ||
| "\n" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "markdown", | ||
| "metadata": {}, | ||
| "source": [ | ||
| "<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": null, | ||
| "metadata": { | ||
| "language": "python" | ||
| }, | ||
| "outputs": [], | ||
| "source": [ | ||
| "#| echo: false\n", | ||
| "# from hamux_qmd.core import *" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "markdown", | ||
| "metadata": {}, | ||
| "source": [ | ||
| "> Energy formulation for deep learning\n", | ||
| "\n", | ||
| "This file will become your README and also the index of your documentation.\n", | ||
| "\n", | ||
| "## Developer Guide\n", | ||
| "\n", | ||
| "If you are new to using `nbdev` here are some useful pointers to get you started.\n", | ||
| "\n", | ||
| "### Install hamux_qmd in Development mode\n", | ||
| "\n", | ||
| "```sh\n", | ||
| "# make sure hamux_qmd package is installed in development mode\n", | ||
| "$ pip install -e .\n", | ||
| "\n", | ||
| "# make changes under nbs/ directory\n", | ||
| "# ...\n", | ||
| "\n", | ||
| "# compile to have changes apply to hamux_qmd\n", | ||
| "$ nbdev_prepare" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": null, | ||
| "metadata": { | ||
| "language": "python" | ||
| }, | ||
| "outputs": [], | ||
| "source": [ | ||
| "## Usage\n", | ||
| "\n", | ||
| "### Installation\n", | ||
| "\n", | ||
| "Install latest from the GitHub [repository][repo]:\n", | ||
| "\n", | ||
| "```sh\n", | ||
| "$ pip install git+https://github.com/bhoov/hamux_qmd.git" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "markdown", | ||
| "metadata": {}, | ||
| "source": [ | ||
| "or from [conda][conda]\n", | ||
| "\n", | ||
| "```sh\n", | ||
| "$ conda install -c bhoov hamux_qmd" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": null, | ||
| "metadata": { | ||
| "language": "python" | ||
| }, | ||
| "outputs": [], | ||
| "source": [ | ||
| "or from [pypi][pypi]\n", | ||
| "\n", | ||
| "\n", | ||
| "```sh\n", | ||
| "$ pip install hamux_qmd" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "markdown", | ||
| "metadata": {}, | ||
| "source": [ | ||
| "[repo]: https://github.com/bhoov/hamux_qmd\n", | ||
| "[docs]: https://bhoov.github.io/hamux_qmd/\n", | ||
| "[pypi]: https://pypi.org/project/hamux_qmd/\n", | ||
| "[conda]: https://anaconda.org/bhoov/hamux_qmd\n", | ||
| "\n", | ||
| "## How to use\n", | ||
| "\n", | ||
| "Fill me in please! Don't forget code examples:\n" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": null, | ||
| "metadata": { | ||
| "language": "python" | ||
| }, | ||
| "outputs": [], | ||
| "source": [ | ||
| "1+1" | ||
| ] | ||
| } | ||
| ], | ||
| "metadata": { | ||
| "kernelspec": { | ||
| "display_name": "Python 3", | ||
| "language": "python", | ||
| "name": "python3" | ||
| }, | ||
| "language_info": { | ||
| "name": "python" | ||
| } | ||
| }, | ||
| "nbformat": 4, | ||
| "nbformat_minor": 5 | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,112 @@ | ||
| { | ||
| "cells": [ | ||
| { | ||
| "cell_type": "raw", | ||
| "metadata": {}, | ||
| "source": [ | ||
| "---\n", | ||
| "output-file: index_ipynb.html\n", | ||
| "title: HAMUX2\n", | ||
| "\n", | ||
| "---\n", | ||
| "\n" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "markdown", | ||
| "metadata": {}, | ||
| "source": [ | ||
| "<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": null, | ||
| "metadata": { | ||
| "language": "python" | ||
| }, | ||
| "outputs": [], | ||
| "source": [ | ||
| "#| echo: false\n", | ||
| "# from hamux_qmd.core import *" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "markdown", | ||
| "metadata": {}, | ||
| "source": [ | ||
| "> Energy formulation for deep learning\n", | ||
| "\n", | ||
| "This file will become your README and also the index of your documentation.\n", | ||
| "\n", | ||
| "## Developer Guide\n", | ||
| "\n", | ||
| "If you are new to using `nbdev` here are some useful pointers to get you started.\n", | ||
| "\n", | ||
| "### Install hamux_qmd in Development mode\n", | ||
| "\n", | ||
| "```sh\n", | ||
| "# make sure hamux_qmd package is installed in development mode\n", | ||
| "$ pip install -e .\n", | ||
| "\n", | ||
| "# make changes under nbs/ directory\n", | ||
| "# ...\n", | ||
| "\n", | ||
| "# compile to have changes apply to hamux_qmd\n", | ||
| "$ nbdev_prepare\n", | ||
| "```\n", | ||
| "\n", | ||
| "## Usage\n", | ||
| "\n", | ||
| "### Installation\n", | ||
| "\n", | ||
| "Install latest from the GitHub [repository][repo]:\n", | ||
| "\n", | ||
| "```sh\n", | ||
| "$ pip install git+https://github.com/bhoov/hamux_qmd.git\n", | ||
| "```\n", | ||
| "\n", | ||
| "or from [conda][conda]\n", | ||
| "\n", | ||
| "```sh\n", | ||
| "$ conda install -c bhoov hamux_qmd\n", | ||
| "```\n", | ||
| "\n", | ||
| "or from [pypi][pypi]\n", | ||
| "\n", | ||
| "\n", | ||
| "```sh\n", | ||
| "$ pip install hamux_qmd\n", | ||
| "```\n", | ||
| "\n", | ||
| "\n", | ||
| "[repo]: https://github.com/bhoov/hamux_qmd\n", | ||
| "[docs]: https://bhoov.github.io/hamux_qmd/\n", | ||
| "[pypi]: https://pypi.org/project/hamux_qmd/\n", | ||
| "[conda]: https://anaconda.org/bhoov/hamux_qmd\n", | ||
| "\n", | ||
| "## How to use\n", | ||
| "\n", | ||
| "Fill me in please! Don't forget code examples:" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": null, | ||
| "metadata": { | ||
| "language": "python" | ||
| }, | ||
| "outputs": [], | ||
| "source": [ | ||
| "1+1" | ||
| ] | ||
| } | ||
| ], | ||
| "metadata": { | ||
| "language_info": { | ||
| "name": "python" | ||
| } | ||
| }, | ||
| "nbformat": 4, | ||
| "nbformat_minor": 2 | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,7 +38,7 @@ def nbdev_trust( | |
| path = fname if fname.is_dir() else fname.parent | ||
| check_fname = path/".last_checked" | ||
| last_checked = os.path.getmtime(check_fname) if check_fname.exists() else None | ||
| nbs = globtastic(fname, file_glob='*.ipynb', skip_folder_re='^[_.]') if fname.is_dir() else [fname] | ||
| nbs = globtastic(fname, file_re=r'.*\.ipynb$|.*\.qmd$', skip_folder_re='^[_.]') if fname.is_dir() else [fname] | ||
| for fn in nbs: | ||
| if last_checked and not force_all: | ||
| last_changed = os.path.getmtime(fn) | ||
|
|
@@ -141,7 +141,7 @@ def nbdev_clean( | |
| _write = partial(process_write, warn_msg='Failed to clean notebook', proc_nb=_clean) | ||
| if stdin: return _write(f_in=sys.stdin, f_out=sys.stdout) | ||
| if fname is None: fname = get_config().nbs_path | ||
| for f in globtastic(fname, file_glob='*.ipynb', skip_folder_re='^[_.]'): _write(f_in=f, disp=disp) | ||
| for f in globtastic(fname, file_re=r'.*\.ipynb$', skip_folder_re='^[_.]'): _write(f_in=f, disp=disp) # Don't clean .qmd files | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we leave the glob as it was then? |
||
|
|
||
| # %% ../nbs/api/11_clean.ipynb | ||
| def clean_jupyter(path, model, **kwargs): | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could simplify this in the multiple places it occurs, eg:
Although it feels like a glob would be nicer. What if we added a
file_extsparam to globtastic which took a comma separated list of file extensions? Then we could just havefile_exts='ipynb,qmd'.