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

Errors when parsing singularity definitions with comments before bootstrap line #180

Closed
StopMotionCuber opened this issue Sep 13, 2021 · 2 comments · Fixed by #181
Closed

Comments

@StopMotionCuber
Copy link

StopMotionCuber commented Sep 13, 2021

Expected Behavior

When parsing a singularity definition with comments before the bootstrap line, the file should be successfully parsed

Actual Behavior

The parsing throws an UnboundLocalError: local variable 'comments' referenced before assignment

Steps to Reproduce

  1. Create a definition file with the following content:
# Minimal Example - This comment line is important for reproduction purposes

Bootstrap: docker
From: ubuntu:16.04
  1. Start a python interpreter in that directory, with spython installed
  2. Execute
from spython.main.parse.parsers import SingularityParser
SingularityParser("minimal.def")

in that directory

Context

  • Operating System: Arch Linux
  • singularity version: not installed
  • spython version: 0.1.15
  • python version: 3.9.7

Failure Logs

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "[redacted]/venv/lib/python3.9/site-packages/spython/main/parse/parsers/singularity.py", line 30, in __init__
    super(SingularityParser, self).__init__(filename, load)
  File "[redacted]/venv/lib/python3.9/site-packages/spython/main/parse/parsers/base.py", line 56, in __init__
    self.parse()
  File "[redacted]/venv/lib/python3.9/site-packages/spython/main/parse/parsers/singularity.py", line 41, in parse
    self.load_recipe()
  File "[redacted]/venv/lib/python3.9/site-packages/spython/main/parse/parsers/singularity.py", line 333, in load_recipe
    elif stripped.startswith("#") and stripped not in comments:
UnboundLocalError: local variable 'comments' referenced before assignment

Possible Fix

https://github.com/singularityhub/singularity-cli/blob/master/spython/main/parse/parsers/singularity.py#L318
That comments definition could to be repeated somewhere above

@vsoch
Copy link
Member

vsoch commented Sep 13, 2021

Oh this is easy to fix! I'll get a PR in for you at the end of the work day. Thanks for pointing out the issue!

@vsoch
Copy link
Member

vsoch commented Sep 14, 2021

@StopMotionCuber would you care to review? #181

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants