Skip to content

Commit

Permalink
feat: add -v to get dptb version, and update the version.py to load v…
Browse files Browse the repository at this point in the history
…ersion number and git version (#158)

* Refactor plotting code in dftb2nnsk.py

* refactor(nnsk): Refactor NNSK class in nnsk.py to fix push_decay method and update push options

* update saver.py to save ckpt with name of ovlp

* fix: update nnsk from reference and change the sign of ovp_thr

* update saver.py

* update mos2 example

* Update test_sktb.py with new model weights and fix init_model path in test_md

* docs: Update dftb.md with hBN model training steps and fix formatting

* Refactor main.py to add version flag and handle unknown version

* Update pyproject.toml to add toml dependency
  • Loading branch information
QG-phy authored Apr 30, 2024
1 parent 0d6aec3 commit 32e1f4d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
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

0 comments on commit 32e1f4d

Please sign in to comment.