-
Notifications
You must be signed in to change notification settings - Fork 36
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
add code to programmatically set parameters #184
Conversation
b4bed2d
to
b8068ad
Compare
scr_globals.h provides access to variables set from parameters during scr_init and which should not be accessed by tools to make tracking parameter dependencies more feasible
scr_globals.h provides access to variables set from parameters during scr_init and which should not be accessed by tools to make tracking parameter dependencies more feasible
this introduces another config hash of config options "app" that take precendence over all other hashes.
b8068ad
to
0b6d3b2
Compare
hmm. some rebase was required (git confused me when working with multiple remotes), so I did not properly rebase before. Now tests fail. Will update once tests pass once more. |
Actually already fails for me in the develop branch:
the file test.conf refers to |
0b6d3b2
to
6fd51ee
Compare
updating all components, re-running cmake and compiling form scratch seems to have fixed this. |
Thanks @rhaas80 . This is great! I'll try to review this later. One thing that comes to mind in reading your description. I think it'd be good to make the settings from environment variables or config files override settings from the Config API. This would allow a user to override a setting the application developer has hardcoded via the config API. Without that, one would have to recompile. |
src/scr.c
Outdated
|
||
scr_param_app_hash_write_file(app_config); | ||
|
||
free(app_config); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
free(app_config); | |
scr_free(&app_config); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. The variable (app_config) goes out of scope a line after this so I did not change (I nottd the same free vs. scr_free potential issue). Will change to make this more obvious since I am apparently not the only one taking note of this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a way in GitHub to jump to the current version of those lines to show my fix?
src/scr_param.c
Outdated
value = kvtree_elem_get_first_val(scr_app_hash, name); | ||
if (value != NULL) { | ||
/* evaluate environment variables */ | ||
if(*value == '$'){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In case there is a variable embedded anywhere in the value, like "STORE=/tmp/$USER"
if(*value == '$'){ | |
if(strchr(value, '$')){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. I thought I had got all of those when re-doing things to support expandenv.
Fine with me (I had thought of SCR_Config something the application code would call based on its own input deck and env variables while the ENV variables are set inherited from a templated / canned submit scritpt). Certainly keeping env variables at highest priority is sensible if they are controlled directly by the user. I have moved (in d96a69a) the order so that now it is:
Before final merge I would squash commits for the various bits (Perl code, scr_param changes) to have one commit per bit. |
I was able to take a closer look last night. Things generally look fine to me. User will love this feature. A few more things:
Style:
|
Right now these changes are individual commits but I will squash them down with the original commits once the pull request is reviewed. There are some whitespace changes in code not touched due to SCR_Config, mostly in |
Thanks @rhaas80 . This all looks good to me. I keep going back and forth on how to prioritize the SCR_Config settings, too. As I talk with more code teams I'm hoping that might shed more light on which way to go with this. We can talk about these options on our next call. I think we're generally on the same page as to letting the end user have final control. The SCR system config file is meant to be something a system admin might create with settings that apply to the machine which is useful for all users. This could contain info about expected failure groups and available storage mount points that one can opt to use as cache locations. This might be installed to /etc/scr/scr.conf. In practice, I don't think admins will really be creating or maintaining these files. Even though these files aren't likely to be used, they're at least an option. The SCR user config file is meant to be for the end user of the application. SCR will read the file pointed to by SCR_CONF_FILE if that is set. That might be a conf file the user has in their home directory in case they can use one config file across lots of their runs. If SCR_CONF_FILE is not set, SCR automatically looks in the SCR_PREFIX directory of the job for an existing ".scrconf" file. This lets users more easily manage a config file per application if they want to, where each simulation (prefix directory) has its own config file. The application developers now have three options for their users:
My goal was to make things so users can use environment variables or config files to override what the developers might have coded up in SCR_Config calls. If the settings that the developer picked are wrong, this gives users an escape hatch to override those settings. |
@rhaas80 , I think this looks good to merge. Is it good to go for you? While working with apps, I'm already marking places in their code where they will be able to use this. This will be a popular feature. |
It does remind me of our existing issue where our scripts can see different values from the application depending on where parameters get set. I know you've already worked through this and encoded it directly into the config params code. To get a grasp of where we stand, we should put together a matrix of SCR parameter vs user-facing scripts (scr_prerun, scr_run, library, scr_postrun). That way we can show what gets used and where. We could include that on our readthedocs page if we think users would benefit, but if not there, we should definitely put that somewhere where developers can see it. |
Thanks , @rhaas80 . |
oha. I am way too slow for you here, sorry. No cleanup of the branch anymore :-). I don't have a full matrix but I have the list of parameters that are used by user-facing scripts that run before the main app runs: "CACHE", "CACHEDIR", "CNTLDIR", "SCR_CACHE_BASE", "SCR_CACHE_SIZE", "SCR_CNTL_BASE", "SCR_CONF_FILE", "SCR_DB_DEBUG", "SCR_DB_ENABLE", "SCR_DB_HOST", "SCR_DB_NAME", "SCR_DB_PASS", "SCR_DB_USER", "SCR_EXCLUDE_NODES", "SCR_JOB_NAME", "SCR_LOG_ENABLE", "SCR_PREFIX", "SCR_WATCHDOG_TIMEOUT", "SCR_WATCHDOG_TIMEOUT_PFS" These are used by scripts / utililties (maybe not all user facing):
|
The introduces a function:
that takes as argument a configuration string of the form found on
scr.conf
:which is interpreted the same way as an configuration file line, or a query string which lacks the final value assignment
or
Options must be set on all MPI ranks, no broadcast takes place.
Options set this way override all other options.
Both C and Fortran bindings are provided and the routines are tested in
examples/test_config.c
which runs as part ofctest
.Configuration options set in the code are stored in a file
.scr/app.conf
to be used by Perl scripts.This addresses issue #40 .
Caveats:
SCR_Config
must be called beforeSCR_init
SCR_Config
will initialize scr's MPI communicator to read in.scr/app.conf
when the firstSCR_Config
call is madeget_param
functions there are memory leaks when querying certain configuration options