Unverified Commit ed1b96d5 authored by Lei Wang's avatar Lei Wang Committed by GitHub
Browse files

[Version] Keep local commit id as it somehow help with debugging (#697)

* [Enhancement] Disable cache and append git commit ID to version in tilelang (#688)

* Disabled caching in quickstart example for improved performance.
* Added a function to retrieve the current git commit ID and appended it to the version string if not already present, enhancing version tracking and debugging capabilities.

* revert quickstart
parent 17fafc1b
...@@ -24,5 +24,24 @@ else: ...@@ -24,5 +24,24 @@ else:
with open(version_file_path, "r") as version_file: with open(version_file_path, "r") as version_file:
__version__ = version_file.read().strip() __version__ = version_file.read().strip()
def get_git_commit_id() -> Union[str, None]:
"""Get the current git commit hash by running git in the current file's directory."""
try:
return subprocess.check_output(['git', 'rev-parse', 'HEAD'],
cwd=os.path.dirname(os.path.abspath(__file__)),
stderr=subprocess.DEVNULL,
encoding='utf-8').strip()
except subprocess.SubprocessError:
return None
# Append git commit hash to version if not already present
# NOTE(lei): Although the local commit id cannot capture locally staged changes,
# the local commit id can help mitigate issues caused by incorrect cache to some extent,
# so it should still be kept.
if "+" not in __version__ and (commit_id := get_git_commit_id()):
__version__ = f"{__version__}+{commit_id}"
# Define the public API for the module # Define the public API for the module
__all__ = ["__version__"] __all__ = ["__version__"]
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment