Skip to content

Commit

Permalink
Merge pull request #40 from OpenBioSim/feature_version
Browse files Browse the repository at this point in the history
Improve versioning
  • Loading branch information
lohedges authored Apr 9, 2024
2 parents 32a8205 + 9954b82 commit 91348d8
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 11 deletions.
27 changes: 27 additions & 0 deletions src/somd2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,30 @@
from loguru import logger as _logger

from . import runner

# Store the somd2 version.
from ._version import __version__

# Store the sire version.
from sire import __version__ as _sire_version
from sire import __revisionid__ as _sire_revisionid

# Determine whether we're being run interactively.
try:
_shell = get_ipython().__class__.__name__
if _shell == "ZMQInteractiveShell":
_is_interactive = True # Jupyter notebook or qtconsole
elif _shell == "TerminalInteractiveShell":
_is_interactive = True # Terminal running IPython
else:
_is_interactive = False # Other type (?)
del _shell
except NameError:
_is_interactive = False # Probably standard Python interpreter

if not _is_interactive:
# Log the versions of somd2 and sire.
_logger.info(f"somd2 version: {__version__}")
_logger.info(f"sire version: {_sire_version}+{_sire_revisionid}")

del _is_interactive
11 changes: 0 additions & 11 deletions src/somd2/app/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,6 @@ def cli():

from somd2.io import yaml_to_dict

# Store the somd2 version.
from somd2._version import __version__

# Store the sire version.
from sire import __version__ as sire_version
from sire import __revisionid__ as sire_revisionid

# Generate the parser.
parser = Config._create_parser()

Expand Down Expand Up @@ -86,10 +79,6 @@ def cli():
# Instantiate a Config object to validate the arguments.
config = Config(**args)

# Log the versions of somd2 and sire.
_logger.info(f"somd2 version: {__version__}")
_logger.info(f"sire version: {sire_version}+{sire_revisionid}")

# Instantiate a Runner object to run the simulation.
runner = Runner(system, config)

Expand Down
4 changes: 4 additions & 0 deletions src/somd2/runner/_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -938,12 +938,16 @@ def _run(sim, is_restart=False):
raise
self._sim._cleanup()

from somd2 import __version__, _sire_version, _sire_revisionid

# Write final dataframe for the system to the energy trajectory file.
# Note that sire s3 checkpoint files contain energy trajectory data, so this works even for restarts.
_ = _dataframe_to_parquet(
df,
metadata={
"attrs": df.attrs,
"somd2 version": __version__,
"sire version": f"{_sire_version}+{_sire_revisionid}",
"lambda": str(lambda_value),
"lambda_array": self._lambda_values,
"lambda_grad": lambda_grad,
Expand Down

0 comments on commit 91348d8

Please sign in to comment.