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

Update the EntryPoint class to provide user feedback on required positional arguments #922

Merged
merged 14 commits into from
Oct 10, 2022

Conversation

jakehader
Copy link
Member

@jakehader jakehader commented Oct 5, 2022

Description

Update the entry point class to provide the settings file as an required position argument when a user requests the help menu. Additionally, add a try/except around adding a new argument from case settings to handle duplicate entries more robustly rather than requiring exclusion of settings like verbosity and branchVerbosity.

@opotowsky update:

In getting the unit tests to work, a few more changes were made.

  1. the reloadDBName setting was removed from armiRun.yaml. This ended up not being necessary after other fixes were made, but it is only used for 3 tests (in bookkeeping/db).
  2. I altered the above-mentioned test setup there to have custom settings to handle the deletion. Side note: ARMI should be able to handle settings that are files that do not yet exist, but it can't right now. Seemed ideal to keep the base case for all unit tests simple.
  3. the CLI for checkInputs needed some love. There are minor code updates, deletions, and some small updates to the tests.

Checklist

  • This PR has only one purpose or idea.
  • Tests have been added/updated to verify that the new/changed code works.
  • The release notes (location doc/release/0.X.rst) are up-to-date with any bug fixes or new features.
  • The documentation is still up-to-date in the doc folder.
  • The dependencies are still up-to-date in setup.py.

position argument when a user requests the help menu. Additionally,
add a try/except around adding a new argument from case settings to
handle duplicate entries more robustly rather than requiring exclusion
of settings like `verbosity` and `branchVerbosity`.
@opotowsky
Copy link
Member

For the life of me, I couldn't invoke any of the clone commands in test_runEntryPoint.py

This update allows me to.

THANK YOU!!!!!!!!!!!!!!!!

@opotowsky
Copy link
Member

I'll push up some unit test fixes to this branch

@opotowsky opotowsky linked an issue Oct 6, 2022 that may be closed by this pull request
@opotowsky opotowsky added the enhancement New feature or request label Oct 6, 2022
Having both a settings file and patterns arg is both redunant and causes
unreliable use issues. Since only patterns was used in invoke, decided
to remove the settingsArgument as optional. I also removed the
sys.exit(), since there is no need that I can think of to do this. The
armi unit test settings file, e.g., fails this check (with can start =
UNKNOWN).
For some reason, this makes parse_args go bonkers (on my machine, at
least). So this seemed like an easy resolution, even if I don't
understand it.
armi/cli/checkInputs.py Outdated Show resolved Hide resolved
This is only needed for 3 tests, and it was causing some annoying
failures on the check-inputs entry point test (although I fixed it
separately by rejecting the notion that there needed to be a
sys.exit()).
@@ -86,7 +86,9 @@ def test_diffResultsBasic(self):
def test_compareDatabaseDuplicate(self):
"""end-to-end test of compareDatabases() on a photocopy database"""
# build two super-simple H5 files for testing
o, r = test_reactors.loadTestReactor(TEST_ROOT)
o, r = test_reactors.loadTestReactor(
TEST_ROOT, customSettings={"reloadDBName": "reloadingDB.h5"}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love it!

self.assertIn("input is self consistent", mock._outputStream)


class TestCloneArmiRunCommandBatch(unittest.TestCase):
def test_cloneArmiRunCommandBatchBasics(self):
ca = CloneArmiRunCommandBatch()
ca.addOptions()
ca.parse_args(["--additional-files", "test"])
ca.parse_args([ARMI_RUN_PATH, "--additional-files", "test"])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively, this one needs to be a real file path

@@ -237,7 +271,7 @@ class TestRunEntryPoint(unittest.TestCase):
def test_runEntryPointBasics(self):
rep = RunEntryPoint()
rep.addOptions()
rep.parse_args([])
rep.parse_args([ARMI_RUN_PATH])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, needs to be real since the settingsArgument is required here too

@opotowsky
Copy link
Member

opotowsky commented Oct 7, 2022

The coverage drop looks like a fluke to me....
image

Nevermind....

@john-science
Copy link
Member

@opotowsky But I see you fixed the coverage issue! Awesome!

@opotowsky opotowsky merged commit f4bb14b into main Oct 10, 2022
@opotowsky opotowsky deleted the entrypoint branch October 10, 2022 15:23
scottyak pushed a commit to scottyak/armi that referenced this pull request Oct 27, 2022
…tional arguments (terrapower#922)

* Update the entry point class to provide the settings file as an required
position argument when a user requests the help menu. Additionally,
add a try/except around adding a new argument from case settings to
handle duplicate entries more robustly rather than requiring exclusion
of settings like `verbosity` and `branchVerbosity`.

* Suppress the printing of all possible settings in clone CLI

* There are 18 entry points!

* Make changes to checkInputs CLI and tests

Having both a settings file and patterns arg is both redundant and causes
unreliable use issues. Since only patterns was used in invoke, decided
to remove the settingsArgument as optional. I also removed the
sys.exit(), since there is no need that I can think of to do this. The
armi unit test settings file, e.g., fails this check (with can start =
UNKNOWN).

* Move settings arg processing to not be first (nargs='*' behavior means this can't be first in the list)

* Minor docstring add

* Remove reloadDBName setting from armiRun.yaml

This is only needed for 3 tests, and it was causing some annoying
failures on the check-inputs entry point test (although I fixed it
separately by rejecting the notion that there needed to be a
sys.exit()).

* Update warning to error for checkInputs CLI

* Remove unused CLI args from checkInputs (finishing what terrapower#754 started)

* Remove update to real file because that ain't necessary

* Release Notes

Co-authored-by: Arrielle Opotowsky <c-aopotowsky@terrapower.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Get all options from entry points without parsing arguments
4 participants