activitysim
activitysim copied to clipboard
cli standard args overwritten by config.py
Currently ActivitySim command-line input runtime args are handled by cli.run.handle_standard_args(), which loads each of them as injectables here: https://github.com/ActivitySim/activitysim/blob/master/activitysim/cli/run.py#L95-L114
Oddly enough, these very same arguments are defined a second time in "core/config.py" here, many of which have hard-coded default values.
The issue arises from the fact that the internal method used to inject the CLI args does so without enabling the cache for these injectables. The result is that a user may run activitysim run --settings_file special_settings.yaml only to find that wherever config.setting('settings_file_name') or inject.get_injectable('settings_file_name') are called they each return "settings.yaml" rather than "special_settings.yaml".
My recommendation is one of the following:
- Enable caching for the CLI standard argument injectables such that the config.py injectable definitions are never loaded if the injectables are created from the CLI args
- Move the hardcoded default injectable definitions in config.py to run.py so that all settings injectables, regardless of whether they are defaults or CLI args, are initialized at the same time and in the same place. Perhaps the defaults could simply become
argparsedefaults?