executablebooks / cookiecutter-jupyter-book

Cookiecutter template for a simple jupyter book
https://executablebooks.github.io/cookiecutter-jupyter-book/
BSD 3-Clause "New" or "Revised" License
140 stars 53 forks source link

Unable to use cookiecutter template #15

Closed hdoupe closed 3 years ago

hdoupe commented 3 years ago

Describe the bug

I tried to use the cookie cutter command, but there was a key error when Jupyter Book tried to write the files.

To Reproduce

$ jupyter-book create docs/ --cookiecutter
You've downloaded /home/hankdoupe/.cookiecutters/cookiecutter-jupyter-book before. Is it okay to delete and re-download it? [yes]: yes
author_name [Captain Jupyter]: Hank Doupe   
github_username [hankdoupe]: hdoupe
book_name [my-book]: docs
book_slug [docs]: docs
book_short_description [This cookiecutter creates a simple boilerplate for a Jupyter Book.]: Developer documentation for Compute Studio.
version ['0.1.0']: 
Select open_source_license:
1 - MIT license
2 - BSD license
3 - ISC license
4 - Apache Software License 2.0
5 - GNU General Public License v3
Choose from 1, 2, 3, 4, 5 [1]: 5
Select include_ci:
1 - github
2 - gitlab
3 - no
Choose from 1, 2, 3 [1]: 1
Traceback (most recent call last):
  File "/home/hankdoupe/miniconda3/lib/python3.8/site-packages/cookiecutter/generate.py", line 352, in generate_files
    generate_file(
  File "/home/hankdoupe/miniconda3/lib/python3.8/site-packages/cookiecutter/generate.py", line 175, in generate_file
    rendered_file = tmpl.render(**context)
  File "/home/hankdoupe/miniconda3/lib/python3.8/site-packages/jinja2/environment.py", line 1090, in render
    self.environment.handle_exception()
  File "/home/hankdoupe/miniconda3/lib/python3.8/site-packages/jinja2/environment.py", line 832, in handle_exception
    reraise(*rewrite_traceback_stack(source=source))
  File "/home/hankdoupe/miniconda3/lib/python3.8/site-packages/jinja2/_compat.py", line 28, in reraise
    raise value.with_traceback(tb)
  File "./LICENSE", line 82, in top-level template code
jinja2.exceptions.UndefinedError: 'collections.OrderedDict object' has no attribute 'project_short_description'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/hankdoupe/miniconda3/bin/jupyter-book", line 8, in <module>
    sys.exit(main())
  File "/home/hankdoupe/.local/lib/python3.8/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/home/hankdoupe/.local/lib/python3.8/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/home/hankdoupe/.local/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/hankdoupe/.local/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/hankdoupe/.local/lib/python3.8/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/home/hankdoupe/miniconda3/lib/python3.8/site-packages/jupyter_book/commands/__init__.py", line 286, in create
    book = cookiecutter(cc_url, output_dir=Path(path_book))
  File "/home/hankdoupe/miniconda3/lib/python3.8/site-packages/cookiecutter/main.py", line 101, in cookiecutter
    result = generate_files(
  File "/home/hankdoupe/miniconda3/lib/python3.8/site-packages/cookiecutter/generate.py", line 359, in generate_files
    raise UndefinedVariableInTemplate(msg, err, context)
cookiecutter.exceptions.UndefinedVariableInTemplate: Unable to create file 'LICENSE'. Error message: 'collections.OrderedDict object' has no attribute 'project_short_description'. Context: OrderedDict([('cookiecutter', OrderedDict([('author_name', 'Hank Doupe'), ('github_username', 'hdoupe'), ('book_name', 'docs'), ('book_slug', 'docs'), ('book_short_description', 'Developer documentation for Compute Studio.'), ('version', "'0.1.0'"), ('open_source_license', 'GNU General Public License v3'), ('include_ci', 'github'), ('_template', 'gh:executablebooks/cookiecutter-jupyter-book')]))])

Expected behavior

No errors.

$ jupyter-book build mybook
ERROR ...

Environment

$ jupyter-book --version
Jupyter Book: 0.8.2
MyST-NB: 0.10.1
Sphinx Book Theme: 0.0.37
MyST-Parser: 0.12.10
Jupyter-Cache: 0.4.1
NbClient: 0.5.0
(base) ~/compute-studio 
$ python --version
Python 3.8.1
(base) ~/compute-studio 

OS: Ubuntu

Thanks for taking a look at this! I'm just getting started with Jupyterbooks and the cookie cutter command seemed like the right way to template everything out!

welcome[bot] commented 3 years ago

Thanks for opening your first issue here! Engagement like this is essential for open source projects! :hugs:
If you haven't done so already, check out EBP's Code of Conduct. Also, please try to follow the issue template as it helps other community members to contribute more effectively.
If your issue is a feature request, others may react to it, to raise its prominence (see Feature Voting).
Welcome to the EBP community! :tada:

chrisjsewell commented 3 years ago

thanks @hdoupe, I've transferred this over to the cookie cutter repo, so @TomasBeuzen can have a look

TomasBeuzen commented 3 years ago

Thanks both - will investigate this bug ASAP

TomasBeuzen commented 3 years ago

@hdoupe - this should be fixed now. Please try running jupyter-book create docs/ --cookiecutter again. If the issue is not resolved please post here and I'll re-open.

hdoupe commented 3 years ago

Looks great! Thanks @TomasBeuzen and @chrisjsewell!

I've been admiring all of the jupyter books docs sites that seem to be popping up everywhere and decided it was time to convert!

TomasBeuzen commented 3 years ago

Glad to hear it and thanks for reporting the bug! The core Jupyter Book team is doing a wonderful job for sure. If you're just getting started, I gave a short presentation on the key features I find useful in Jupyter Book a few months ago which you can find here, but in particular, I compiled a short list of some of my fav JB examples which might be helpful to check out, just to see what others are doing :)

chrisjsewell commented 3 years ago

@TomasBeuzen you might want to mention this in https://github.com/executablebooks/meta/issues/154

choldgraf commented 3 years ago

@TomasBeuzen amazing - thanks for continuing to help with the project <3