ReScience / template

Template for article submission

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

yaml-to-latex.py error: AttributeError: 'str' object has no attribute 'name'

weinman opened this issue · comments

I am trying to use the convenient script for generating the metadata.tex file, but I get an error.

Host Platforms: macOS 10.14.6 and Ubuntu 18.04
Python: 3.7 (both cases)
PyYAML-5.3.1 pyaml-20.4.0

Here is the command invoked: ./yaml-to-latex.py -i metadata.yaml -o metadata.tex

and the error:

Traceback (most recent call last):
  File "./yaml-to-latex.py", line 88, in <module>
    content = generate_latex_metadata(filename_in, article)
  File "./yaml-to-latex.py", line 49, in generate_latex_metadata
    "".format(filename=filename, _=article, abstract=abstract))
AttributeError: 'str' object has no attribute 'name'

(Although I don't think it's the source of the problem, I note it looks like the version on Overleaf differs from the current version of the template. Whereas I already burned over an hour trying to get the template to work on a local system (an failed) and opted instead to go to Overleaf, this seems like an unfortunate place to have outdated code.)

Pointers welcome! The overhead to submission so far has been quite steep.

Update: The proximal cause was a typo somewhere in my own yaml file edit, though I'm not sure where (I reverted and am now making line by line edits of the original, which I later determined to have successfully worked—something I should have tried originally!).

I suppose the lesson is better error checking and reporting in the python script might be helpful.

I agree. Did you find what was the typo (might be useful for debug)?

I am fairly certain I'd forgotten the comma between the author Id and the asterisk indicating the corresponding author.

Writing

 authors:
  - name: Jerod Weinman
    affiliations: 1*

instead of

 authors:
  - name: Jerod Weinman
    affiliations: 1,*

produces the same error

Ok thanks. I need to make this script a bit more robust.

As a datapoint: same error if there's a space between a comma and an asterisk

    affiliations: 1, *

Not sure if related: there's a warning (I'm still on python 3.5, not sure if it matters)

$ make
./yaml-to-latex.py -i metadata.yaml -o metadata.tex
/home/br/sweethome/proj/10yr_repro/paper/article.py:171: YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details.
  document = yaml.load(data)
latexmk -pdf -pdflatex="xelatex -interaction=nonstopmode" -use-make article.tex
Latexmk: This is Latexmk, John Collins, 1 January 2015, version: 4.41.

I got the same warning, but regardless of whether there was a space. I assume this is a general deprecation warning for something used in the script wrt to the client (i.e., you and me) version of the PyYAML library used.

Also, if this script is being worked on, the pyyaml requirement would be good to document somewhere.

@ev-br Good point. I need to work on this script. It may have to wait for the end of the challenge because we now have a lof of entry to review.

I can volunteer (bandwidth permitting etc), also definitely after finishing up my piece for the challenge.