-
Notifications
You must be signed in to change notification settings - Fork 127
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
Per-user defaults for xAH_run (aka a dotfile) #1303
Conversation
don't move the |
Yup, fixed. Any comments on the interface? If not, I'll start adding this to the other xAH_run arguments. |
@kkrizka , I've been thinking a little about this, and I want to take the opportunity to make this easier for you, actually. As it's been pretty clear, more especially so in this PR, the configurations available (their types, the default values, etc...) should be maintained in some particular list that you can directly access or use to automatically generate the dot-file config as well. Let me submit a PR to rearrange some of this for you, so that this is a bit easier to deal with. On a second note, I would encourage you to use the exact name of the argument in the config file as well, instead of using a different name, e.g. |
When #1304 is merged in, you should be able to do something like this config.add_section('slurm')
for optName,optConfig in xAODAnaHelpers.cli_options.drivers_slurm.iteritems():
config.set('slurm', optName, optConfig.get('default'))
config.read(userconfigpath)
# update the cli_options based on the read-in config file
for optName in xAODAnaHelpers.cli_options.drivers_slurm.keys():
xAODAnaHelpers.cli_options.drivers_slurm[optName]['default'] = config.get('slurm', optName)
...
...
...
xAODAnaHelpers.utils.register_on_parser(xAODAnaHelpers.cli_options.drivers_slurm, slurm) and then in portions when we build the argument parser, it should see the updated defaults. Let me know if this is a lot more preferable for your needs. |
I prefer the dotfile. It is a standard way to configure applications on Linux. |
This still uses the dotfile. |
Ok, I don't see any difference by moving all of the options to a separate file then. So go ahead. |
This way, you're not hard-coding the |
Merged in my changes. |
Also, any thoughts on using the existing dotfiles from asetup -- and adding in configurations there -- instead of creating another dotfile |
The configuration is very specific to xAH. I don't see a reason to mix its configuration with asetup, which is a separate application. |
Additional, how do we feel about using something like https://github.com/theskumar/python-dotenv? We can package it up with xAH as part of a CMake installation (and it's relatively small) and might be perfect for something like this? If it's too much, that's also fine. |
Right, so the reason I ask is -- for example -- pyproject.toml is becoming (in python3) a centralized, sort-of dotfile for various python packages like flake8 and pytest -- as well as to put setup.py specific things in it as well. One could imagine the same thing here, where xAH plays nicely with other frameworks that depend on xAH like the Xhh folks (so it's less confusing for them to have a ... Also I might request that no matter what we pick, we keep the filename lowercase. |
Can we move the parsing of dotfile into utils, and the updating of cli_options into utils as well? Then I think I'm happy with this. Main reason I ask is so that other people who depend on xAH (Xhh) can take advantage of the nice utility functions for parsing/updating. |
And I think one last thought, and maybe a nice thing. I can imagine that you might want to have multiple
before updating anything else. Or just adding another line, so that the local dotfile updates all defaults last. |
I've moved the dotfile loading into a function in utils. That way if someone requests analysis-specific dotfiles, this can be added. |
…ct for non-existent dotfile.
This PR does not cause #1316 , but the error does highlight an issue with the current proposal. There are certain "common" driver options that I don't want to have the same defaults for. For example, I want The PR has been changed back to use INI files, with section per sub-command and I'm going to keep it as WIP for a day or two to further test the latest changes. |
This is fine. Remove the WIP when you're happy and ping me. |
I've been running with this for a while and I'm happy. So I think it can be merged. |
To run on my institution's cluster, I need to specify a lot of options (ie: queue, setup commands...) to xAH_run.py. This is not very practical if I want to run one-off tests.
This PR solves this by adding a dotfile (
~/.xah
) that is read byxAH_run.py
at start and overrides any defaults passed to the argument parser. It is an INI file with a section per sub-command and ageneral
section for the general options. The keys are the options being set.As an example, my .xah looks as follows: