Conversation
|
It should be possible to access this information directly with BTW the current link of the commit is pointing to a non-existing page: This site is currently running IOP4 dipol_exceptions @ v1.1.2-12-g9d12107. |
61d5c77 to
5f3ac04
Compare
morcuended
left a comment
There was a problem hiding this comment.
Looks good for now. I'll open a new issue as reminder to explore this:
It should be possible to access this information directly with iop4.version which follows the commit hashes for the dev versions. And actually, we should try to stick to released tagged versions for the production versions installed.
a3b9847 to
5133fea
Compare
9c5eb31 to
0378af9
Compare
There was a problem hiding this comment.
Pull request overview
This pull request addresses an issue where git commands fail in non-editable package installations (e.g., pip-installed packages) by wrapping git subprocess calls in a try-except block. When git is unavailable or the .git directory is missing, the code now gracefully falls back to "Unknown" values instead of raising an exception.
Changes:
- Wrapped git subprocess calls in try-except block with fallback values
- Added error logging when git information cannot be retrieved
- Set GIT_COMMIT_HASH, GIT_BRANCH, and GIT_DESCRIBE to "Unknown" on failure
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| try: | ||
| GIT_COMMIT_HASH = subprocess.check_output(['git', 'rev-parse', 'HEAD'], cwd=os.path.dirname(os.path.realpath(__file__))).decode('ascii').strip() | ||
| GIT_BRANCH = subprocess.check_output(['git', 'rev-parse', '--abbrev-ref', 'HEAD'], cwd=os.path.dirname(os.path.realpath(__file__))).decode('ascii').strip() | ||
| GIT_DESCRIBE = subprocess.check_output(['git', 'describe', '--always'], cwd=os.path.dirname(os.path.realpath(__file__))).decode('ascii').strip() | ||
| except Exception as e: | ||
| logger.error(f"Error getting git info: {e}") | ||
| GIT_COMMIT_HASH = "Unknown" | ||
| GIT_BRANCH = "Unknown" | ||
| GIT_DESCRIBE = "Unknown" |
There was a problem hiding this comment.
The same git availability issue exists in docs/conf.py (lines 2-4) but hasn't been fixed there. The git commands in that file will fail in the same non-editable install scenario. Consider applying the same try-except wrapper pattern to docs/conf.py for consistency.
There was a problem hiding this comment.
@copilot open a new pull request to apply changes based on this feedback
No description provided.