<commit_before>(ns kiries.redis
  (:use [clojure.tools.logging :only (info error debug warn)])
  (:require [taoensso.carmine :as car]
            [clj-json.core :as json]))

(defn publish
  "Returns a function which publishes a single event as JSON, to the
  spcified redis server and key."
  [conn key]
  (let [f (spublish conn key)]
    (fn [e]
      (f [e]))))

(defn spublish
  "Returns a function which takes a sequence of events or other
   values, and publishes them as JSON, to the specified redis server
   and key.  Suitable for using inside of rollup."
  [conn key]
  (fn [events]
    (let [jevents
          (remove nil?
                  (map
                   (fn [e]
                     (try (json/generate-string e)
                          (catch Exception err
                            (error "Could not coerce event to json (" e "):" err)
                            nil)))
                   events))]
      (doseq [je jevents]
        (try
          (car/wcar conn
                    (car/publish key je)
                    )
          (catch Exception e
            (warn "Unable to publish" key "to" conn ":" e)))))))
<commit_msg>Fix definition order in kiries.redis<commit_after>(ns kiries.redis
  (:use [clojure.tools.logging :only (info error debug warn)])
  (:require [taoensso.carmine :as car]
            [clj-json.core :as json]))

(defn spublish
  "Returns a function which takes a sequence of events or other
   values, and publishes them as JSON, to the specified redis server
   and key.  Suitable for using inside of rollup."
  [conn key]
  (fn [events]
    (let [jevents
          (remove nil?
                  (map
                   (fn [e]
                     (try (json/generate-string e)
                          (catch Exception err
                            (error "Could not coerce event to json (" e "):" err)
                            nil)))
                   events))]
      (doseq [je jevents]
        (try
          (car/wcar conn
                    (car/publish key je)
                    )
          (catch Exception e
            (warn "Unable to publish" key "to" conn ":" e)))))))

(defn publish
  "Returns a function which publishes a single event as JSON, to the
  spcified redis server and key."
  [conn key]
  (let [f (spublish conn key)]
    (fn [e]
      (f [e]))))

{'fraction_non_alphanumeric': 0.10029876227059326, 'fraction_numerical': 0.0, 'mean_word_length': 1.5814977973568283, 'pattern_counts': {'":': 2, '<': 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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5246567', 'n_tokens_mistral': 702, 'n_tokens_neox': 674, 'n_words': 256}