showyourwork / showyourwork

A workflow for reproducible and open scientific articles
https://show-your.work
MIT License
568 stars 47 forks source link

syw preprocessing fails when `\author` is passed an orchid ID #464

Open tedjohnson12 opened 3 months ago

tedjohnson12 commented 3 months ago

showyourwork version: 0.4.4.dev37+g1526059 (latest on main branch as of August 1) snakemake version: 7.15.2 Python version: 3.9.19 Minimal reproducible example:

In one of my projects I changed the author line in ms.tex \author{Author Name} to \author[0000-0000-0000-0000]{Author Name} in order to link my Orchid ID (of course, I used my actual name and ID). My project, which had successfully built previously, now gives me the following error message upon showyourwork build:

Preprocess: Setting up the workflow...
Traceback (most recent call last):
  File "/home/ted/github/vspec-paper/.snakemake/scripts/tmp0jonyj1k.preprocess.py", line 484, in <module>
    config["tree"] = get_json_tree(snakemake.input[0])
  File "/home/ted/github/vspec-paper/.snakemake/scripts/tmp0jonyj1k.preprocess.py", line 409, in get_json_tree
    free_floating_graphics = [
  File "/home/ted/github/vspec-paper/.snakemake/scripts/tmp0jonyj1k.preprocess.py", line 412, in <listcomp>
    if graphic not in config["tex_files_out"]
KeyError: 'tex_files_out'
Error in rule syw__preprocess:
    jobid: 1
    output: .showyourwork/config.json

RuleException:
CalledProcessErrorin line 98 of /home/ted/anaconda3/envs/syw/lib/python3.9/site-packages/showyourwork/workflow/rules/preprocess.smk:
Command 'set -euo pipefail;  /home/ted/anaconda3/envs/syw/bin/python /home/ted/github/vspec-paper/.snakemake/scripts/tmp0jonyj1k.preprocess.py' returned non-zero exit status 1.
  File "/home/ted/anaconda3/envs/syw/lib/python3.9/site-packages/showyourwork/workflow/rules/preprocess.smk", line 98, in __rule_4
  File "/home/ted/anaconda3/envs/syw/lib/python3.9/concurrent/futures/thread.py", line 58, in run
Exiting because a job execution failed. Look above for error message

I can't find anything in the syw docs about orchid, but I've seen examples of other projects that include IDs, so I am not sure why I am having this problem.

tedjohnson12 commented 3 months ago

Github won't allow me to upload the example, but here is what I did to reproduce the problem:

HealthyPear commented 3 months ago

This issue is the same as in #454, where it is suggested to try the fix proposed by this comment.

Can you try to see if this fixes your problem?

If yes, I'll open a PR to put this in the documentation FAQ until we find a better solution.

tedjohnson12 commented 3 months ago

Thank you! Yes, this works, however note that in order to build the article using GH actions I have to point the showyourwork-spec parameter to my own fork.

As far as long-term fixes, the string "tex_files_out" does not appear anywhere else in the repository so I am not sure what it is specifically referring to. If it is a key that is occasionally in snakemake.config depending on the project, then perhaps a solution like

if "tex_files_out" in config:
    free_floating_graphics = [
        graphic
        for graphic in free_floating_graphics
        if graphic not in config["tex_files_out"]
    ]

would work best.

Otherwise, what do you think of an improved error message? This error will arise for any image not wrapped in <FIGURE> tags in showyourwork.xml, so maybe in the case of a KeyError we point the user to both the FAQ and note that it could be caused by using \includegraphics outside of a figure environment?

thomasckng commented 2 months ago

This issue is the same as in #454, where it is suggested to try the fix proposed by this comment.

Can you try to see if this fixes your problem?

If yes, I'll open a PR to put this in the documentation FAQ until we find a better solution.

Got the same problem and fixed by the solution here temporarily.