run_resfinder.py aborts on git error
Running run_resfinder.py
fails with this exception:
Traceback (most recent call last):
File "/usr/src/ext/resfinder/run_resfinder.py", line 34, in get_git_tag
subprocess.check_output(
File "/opt/conda/lib/python3.9/subprocess.py", line 424, in check_output
return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
File "/opt/conda/lib/python3.9/subprocess.py", line 528, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['git', 'describe', '--tags', '--abbrev=0']' returned non-zero exit status 128.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/src/ext/resfinder/run_resfinder.py", line 181, in <module>
parser.add_argument("-v", "--version", action="version", version=get_git_tag(),
File "/usr/src/ext/resfinder/run_resfinder.py", line 45, in get_git_tag
raise Exception(str(exc_info.output))
Exception: b'fatal: not a git repository (or any of the parent directories): .git\n'
This is apparently due to it calling git describe
, and failing because it is not in a git repository at runtime.
Scripts shouldn't assume they are in a git repository when invoked. This is the case in the development environment, but nowhere else. Once a python module is installed (pip, setup.py), or deployed in a Docker container or in a Conda env, the .git
subdirectory won’t be there.
I’d suggest sticking to the standard way to do this: set a variable __version__ = x.y.z
in the module’s __init.py__
, so it is available globally, and remember to update this when you release (you could even automate this in a commit hook).
PS: note that ResFinder’s .git
history is nearly 200MB(!), so you really don’t want that in a Docker container.
Comments (4)
-
-
-
assigned issue to
-
assigned issue to
-
- changed status to resolved
Resolved in version 4.2.1. ResFinder can now be installed via pip and version number is stored in init as suggested.
-
Issue
#90was marked as a duplicate of this issue. - Log in to comment
Hi Marco
It’s a really good point.
I’ll look into creating proper releases of our tools (i.e. getting them into pypi). However, we are a small team, so a little patience will be required
Best,
Rolf