<commit_before>(ns hermes.stuff.hermesutil
  (:require [runtime.q :as q] :reload-all)
  (:require [hermes.core :as g]
            [hermes.type :as t]
            [hermes.vertex :as v])
  (:import  
    (com.thinkaurelius.titan.graphdb.database   StandardTitanGraph)
    (com.thinkaurelius.titan.graphdb.vertices   PersistStandardTitanVertex)
    (com.tinkerpop.blueprints Graph)
    )
  )

(defn assumedNonNilGraph [graph]
  (q/assumedNotNil [graph "you passed nil graph"])
  )

(defn shutdown
  [graph]
  {:pre [(assumedNonNilGraph graph)]}
  (.shutdown 
    ;^StandardTitanGraph 
    ;^com.tinkerpop.blueprints.Graph 
    ^Graph graph)
  )

(defn assumeNotLeakedGraph
  []
  (q/assumedNil [
               g/*graph*
               "something bad happened and the graph leaked to *graph* ie. it's non-nil now"] )
  )

(defn
  open
  [& params]
  {:pre [(assumedNonNilGraph [params 
                              "if you wanted to open in memory graph, don't pass nil"]
           )
         (assumeNotLeakedGraph)
         ] 
   :post [(assumeNotLeakedGraph)]
   }
  
  (with-bindings {#'g/*graph* nil}
    (assumeNotLeakedGraph)
    (apply g/open params);XXX: (g/open params) would pass nil if no params on call
    g/*graph*
    )
  )

#_(defn x []
  (binding [g/*graph* nil]
    (println g/*graph*)
    (alter-var-root #'g/*graph* (constantly 3)) ;changes root
    (println g/*graph*) ;not seen root
    g/*graph* ;always nil due to binding
    )
  )

(defn pacifyGlobalGraphVarRoot
  []
  (alter-var-root #'g/*graph* (constantly nil))
  )<commit_msg>that should not have been there, for one<commit_after>(ns hermes.stuff.hermesutil
  (:require [runtime.q :as q] :reload-all)
  (:require [hermes.core :as g]
            [hermes.type :as t]
            [hermes.vertex :as v])
  (:import  
    (com.thinkaurelius.titan.graphdb.database   StandardTitanGraph)
    (com.thinkaurelius.titan.graphdb.vertices   PersistStandardTitanVertex)
    (com.tinkerpop.blueprints Graph)
    )
  )

(defn assumedNonNilGraph [graph]
  (q/assumedNotNil [graph "you passed nil graph"])
  )

(defn shutdown
  [graph]
  {:pre [(assumedNonNilGraph graph)]}
  (.shutdown 
    ;^StandardTitanGraph 
    ;^com.tinkerpop.blueprints.Graph 
    ^Graph graph)
  )

(defn assumeNotLeakedGraph
  []
  (q/assumedNil [
               g/*graph*
               "something bad happened and the graph leaked to *graph* ie. it's non-nil now"] )
  )

(defn
  open
  [& params]
  {:pre [
         (assumeNotLeakedGraph)
         ] 
   :post [(assumeNotLeakedGraph)]
   }
  
  (with-bindings {#'g/*graph* nil}
    (assumeNotLeakedGraph)
    (apply g/open params);XXX: (g/open params) would pass nil if no params on call
    g/*graph*
    )
  )

#_(defn x []
  (binding [g/*graph* nil]
    (println g/*graph*)
    (alter-var-root #'g/*graph* (constantly 3)) ;changes root
    (println g/*graph*) ;not seen root
    g/*graph* ;always nil due to binding
    )
  )

(defn pacifyGlobalGraphVarRoot
  []
  (alter-var-root #'g/*graph* (constantly nil))
  )
{'fraction_non_alphanumeric': 0.13326686606846128, 'fraction_numerical': 0.0006646726487205051, 'mean_word_length': 2.6396614268440146, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3928875', 'n_tokens_mistral': 1116, 'n_tokens_neox': 1073, 'n_words': 252}