Skip to content
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
3 changes: 3 additions & 0 deletions process/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from importlib.metadata import version

__version__ = version("process")
9 changes: 9 additions & 0 deletions process/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
from process.impurity_radiation import initialise_imprad
from process.caller import write_output_files

import process

from pathlib import Path
import os
Expand Down Expand Up @@ -191,6 +192,11 @@ def parse_args(self, args):
action="store_true",
help="Produce a filled json from --mfile arg in working dir",
)
parser.add_argument(
"--version",
action="store_true",
help="Print the version of PROCESS to the terminal",
)

# If args is not None, then parse the supplied arguments. This is likely
# to come from the test suite when testing command-line arguments; the
Expand All @@ -202,6 +208,9 @@ def parse_args(self, args):

def run_mode(self):
"""Determine how to run Process."""
if self.args.version:
print(process.__version__)
return
# Store run object: useful for testing
if self.args.varyiterparams:
self.run = VaryRun(self.args.varyiterparamsconfig, self.args.solver)
Expand Down
1 change: 1 addition & 0 deletions tests/unit/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ def test_run_mode(process_obj, monkeypatch):
# Mock the args attributes for --varyiterparams and --varyiterparamsconfig
monkeypatch.setattr(process_obj, "args", argparse.Namespace(), raising=False)
monkeypatch.setattr(process_obj.args, "varyiterparams", True, raising=False)
monkeypatch.setattr(process_obj.args, "version", False, raising=False)
monkeypatch.setattr(
process_obj.args, "varyiterparamsconfig", "file.conf", raising=False
)
Expand Down