Skip to content

Commit

Permalink
Choose analysis/debug.conf file based on ENV var
Browse files Browse the repository at this point in the history
Added new environment variable PROD_STAGE.

If this is set to TRUE, then the debug.conf.internal.json will be selected as the conf file.

Else, the existing try-catch block is executed which either checks for a debug.conf.json or uses the sample file if the former does not exist.

The try part is still valid, since some Test files copy over the sample file as debug.conf.json, then reload the config in eac.reload_config() which would need reading from debug.conf.json as well.

Hence, now three files exist:
- debug.conf.json.sample
- debug.conf.json
- debug.conf.json.internal
  • Loading branch information
Mahadik, Mukul Chandrakant authored and Mahadik, Mukul Chandrakant committed Apr 1, 2024
1 parent 20e1856 commit 4a1005e
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ CFC_DataCollector/moves_collect.log
webapp/www/lib
conf/**/*.json
!conf/**/*.schema.json
!conf/analysis/debug.conf.internal.json

*.ipynb_checkpoints*

Expand Down
14 changes: 14 additions & 0 deletions conf/analysis/debug.conf.internal.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"intake.segmentation.section_segmentation.sectionValidityAssertions": true,
"intake.cleaning.clean_and_resample.speedDistanceAssertions": false,
"intake.cleaning.clean_and_resample.sectionValidityAssertions": false,
"intake.cleaning.filter_accuracy.enable": false,
"classification.inference.mode.useAdvancedFeatureIndices": true,
"classification.inference.mode.useBusTrainFeatureIndices": true,
"classification.validityAssertions": true,
"output.conversion.validityAssertions": true,
"section.startStopRadius": 150,
"section.endStopRadius": 150,
"analysis.result.section.key": "analysis/inferred_section",
"userinput.keylist": ["manual/mode_confirm", "manual/purpose_confirm", "manual/replaced_mode", "manual/trip_user_input"]
}
17 changes: 12 additions & 5 deletions emission/analysis/config.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
import json
import os

def get_config_data():
try:
config_file = open('conf/analysis/debug.conf.json')
except:
print("analysis.debug.conf.json not configured, falling back to sample, default configuration")
config_file = open('conf/analysis/debug.conf.json.sample')
if os.getenv("PROD_STAGE") == "TRUE":
print("In production environment, opening internal debug.conf")
config_file = open('conf/analysis/debug.conf.internal.json')
else:
try:
print("Trying to open debug.conf.json")
config_file = open('conf/analysis/debug.conf.json')
except:
print("analysis.debug.conf.json not configured, falling back to sample, default configuration")
config_file = open('conf/analysis/debug.conf.json.sample')
ret_val = json.load(config_file)
print(ret_val)
config_file.close()
return ret_val

Expand Down

0 comments on commit 4a1005e

Please sign in to comment.