This project contains some tools to help authoring and maintaing python tutorials presented on notebooks.
Add gepetuto
in your pip / PyPI dependencies
- create a (eg.
tp1
) directory (tp0
can be used to check prerequisites) - write python scripts (eg.
example_script.py
) in this directory - delimit snippets inside those scripts between
# %jupyter_snippet example_snippet
and# %end_jupyter_snippet
- create a (eg.
1-example_notebook.ipynb
) notebook, containingimport gepetuto.magic
- run
gepetuto -a generate
: this will create atp{i}/generated
directory with eg.example_script_example_snippet
- cells can contain either eg.
%load tp1/generated/example_script_example_snippet
to display some code to students, or their%do_not_load
version to let the student write the code themself - run
gepetuto -a test
to check all python scripts in tp directories - run
gepetuto -a lint
to ensure the coding standards are respected in all python scripts in tp directories - add
gepetuto -a test
in your CI, andgepetuto -a lint
+gepetuto -a generate
in your pre-commit
$ gepetuto -h
usage: gepetuto [-h] [-v] [-a [{lint,test,generate,all}]] [-f [FILE [FILE ...]]] [-F [FILTER [FILTER ...]]]
[-p PYTHON] [-c] [-C DIRECTORY] [--version] [tp_id [tp_id ...]]
Tutorial edition framework
positional arguments:
tp_id choose which tp to process. Default to all.
optional arguments:
-h, --help show this help message and exit
-v, --verbose increment verbosity level
-a [{lint,test,generate,all}], --action [{lint,test,generate,all}]
choose what to do. Default to 'generate'.
-f [FILE [FILE ...]], --file [FILE [FILE ...]]
choose which files to process.
-F [FILTER [FILTER ...]], --filter [FILTER [FILTER ...]]
filter files to process.
-p PYTHON, --python PYTHON
choose python interpreter to use.
-c, --check check if linters change files.
-C DIRECTORY, --directory DIRECTORY
choose directory to run action on.
--version Get gepetuto version.
example of CI using all gepetuto actions on tests folder here :
- repo: https://github.com/Gepetto/gepetuto
rev: v1.3.0
hooks:
- id: generate-action
- id: lint-action
- id: test-action