Skip to main content

juq

Query, run, and clean/normalize Jupyter notebooks

juq.py on PyPI

Installation

pip install juq.py
juq
# Usage: juq [OPTIONS] COMMAND [ARGS]...
#
# Options:
#   --help  Show this message and exit.
#
# Commands:
#   cells          Slice/Filter cells.
#   merge-outputs  Merge consecutive "stream" outputs (e.g.
#   papermill      Wrapper for Papermill commands (`clean`, `run`).
#   renumber       Renumber cells (and outputs) with non-null...

Usage

juq cells

Slice/Filter cells:

juq cells --help
# Usage: juq cells [OPTIONS] CELLS_SLICE [NB_PATH]
#
#   Slice/Filter cells.
#
# Options:
#   -m, --metadata / -M, --no-metadata
#                                   Explicitly include or exclude each cell's
#                                   "metadata" key. If only `-m` is passed, only
#                                   the "metadata" value of each cell is printed
#   -o, --outputs / -O, --no-outputs
#                                   Explicitly include or exclude each cell's
#                                   "outputs" key. If only `-o` is passed, only
#                                   the "outputs" value of each cell is printed
#   -s, --source / -S, --no-source  Explicitly include or exclude each cell's
#                                   "source" key. If only `-s` is passed, the
#                                   source is printed directly (not as JSON)
#   -t, --cell-type TEXT            Only print cells of this type. Recognizes
#                                   abbreviations: "c" for "code", {"m","md"}
#                                   for "markdown", "r" for "raw"
#   --help                          Show this message and exit.

juq merge-outputs

Merge consecutive "stream" outputs (e.g. stderr):

juq merge-outputs --help
# Usage: juq merge-outputs [OPTIONS] [NB_PATH] [OUT_PATH]
#
#   Merge consecutive "stream" outputs (e.g. stderr).
#
# Options:
#   -a, --ensure-ascii              Octal-escape non-ASCII characters in JSON
#                                   output
#   -i, --in-place                  Modify [NB_PATH] in-place
#   -n, --indent INTEGER            Indentation level for the output notebook
#                                   JSON (default: infer from input)
#   -o, --out-path TEXT             Write to this file instead of stdout
#   -t, --trailing-newline / -T, --no-trailing-newline
#                                   Enforce presence or absence of a trailing
#                                   newline (default: match input)
#   --help                          Show this message and exit.

e.g.:

juq merge-outputs -i notebook.ipynb

Useful for situations like:

As of nbconvert#2089, this should be redundant with:

jupyter nbconvert --coalesce-streams --inplace notebook.ipynb

See also: test_merge_cell_outputs.py.

juq papermill clean

juq papermill clean --help
# Usage: juq papermill clean [OPTIONS] [NB_PATH] [OUT_PATH]
#
#   Remove Papermill metadata from a notebook.
#
#   Removes `.metadata.papermill` and
#   `.cells[*].metadata.{papermill,execution,widgets}`.
#
# Options:
#   -I, --keep-ids                  Keep cell ids; by default they are removed.
#   -k, --keep-tags / -K, --no-keep-tags
#                                   When a cell's `tags` array is empty, enforce
#                                   its presence or absence in the output.
#   -a, --ensure-ascii              Octal-escape non-ASCII characters in JSON
#                                   output
#   -i, --in-place                  Modify [NB_PATH] in-place
#   -n, --indent INTEGER            Indentation level for the output notebook
#                                   JSON (default: infer from input)
#   -o, --out-path TEXT             Write to this file instead of stdout
#   -t, --trailing-newline / -T, --no-trailing-newline
#                                   Enforce presence or absence of a trailing
#                                   newline (default: match input)
#   --help                          Show this message and exit.

See also: test_papermill_clean.py.

juq papermill run

