chrisjsewell / ipypublish

A workflow for creating and editing publication ready scientific reports and presentations, from one or more Jupyter Notebooks, without leaving the browser!
http://ipypublish.readthedocs.io
BSD 3-Clause "New" or "Revised" License
224 stars 37 forks source link

IPyPostProcessor does not allow relative output path #114

Open phelps-sg opened 5 years ago

phelps-sg commented 5 years ago

Bug Report

Describe the bug

When using nbpublish with the -o option, specifying a relative path such as ./ results in the following error message:

ERROR:write-text-file:the post-processor requires an absolute folder path

To Reproduce

Steps to reproduce the behavior:

Specify a relative path when using nbpublish; e.g.:

nbpublish -log debug -f slides_ipypublish_all bayes-slides.ipynb -o ./target

(for extended explanation, use the additional context section)

Minimal Notebook Example

If possible, please create a minimal Jupyter Notebook to replicate the issue. Then rename its file extension to .txt (since Github rejects .ipynb), and drag and drop it here.

Expected Behaviour

nbpublish should write the published files to the target/ folder in the current working directory.

Runtime Information

(please complete the following information)

Additional context

This makes it difficult to automate the publication process using build tools such as Make.

Note that although by default nbpublish will construct an absolute path, this path is still relative to the location of the source file. Consider a simple example use-case where we want files to be written to the directory target/, relative to the source files, instead of the default converted/. The only way to achieve this without relative paths currently is to specify the absolute path of the project, thus creating additional (but potentially unnecessary) configuration maintenance.

Logging

(base) sphelps@sphelps-OptiPlex-9010:~/vcs/teaching/high-frequency/slides/bayes-slides$ nbpublish -log debug -f slides_ipypublish_all bayes-slides.ipynb -o ./
INFO:ipypublish:started ipypublish v0.10.10 at Tue Nov 19 12:03:32 2019
INFO:ipypublish:logging to: ./bayes-slides.nbpub.log
INFO:ipypublish:running for ipynb(s) at: bayes-slides.ipynb
INFO:ipypublish:with conversion configuration: slides_ipypublish_all
INFO:nbmerge:Reading notebook
DEBUG:ipypublish:notebooks meta path: bayes-slides.ipynb
INFO:ipypublish:finding conversion configuration: slides_ipypublish_all
INFO:ipypublish:loading conversion configuration
INFO:ipypublish:creating exporter
INFO:ipypublish:creating template and loading filters
DEBUG:template:overwrite keys: []
DEBUG:template:overwrite keys: []
DEBUG:template:overwrite keys: []
DEBUG:template:overwrite keys: []
DEBUG:template:overwrite keys: ['notebook_all']
DEBUG:template:overwrite keys: ['notebook_output', 'notebook_all', 'notebook_input_markdown', 'notebook_input_code', 'notebook_input_code_pre', 'notebook_input_code_post', 'notebook_output_text', 'notebook_output_stream_stderr', 'notebook_output_stream_stdout']
DEBUG:template:overwrite keys: ['notebook_all', 'html_body_start', 'notebook_input_markdown']
INFO:ipypublish:creating process configuration
INFO:ipypublish:running nbconvert
DEBUG:traitlets:Applying preprocessor: TagRemovePreprocessor
DEBUG:traitlets:Applying preprocessor: RegexRemovePreprocessor
DEBUG:traitlets:Applying preprocessor: coalesce_streams
DEBUG:traitlets:Applying preprocessor: CSSHTMLHeaderPreprocessor
DEBUG:traitlets:Applying preprocessor: HighlightMagicsPreprocessor
DEBUG:traitlets:Applying preprocessor: MetaDefaults
INFO:root:adding ipub defaults to notebook
DEBUG:traitlets:Applying preprocessor: SplitOutputs
INFO:root:splitting outputs into separate cells
DEBUG:traitlets:Applying preprocessor: LatexDocLinks
INFO:resolve_links:resolving external file paths in ipub metadata to: bayes-slides.ipynb
DEBUG:traitlets:Applying preprocessor: LatexDocHTML
INFO:root:processing notebook for html output in ipub metadata to: bayes-slides.ipynb
DEBUG:traitlets:Applying preprocessor: LatexTagsToHTML
INFO:root:converting latex tags to html
DEBUG:traitlets:Applying preprocessor: LatexCaptions
INFO:captions:extracting caption cells
DEBUG:traitlets:Applying preprocessor: MarkdownSlides
INFO:root:creating slides based on markdown and existing slide tags
DEBUG:root:No toc.base_numbering in notebook metadata; starting at 1
DEBUG:traitlets:Attempting to load template template_file
DEBUG:traitlets:    template_path: .
DEBUG:remove-trailing-space:skipping incorrect mime type: text/html
ERROR:write-text-file:the post-processor requires an absolute folder path
ERROR:nbpublish:Run Failed: the post-processor requires an absolute folder path
chrisjsewell commented 4 years ago

I'll await your PR 😀