-
Notifications
You must be signed in to change notification settings - Fork 492
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[feature] Add a main script to print neuralprophet version (#974)
* add a main script to run python -m neuralprophet and print version * rewrite main cli with proper argument parsing * add test case for cli to improve test coverage * fix isort warnings * improve test case and wrap code in function * Rename -v to -V Co-authored-by: Kevin Chen <[email protected]>
- Loading branch information
1 parent
af98e9d
commit 9237bfd
Showing
2 changed files
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
""" | ||
Invokes neuralprophet when module is run as a script. | ||
""" | ||
import argparse | ||
|
||
from neuralprophet._version import __version__ | ||
|
||
|
||
def parse_args(args=None): | ||
parser = argparse.ArgumentParser(description="NeuralProphet") | ||
parser.add_argument("-V", "--version", action="version", version="%(prog)s " + __version__) | ||
return parser.parse_args(args) | ||
|
||
|
||
if __name__ == "__main__": | ||
parse_args() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import pytest | ||
|
||
from neuralprophet.__main__ import parse_args | ||
from neuralprophet._version import __version__ | ||
|
||
|
||
def test_main_file(capsys): | ||
with pytest.raises(SystemExit) as exit_info: | ||
parse_args(["--version"]) | ||
|
||
out, _ = capsys.readouterr() | ||
assert exit_info.value.code == 0 | ||
assert __version__ in out |