Skip to content

Commit 8e42e40

Browse files
authored
Merge pull request #360 from SANDAG/standalone_settings_manager
Standalone settings manager
2 parents a1969da + f78988d commit 8e42e40

File tree

2 files changed

+41
-2
lines changed

2 files changed

+41
-2
lines changed

docs/application/settings-manager.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,22 @@ This is done to ease global replacement. In any configuration yaml file (or the
2727

2828
## Resetting settings
2929

30-
If a user realizes that they set a setting to the wrong value after they started a model run, then they need to reset the settings in order to get all of the tags back to what they were before the settings manager was run. This can be accomplished by running reset_settings.cmd within the "bin" folder in the model directory.
30+
If a user realizes that they set a setting to the wrong value after they started a model run, then they need to reset the settings in order to get all of the tags back to what they were before the settings manager was run. This can be accomplished by running reset_settings.cmd within the "bin" folder in the model directory.
31+
32+
## Running the settings manager
33+
There are two ways the settings manager can be run. The simplest way is that it is automatically run from EMME as soon as a model run is started. However, sometimes the settings need to be updated without EMME, so the settings manager can be run from the Anaconda prompt. To do so, navigate to a clone of the ABM repo and run the following command:
34+
```
35+
python src\main\emme\toolbox\utilities\settings_manager.py [DIRS OR FILES TO UPDATE]
36+
```
37+
As an example, if a user only wanted to update the ActivitySim passenger model configs, they would type the following command:
38+
```
39+
python src\main\emme\toolbox\utilities\settings_manager.py src\asim\configs
40+
```
41+
This command updates the property file:
42+
```
43+
python src\main\emme\toolbox\utilities\settings_manager.py src\main\resources\conf\sandag_abm.properties
44+
```
45+
If one were to update all of the files that the settings manager updates when run from EMME, they would use the following command:
46+
```
47+
python src\main\emme\toolbox\utilities\settings_manager.py src\main\resources\conf\sandag_abm.properties src\asim\configs src\asim-cvm\configs
48+
```

src/main/emme/toolbox/utilities/settings_manager.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,4 +209,25 @@ def __call__(self, target):
209209
self.update_directory(target)
210210

211211
elif os.path.isfile(target):
212-
self.update_settings_file(target)
212+
self.update_settings_file(target)
213+
214+
if __name__ == "__main__":
215+
"""
216+
Run from root directory of a clone of the ABM repo
217+
Instructions to run from Anaconda prompt:
218+
python src\main\emme\toolbox\utilities\settings_manager.py [DIRS OR FILES TO UPDATE]
219+
220+
Example (just passenger model configs):
221+
python src\main\emme\toolbox\utilities\settings_manager.py src\asim\configs
222+
223+
Example (property file):
224+
python src\main\emme\toolbox\utilities\settings_manager.py src\main\resources\conf\sandag_abm.properties
225+
226+
Example (all configs):
227+
python src\main\emme\toolbox\utilities\settings_manager.py src\main\resources\conf\sandag_abm.properties src\asim\configs src\asim-cvm\configs
228+
"""
229+
manage_settings = SettingsManager(r"src\main\resources\abm3_settings.yaml")
230+
import sys
231+
assert len(sys.argv) > 1, "Please provide at least one file or directory to update"
232+
for arg in sys.argv[1:]:
233+
manage_settings(arg)

0 commit comments

Comments
 (0)