juq papermill run --help
# Usage: juq papermill run [OPTIONS] [NB_PATH] [OUT_PATH]
#
#   Run a notebook using Papermill, clean nondeterministic metadata, normalize
#   output streams.
#
# Options:
#   -I, --keep-ids                  Keep cell ids; by default they are removed.
#   -k, --keep-tags / -K, --no-keep-tags
#                                   When a cell's `tags` array is empty, enforce
#                                   its presence or absence in the output.
#   -p, --parameter TEXT            "<k>=<v>" variable to set, while executing
#                                   the notebook
#   -s, --request-save-on-cell-execute
#                                   Request save notebook after each cell
#                                   execution
#   -S, --autosave-cell-every INTEGER
#                                   How often in seconds to autosave the
#                                   notebook during long cell executions (0 to
#                                   disable)
#   -a, --ensure-ascii              Octal-escape non-ASCII characters in JSON
#                                   output
#   -i, --in-place                  Modify [NB_PATH] in-place
#   -n, --indent INTEGER            Indentation level for the output notebook
#                                   JSON (default: infer from input)
#   -o, --out-path TEXT             Write to this file instead of stdout
#   -t, --trailing-newline / -T, --no-trailing-newline
#                                   Enforce presence or absence of a trailing
#                                   newline (default: match input)
#   --help                          Show this message and exit.

See also: test_papermill_run.py.

juq renumber

juq renumber --help
# Usage: juq renumber [OPTIONS] [NB_PATH] [OUT_PATH]
#
#   Renumber cells (and outputs) with non-null `execution_count` fields
#   (beginning from 1).
#
#   Simulates the executed cells having been executed in order (e.g. to avoid
#   needing to re-run a whole notebook after rearranging cells that don't depend
#   on one another).
#
# Options:
#   -q, --quiet                     Suppress logging info about each
#                                   `execution_count` update to stderr
#   -a, --ensure-ascii              Octal-escape non-ASCII characters in JSON
#                                   output
#   -i, --in-place                  Modify [NB_PATH] in-place
#   -n, --indent INTEGER            Indentation level for the output notebook
#                                   JSON (default: infer from input)
#   -o, --out-path TEXT             Write to this file instead of stdout
#   -t, --trailing-newline / -T, --no-trailing-newline
#                                   Enforce presence or absence of a trailing
#                                   newline (default: match input)
#   --help                          Show this message and exit.

See also: test_renumber.py.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

juq_py-0.7.0.tar.gz (151.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

juq_py-0.7.0-py3-none-any.whl (12.9 kB view details)

Uploaded Python 3

File details

Details for the file juq_py-0.7.0.tar.gz.

File metadata

  • Download URL: juq_py-0.7.0.tar.gz
  • Upload date:
  • Size: 151.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for juq_py-0.7.0.tar.gz
Algorithm Hash digest
SHA256 3b543c33d55393e47dcccf9c33584708eaf2ace8e290acae1fa148b0411fe884
MD5 186a1aac4bf051a23e1fe6052fa8d864
BLAKE2b-256 fcc45f1b7902523444884f8b72ae33ea5d93829dd0ba67fc2e1fde81c3f8e312

See more details on using hashes here.

File details

Details for the file juq_py-0.7.0-py3-none-any.whl.

File metadata

  • Download URL: juq_py-0.7.0-py3-none-any.whl
  • Upload date:
  • Size: 12.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for juq_py-0.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 34180963c670e1b52bb529806bfd2a0fb93319588a9f6a15b04da58280ba1023
MD5 cef91464656a9cc893de85ca54a53c11
BLAKE2b-256 a608b63efaf07bf9a777316434f742a4e8c5a5adfd72220d6d4ed85c39e2773c

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.7.0 This release

2 files

0.6.0

2 files

0.5.2

2 files

0.5.1

2 files

0.5.0

2 files

0.4.2

2 files

0.4.1

2 files

0.4.0

2 files

0.3.1

2 files

0.3.0

2 files

0.2.2

2 files

0.2.1

2 files

0.2.0

2 files

0.1.1

2 files

0.1.0

2 files

0.0.1

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page