Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add -v to get dptb version, and update the version.py to load version number and git version #158

Merged
merged 13 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions dptb/entrypoints/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
from dptb.utils.loggers import set_log_handles
from dptb.utils.config_check import check_config_train
from dptb.entrypoints.collectskf import skf2pth
from dptb.version import get_version

try:
version = get_version()
except:
version = "unknown"

def get_ll(log_level: str) -> int:
"""Convert string to python logging level.
Expand Down Expand Up @@ -41,14 +47,17 @@ def main_parser() -> argparse.ArgumentParser:
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
)

parser.add_argument('-v', '--version',
action='version', version=f'%(prog)s {version}', help="show the DeepTB's version number and exit")

subparsers = parser.add_subparsers(title="Valid subcommands", dest="command")

# log parser
parser_log = argparse.ArgumentParser(
add_help=False, formatter_class=argparse.ArgumentDefaultsHelpFormatter
)
parser_log.add_argument(
"-v",
"-ll",
"--log-level",
choices=["DEBUG", "3", "INFO", "2", "WARNING", "1", "ERROR", "0"],
default="INFO",
Expand All @@ -57,7 +66,7 @@ def main_parser() -> argparse.ArgumentParser:
)

parser_log.add_argument(
"-l",
"-lp",
"--log-path",
type=str,
default=None,
Expand Down
18 changes: 16 additions & 2 deletions dptb/version.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
import os
import subprocess as sp
import toml, os

MAJOR = 0
MINOR = 1
MICRO = 0
ISRELEASED = False
VERSION = '%d.%d.%d' % (MAJOR, MINOR, MICRO)
# VERSION = '%d.%d.%d' % (MAJOR, MINOR, MICRO)

entrypoint_path = os.path.dirname(os.path.abspath(__file__))
pyproject_path = os.path.join(entrypoint_path, "..", "pyproject.toml")

with open(pyproject_path, "r") as f:
pyproject = toml.load(f)
VERSION = pyproject["tool"]["poetry"]["version"]


# Return the git revision as a string
# taken from numpy/numpy
Expand Down Expand Up @@ -59,4 +68,9 @@ def get_version(build_version=False):
date = dt.date.strftime(dt.datetime.now(), "%Y%m%d%H%M%S")
return VERSION + ".dev" + date
else:
return VERSION + ".dev0+" + GIT_REVISION[:7]
return VERSION + ".dev0+" + GIT_REVISION[:7]

if __name__ == "__main__":
GIT_REVISION = _get_git_version()
print(GIT_REVISION)
print(get_version())
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ torch_scatter = "2.1.2"
torch_geometric = ">=2.4.0"
opt-einsum = "3.3.0"
h5py = "3.7.0"
toml="*"


[tool.poetry.group.dev.dependencies]
Expand All @@ -50,6 +51,7 @@ torch_scatter = "2.1.2"
torch_geometric = ">=2.4.0"
opt-einsum = "3.3.0"
h5py = "3.7.0"
toml="*"


[tool.poetry.group.3Dfermi]
Expand Down