Skip to content

Commit

Permalink
move version to function
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanklut committed Nov 14, 2023
1 parent 43f1ead commit 4897cb7
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions core/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,17 @@ def setup_logging(cfg: Optional[CfgNode] = None, save_log: bool = True) -> loggi
return logger


def get_git_hash() -> str:
version_path = Path("version_info")

if version_path.is_file():
with version_path.open(mode="r") as file:
git_hash = file.read()
else:
git_hash = subprocess.check_output(["git", "rev-parse", "HEAD"], cwd=Path(__file__).resolve().parent).strip().decode()
return git_hash


# TODO Replace with LazyConfig
def setup_cfg(args, cfg: Optional[CfgNode] = None) -> CfgNode:
"""
Expand Down Expand Up @@ -89,12 +100,7 @@ def setup_cfg(args, cfg: Optional[CfgNode] = None) -> CfgNode:

version_path = Path("version_info")

if version_path.is_file():
with version_path.open(mode="r") as file:
git_hash = file.read()
else:
git_hash = subprocess.check_output(["git", "rev-parse", "HEAD"], cwd=Path(__file__).resolve().parent).strip().decode()
cfg.LAYPA_GIT_HASH = git_hash
cfg.LAYPA_GIT_HASH = get_git_hash()

cfg.CONFIG_PATH = str(Path(args.config).resolve())

Expand Down

0 comments on commit 4897cb7

Please sign in to comment.