-
Notifications
You must be signed in to change notification settings - Fork 92
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
Settings should be referenced via their CONF_XXX
name
#1103
Comments
My thoughts:
|
A quick look at the size and scope of this problem:
|
@bherlethtwo This ticket would be a good place to start at, as the work is maybe a little monotonous, but would be a quick intro to our tool chain and workflows. |
Hello, I would like to contribute to armi. This seems like a pretty straight forward issue that I could get started on. Would that be alright? |
Hi @Till223, thank you! I think that we would definitely appreciate the support on this ticket / issue and it would help clean up the code and move away from using strings for setting accessing within the code base. @john-science, any notes to add here? Is there any good way to "test" for this or enforce this that we could add or is just a style guide in the developer notes? |
This would be a great place to start! Just take one of the bullet points here and go to the file. Find all the I will be your point-of-contact on this. Probably, since it is your first time contributing to ARMI, most of the work will be getting your environment setup and installed, and learning our GitHub workflows (opening a PR, etc). Don't worry if your PR has a lot of back-and-forth chatter and requested updates, it happens to EVERYONE. People are just trying to be careful and thorough. Thanks! |
There isn't any standard practice for ensure tight use of string constants, no. But once we get the items in this bullet list solved, we will probably add a note in the PR docs or the Dev docs. |
Alright, I will start working on this then, thanks for all the pointers! If I have any trouble with the setup I'll message you directly @john-science
Couldn't you use a github action to check for this? |
Maybe a regex check could be used in the code base as a high level unit test within an ARMI application? Thanks @john-science and @Till223! |
I fully acknowledge that it is more appropriate to use the defined constants than the literal strings throughout the codebase. I've been bitten by bugs from typos in the setting name. And of course, it's possible to miss some instances of the string when the name of a setting is updated. So there are plenty of benefits, as stated above. So, yes, we should absolutely do this. But I do want to give voice to the other side for a minute, just to put it out there. Many ARMI developers are also ARMI users. ARMI users usually know the string names of all the settings that they need to use in whatever code they're developing. Nobody knows off the top of their head the Again, I still think it's the right direction, but I would contend that it's not a clear, no-brainer decision. |
@mgjarrett I definitely know what you're referring to with your comment. I think that issue typically might arise when there is a discrepancy between the string name and the CONF name. Like a setting I think if we were rigorous about translating the setting string names into those CONF variables, there would be no (or less) confusion. |
@mgjarrett I mean, you might not know the I think the only real concern I have about implementing the above is we might accidentally create some import loops, by adding so many |
@mgjarrett quick shameless plug for vscode here. If you use the |
now that these are more widely used we need to update our internal repos to use confs also. Before it was 95+% of the time you would grep for the string and it would find all instances. . now its 50/50 depending on if its in the framework or not |
Thanks @Till223 ! |
When we define settings, we almost always go through the trouble of defining its name with a special module-level variable of a particular convention. See, for instance:
armi/armi/settings/fwSettings/globalSettings.py
Lines 34 to 121 in 53ae82e
In theory this should make it easy for us to change the variable name and have that permeated throughout the whole repo automatically. However, all around the codebase people seem to grab settings from the
cs
via the setting's actual name. Just a random example:armi/armi/operators/settingsValidation.py
Lines 274 to 279 in 53ae82e
We should instead always be pulling from the
cs
using theCONF_XXX
variables. This means extra imports, yes, but not doing this has caused bugs in the past and is sure to do so again in the future.The text was updated successfully, but these errors were encountered: