Skip to content
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

Posts without metadata make nikola fail with cryptic error. #2771

Closed
SnoopJ opened this issue May 17, 2017 · 2 comments
Closed

Posts without metadata make nikola fail with cryptic error. #2771

SnoopJ opened this issue May 17, 2017 · 2 comments

Comments

@SnoopJ
Copy link

SnoopJ commented May 17, 2017

When building a Nikola site with the ipynb compiler enabled, any notebooks not created or imported using nikola new_post will raise a ValueError from because of the missing metadata, e.g.:

ValueError: Invalid date '' in file posts/notes-on-meshgrid-ordering.ipynb

This is caused by the return of an empty dictionary in read_metadata().

I understand that this can be worked around with nikola new_post -i and creation of a separate metadata file, but the workflow I'd personally prefer when using Nikola is to author my notebooks in a way that is entirely Nikola-agnostic. Drawing inspiration from what's done for page metadata, I kludged together a solution in ipynb.py that works for my use case.

After speaking with @Kwpolska a little in Freenode #python, it appears this is partially a design decision, but I think it's pretty inelegant to just propagate the ValueError to the user.

For my workflow, my ideal user story would be:

I place an IPython notebook in posts/ and run nikola build
No Nikola metadata is found
The build script prompts me to enter the same info nikola new_post would ask for
After completing this process, the build script continues as normal

I'm happy to maintain my own version of the ipynb compiler for my personal use, but I figured I'd find out if this is a feature that would add value to the project. If not, then at the very least it seems appropriate to point the user to the new_post command when this error is raised.

@ralsina
Copy link
Member

ralsina commented May 17, 2017

Build scripts are really not meant to be interactive. A better error message is indeed a good idea.

Also, this is not really ipynb specific, I am changing the title to reflect that.

@ralsina ralsina self-assigned this May 17, 2017
@ralsina ralsina changed the title .ipynb files not created or imported with new_post fail on build Posts without metadata make nikola fail with cryptic error. May 17, 2017
ralsina pushed a commit that referenced this issue May 18, 2017
@ralsina
Copy link
Member

ralsina commented May 18, 2017

That branch mentioned above changes from that ... thing to this:

(nikola)ralsina@onalap1040 ~/P/n/foo> nikola build
Scanning posts.[2017-05-18T15:09:43Z] ERROR: Nikola: Missing date in file posts/foo.rst
[2017-05-18T15:09:43Z] ERROR: scan_posts: Error reading post posts/foo.rst
[2017-05-18T15:09:43Z] ERROR: Nikola: Error reading timeline
[2017-05-18T15:09:43Z] ERROR: Nikola: Error loading tasks

Kwpolska added a commit that referenced this issue May 21, 2017
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
ralsina pushed a commit that referenced this issue May 21, 2017
…2782)

* Show last exception text and NIKOLA_DEBUG explanation (#2774 #2771)

Signed-off-by: Chris Warrick <kwpolska@gmail.com>

* more friendly → friendlier

Signed-off-by: Chris Warrick <kwpolska@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants