From 05551c816930be81db9736a84530d41bf84dfc4a Mon Sep 17 00:00:00 2001 From: "Mahadik, Mukul Chandrakant" Date: Mon, 15 Apr 2024 17:14:34 -0700 Subject: [PATCH] Try-except block brought to the top Will first check if debug.conf exists, like other conf files. If it does not, except block then check if PROD_STAGE environment variable is set and whether debug.conf.internal is present. Else, fall back to sample conf. --- emission/analysis/config.py | 17 ++++++++--------- seed_model.json | 1 + 2 files changed, 9 insertions(+), 9 deletions(-) create mode 100644 seed_model.json diff --git a/emission/analysis/config.py b/emission/analysis/config.py index f579349c9..a7a84b6db 100644 --- a/emission/analysis/config.py +++ b/emission/analysis/config.py @@ -2,18 +2,17 @@ import os def get_config_data(): - 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: + try: + print("Trying to open debug.conf.json") + config_file = open('conf/analysis/debug.conf.json') + except: + if os.getenv("PROD_STAGE") == "TRUE": + print("In production environment, opening internal debug.conf") + config_file = open('conf/analysis/debug.conf.internal.json') + else: 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 diff --git a/seed_model.json b/seed_model.json new file mode 100644 index 000000000..b8a4aca8a --- /dev/null +++ b/seed_model.json @@ -0,0 +1 @@ +{"py/object": "sklearn.ensemble._forest.RandomForestClassifier", "py/state": {"base_estimator": {"py/object": "sklearn.tree._classes.DecisionTreeClassifier", "py/state": {"class_weight": null, "classes_": null, "criterion": "gini", "max_depth": null, "max_features": null, "max_features_": null, "max_leaf_nodes": null, "min_impurity_split": 1e-07, "min_samples_leaf": 1, "min_samples_split": 2, "min_weight_fraction_leaf": 0.0, "n_classes_": null, "n_features_": null, "n_outputs_": null, "presort": false, "random_state": null, "splitter": "best", "tree_": null, "_sklearn_version": "0.23.2"}}, "base_estimator_": {"py/id": 1}, "bootstrap": true, "class_weight": null, "classes_": {"py/object": "numpy.ndarray", "dtype": "float64", "values": [1.0, 5.0]}, "criterion": "gini", "estimator_params": {"py/tuple": ["criterion", "max_depth", "min_samples_split", "min_samples_leaf", "min_weight_fraction_leaf", "max_features", "max_leaf_nodes", "min_impurity_split", "random_state"]}, "estimators_": [{"py/object": "sklearn.tree._classes.DecisionTreeClassifier", "py/state": {"class_weight": null, "classes_": {"py/object": "numpy.ndarray", "dtype": "float64", "values": [0.0, 1.0]}, "criterion": "gini", "max_depth": null, "max_features": "auto", "max_features_": 3, "max_leaf_nodes": null, "min_impurity_split": 1e-07, "min_samples_leaf": 1, "min_samples_split": 2, "min_weight_fraction_leaf": 0.0, "n_classes_": {"py/object": "numpy.int64", "dtype": "int64", "value": 2}, "n_features_": 13, "n_outputs_": 1, "presort": false, "random_state": 1842313873, "splitter": "best", "tree_": {"py/reduce": [{"py/type": "sklearn.tree._tree.Tree"}, {"py/tuple": [13, {"py/object": "numpy.ndarray", "dtype": "int64", "values": [2]}, 1]}, {"max_depth": 1, "node_count": 3, "nodes": {"py/object": "numpy.ndarray", "dtype": "[('left_child', '