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

Regular config file doesn't always take precedence over shared config file. #2448

Open
tomballgithub opened this issue Jan 18, 2018 · 3 comments

Comments

@tomballgithub
Copy link
Contributor

tomballgithub commented Jan 18, 2018

The 'db-name: setting' in a config file does NOT override the setting within a 'shared' config file. This impacted me after making a setting change and then doing a -cd to clear the database. It cleared the wrong database.

I found this at the following link:
The value set in the regular -cf configuration file takes precedence
https://github.com/RocketMap/RocketMap/blob/develop/docs/first-run/configuration-files.md

However, it doesn't work

Expected Behavior

The -cf configuration file should take precedence over the shared config file.

Current Behavior

The -cf does NOT take precedence over the shared config file for 'db-name'. I have heard this applies to other settings also.

Possible Solution

  1. Fix the code so that the -cf settings always take priority
  2. Fix the code so that if there are conflicting settings that an error occurs.

Steps to Reproduce (for bugs)

  1. Create two databases
  2. Assign one to Rocketmap in the shared config file
  3. Assign one to Rocketmap in the -cf config file
  4. Launch Rocketmap using both a shared and -cf config file
  5. See that Rocketmap is using the incorrect database, the shared one

Context

Your Environment

  • Version used:
  • Environment name and version (e.g. Python 2.7):
  • Operating System and version (desktop or mobile):
@sebastienvercammen sebastienvercammen changed the title 'Db-name' is not adhered to in the -cf config file if also listed in the shared config file Regular config file doesn't always take precedence over shared config file. Jan 18, 2018
@sebastienvercammen
Copy link
Member

sebastienvercammen commented Jan 18, 2018

Updated title to reflect that this isn't about db-name specifically. The order of priority for config items doesn't seem to be consistent for all items: some get precedence, others don't, and CLI arg priority (-cf vs -scf) might affect it as well.

Since we've defined the shared config file as a config file for the ConfigArgParse library, the load order isn't controlled by us.

To be investigated.

@sebastienvercammen sebastienvercammen added this to the 4.1.1 milestone Jan 18, 2018
@pogo-excalibur
Copy link
Contributor

pogo-excalibur commented Jan 24, 2018

Logic summary from ConfigArgParse (quick examination):

  1. Read command line args
  2. Read ENV variables
    • unless they're already set, in which case they get ignored
  3. Read config files (marked is_config_file=True) in reverse order to the order that they are declared in
    • unless they're already set, in which case they get ignored
  4. Fill in any required but missing args with their default values

I'd guess that it's the combination of reversing the order and ignoring already set args that's caused the issue here.

In summary, ConfigArgParse doesn't appear to allow args to be overridden.

Quick addendum: there are subtleties here around some arg types - for example store_true and store_false are only considered 'set' if they are set to True or False respectively, i.e. if a store_true arg gets set to False in one config file it can still get set to True by another config file higher in the load order.

@sebastienvercammen
Copy link
Member

@pogo-excalibur Thanks for looking into the details.

Tagged as "bug" since we describe a specific load order in our documentation (config should have precedence over shared config).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants