Skip to content

Commit

Permalink
Report lib SHA (#72)
Browse files Browse the repository at this point in the history
  • Loading branch information
IlyasMoutawwakil authored Oct 19, 2023
1 parent 12da391 commit 36b83d7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
16 changes: 16 additions & 0 deletions optimum_benchmark/env_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,19 @@ def get_gpus():
gpus = ["GPUs not available"]

return gpus


def get_git_revision_hash(path: Optional[str]) -> str:
"""
Returns the git commit SHA for the git repository in `path`.
"""
if path is None:
return None
else:
try:
return subprocess.check_output(["git", "rev-parse", "HEAD"], cwd=path).decode("ascii").strip()
except Exception as e:
LOGGER.warning(
f"Asked to log the git commit SHA for {path}, but it does not appear to be a git repository: {e}"
)
return None
6 changes: 5 additions & 1 deletion optimum_benchmark/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from .backends.text_generation_inference.config import TGIConfig
from .benchmarks.inference.config import InferenceConfig
from .benchmarks.training.config import TrainingConfig
from .env_utils import get_cpu, get_cpu_ram_mb, get_gpus
from .env_utils import get_cpu, get_cpu_ram_mb, get_git_revision_hash, get_gpus
from .import_utils import (
accelerate_version,
diffusers_version,
Expand Down Expand Up @@ -66,9 +66,13 @@ class ExperimentConfig:
environment: Dict = field(
default_factory=lambda: {
"optimum_version": optimum_version(),
"optimum_commit": get_git_revision_hash(os.environ.get("OPTIMUM_PATH")),
"transformers_version": transformers_version(),
"transformers_commit": get_git_revision_hash(os.environ.get("TRANSFORMERS_PATH")),
"accelerate_version": accelerate_version(),
"accelerate_commit": get_git_revision_hash(os.environ.get("ACCELERATE_PATH")),
"diffusers_version": diffusers_version(),
"diffusers_commit": get_git_revision_hash(os.environ.get("DIFFUSERS_PATH")),
"python_version": platform.python_version(),
"system": platform.system(),
"cpu": get_cpu(),
Expand Down

0 comments on commit 36b83d7

Please sign in to comment.