<commit_before>(ns cmr.common.config
  "A namespace that allows for global configuration. Configuration can be provided at runtime or
  through an environment variable"
  (:require [clojure.string :as str]))

(def runtime-config-values
  "An atom containing a map of explicitly set config values."
  (atom {}))

(defn set-config-value!
  "Sets a config value at runtime. This allows something like dev-system
  to change a port at runtime without having to specify it as a env variable"
  [name value]
  (swap! runtime-config-values #(assoc % name value)))

(defn reset-config-values
  "Resets any explicitly set runtime configuration values."
  []
  (reset! runtime-config-values {}))

(defn config-value-fn
  "Returns a function that can retrieve a configuration value which can be set as an environment
  variable on the command line or default to a value."
  [config-name default-value]

  ;; Environment variables can't change at runtime so we look them up initially.
  (let [env-name (str "CMR_" (-> config-name
                                 name
                                 (str/replace "-" "_")
                                 str/upper-case))
        env-value (System/getenv env-name)]
    (fn []
      (or (get @runtime-config-values config-name)
          env-value
          default-value))))<commit_msg>Updated common config to use camel snake kebab.<commit_after>(ns cmr.common.config
  "A namespace that allows for global configuration. Configuration can be provided at runtime or
  through an environment variable"
  (:require [clojure.string :as str]
            [camel-snake-kebab :as csk]))

(def runtime-config-values
  "An atom containing a map of explicitly set config values."
  (atom {}))

(defn set-config-value!
  "Sets a config value at runtime. This allows something like dev-system
  to change a port at runtime without having to specify it as a env variable"
  [name value]
  (swap! runtime-config-values #(assoc % name value)))

(defn reset-config-values
  "Resets any explicitly set runtime configuration values."
  []
  (reset! runtime-config-values {}))

(defn config-value-fn
  "Returns a function that can retrieve a configuration value which can be set as an environment
  variable on the command line or default to a value."
  [config-name default-value]

  ;; Environment variables can't change at runtime so we look them up initially.
  (let [env-name (str "CMR_" (csk/->SNAKE_CASE_STRING config-name))
        env-value (System/getenv env-name)]
    (fn []
      (or (get @runtime-config-values config-name)
          env-value
          default-value))))
{'fraction_non_alphanumeric': 0.09247889485801995, 'fraction_numerical': 0.0, 'mean_word_length': 3.0046082949308754, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5598383', 'n_tokens_mistral': 721, 'n_tokens_neox': 707, 'n_words': 293}