fix tasks to work with cake 0.6.0

fix tasks to work with cake 0.6.0

--- tasks.clj
+++ tasks.clj
@@ -1,5 +1,5 @@
-(ns user
-  (:use [cake.core :only [deftask remove-dep!]]
+(ns tasks
+  (:use [cake.core :only [deftask]]
         [cake.file :only [file rm rmdir]]
         [bake.core :only [log]]
         [cake.ant :only [ant args env add-zipfileset]]


STORM-464: Simulated time advanced after test cluster exits causes intermitent test failures

--- storm-core/src/clj/backtype/storm/testing.clj
+++ storm-core/src/clj/backtype/storm/testing.clj
@@ -235,10 +235,11 @@
          (log-error t# "Error in cluster")
          (throw t#))
        (finally
-         (let [keep-waiting?# (atom true)]
-           (future (while @keep-waiting?# (simulate-wait ~cluster-sym)))
+         (let [keep-waiting?# (atom true)
+               f# (future (while @keep-waiting?# (simulate-wait ~cluster-sym)))]
            (kill-local-storm-cluster ~cluster-sym)
-           (reset! keep-waiting?# false))))))
+           (reset! keep-waiting?# false)
+            @f#)))))

 (defmacro with-simulated-time-local-cluster
   [& args]


minor:  suppress logs

minor:  suppress logs

--- jar-placement-lib/src/sixsq/slipstream/placement/core.clj
+++ jar-placement-lib/src/sixsq/slipstream/placement/core.clj
@@ -166,12 +166,6 @@

 (defn- keep-only-exact-instance-type
   [connector-instance-types [connector-name service-offers]]
-
-  (log/info "keep only connector name " connector-name)
-  (log/info "keep only instance types " connector-instance-types)
-  (log/info "keep only service offers " (map display-service-offer service-offers))
-  (log/info "keep only instance-type " (get connector-instance-types (keyword connector-name)))
-
   (if-let [instance-type (get connector-instance-types (keyword connector-name))]
     (filter #(= instance-type (:schema-org:name %)) service-offers)
     service-offers))


Use the classloader for decoding that was active when the listener was created [IMMUTANT-266]

Without this, the decode will use the top-level ImmutantClassLoader,
which won't be able to load any dynamically created classes that are
visible at listen time.

--- modules/messaging/src/main/clojure/immutant/messaging.clj
+++ modules/messaging/src/main/clojure/immutant/messaging.clj
@@ -194,8 +194,10 @@
                          destination (create-destination session dest)]
                      {"session" session
                       "consumer-fn" #(create-consumer % destination opts)
-                      "handler" #(binding [*raw-message* %]
-                                   (f (codecs/decode-if decode? %)))}))]
+                      "handler" (with-loading-context
+                                  (bound-fn [m]
+                                    (binding [*raw-message* m]
+                                      (f (codecs/decode-if decode? m)))))}))]
     (at-exit #(.close connection))
     (cond
      (or (not izer)


(PDB-3269) Add initial large_value_hash tests

--- test/puppetlabs/puppetdb/scf/storage_test.clj
+++ test/puppetlabs/puppetdb/scf/storage_test.clj
@@ -23,6 +23,7 @@
             [puppetlabs.puppetdb.testutils.reports :refer :all]
             [puppetlabs.puppetdb.testutils.events :refer :all]
             [puppetlabs.puppetdb.random :as random]
+            [puppetlabs.puppetdb.scf.hash :as hash]
             [puppetlabs.puppetdb.scf.storage :refer :all]
             [clojure.test :refer :all]
             [clojure.math.combinatorics :refer [combinations subsets]]
@@ -469,6 +470,64 @@
                         (query-to-vec
                          "select count(id) as c from fact_paths"))))))))))

+(deftest large-value-hash
+  (let [facts-now (fn [c v]
+                    {:certname c :values v
+                     :environment nil
+                     :timestamp (now)
+                     :producer_timestamp (now)
+                     :producer nil})
+        hex-hash-for (fn [x]
+                       (-> x
+                           hash/generic-identity-hash
+                           sutils/munge-hash-for-storage
+                           sutils/parse-db-hash))
+        bytes->hex (fn [x]
+                     (apply str (map #(format "%02x" %) x)))
+        db-items (fn [col]
+                   (->> (format (str "select path, %s, large_value_hash"
+                                     "  from facts"
+                                     "  inner join fact_paths on id = fact_path_id")
+                                (name col))
+                        query-to-vec
+                        (map (fn [row]
+                               (update row :large_value_hash bytes->hex)))))
+        by-path #(compare (:path %1) (:path %2))
+        threshold facts/large-value-threshold
+        large-str (apply str (repeat (* 2 threshold) \x))
+        large-str-hex (hex-hash-for large-str)]
+
+    (is (> threshold 20))
+
+    (testing "strings have a suitable large_value_hash when expected"
+      (with-test-db
+        (add-certname! "somehost")
+        (add-facts! (facts-now "somehost" {"small" "x" "large" large-str}))
+        (is (= [{:path "large"
+                 :value_string large-str
+                 :large_value_hash large-str-hex}
+                {:path "small"
+                 :value_string "x"
+                 :large_value_hash ""}]
+               (sort by-path (db-items :value_string))))))
+
+    (testing "structured values have a suitable large_value_hash when expected"
+      (with-test-db
+        (let [large-val [large-str]
+              large-val-hex (hex-hash-for large-val)]
+          (add-certname! "somehost")
+          (add-facts! (facts-now "somehost" {"small" ["x"] "large" large-val}))
+          (is (= [{:path "large"
+                   :value large-val
+                   :large_value_hash large-val-hex}
+                  {:path "large#~0"
+                   :value large-str
+                   :large_value_hash large-str-hex}
+                  {:path "small" :value ["x"] :large_value_hash ""}
+                  {:path "small#~0" :value "x" :large_value_hash ""}]
+                 (sort by-path (map #(update % :value sutils/parse-db-json)
+                                    (db-items :value))))))))))
+
 (def catalog (:basic catalogs))
 (def certname (:certname catalog))
 (def current-time (str (now)))


added clause to ensure linkage to a protein bioentity

The DrugBank polypeptide sometimes references gene identifiers along
with protein identifiers. The added clause ensures that for all
drug--protein-target interactions, the target is represented as a
protein bioentity.

--- kabob-build/src/main/resources/edu/ucdenver/ccp/kabob/build/rules/temp/drugbank/drugbank_rules.clj
+++ kabob-build/src/main/resources/edu/ucdenver/ccp/kabob/build/rules/temp/drugbank/drugbank_rules.clj
@@ -76,6 +76,9 @@
     (_/polypeptide_record kiao/hasTemplate iaodrugbank/PolypeptideSchema1)
     (_/polypeptide_record obo/BFO_0000051 _/polypeptide_id_field)
     (_/polypeptide_id_field obo/IAO_0000219 _/protein_ice_id)
+    ;; ensure that the identifier is a protein identifier
+    ;; the polypeptide id sometimes contains gene ids (e.g. HGNC ids)
+    (_/protein_ice_id kiao/denotesSubClassOf obo/CHEBI_36080)
     (_/protein_ice_id obo/IAO_0000219 ?/target_bioentity)
   )


fix #6440 increase width of mobile message bubbles on mobile

--- src/status_im/ui/screens/chat/styles/message/message.cljs
+++ src/status_im/ui/screens/chat/styles/message/message.cljs
@@ -77,9 +77,7 @@
   [outgoing message-type]
   (let [align (if outgoing :flex-end :flex-start)]
     {:flex-direction :column
-     :width          (if (= :system-message message-type)
-                       300
-                       230)
+     :width          320
      :padding-left   8
      :padding-right  8
      :align-items    align}))
@@ -211,4 +209,3 @@
 (defn extension-install [outgoing]
   {:font-size 12
    :color     (if outgoing colors/white colors/blue)})
-


lein-release plugin: preparing 0.1.14 release


get bb ip addr

get bb ip addr

--- src/ci3/repo/bitbucket.clj
+++ src/ci3/repo/bitbucket.clj
@@ -124,7 +124,6 @@
    {:env env :repository repo}))

-
 (defn cleanup [s]
   (-> s
       (str/replace  #"\/" "_")
@@ -158,11 +157,17 @@
   {:response {:status 200
               :body (create-build (json/parse-string payload keyword)) }})

+(defmethod u/*fn
+  ::verify
+  [{{ip :remote-addr} :request}]
+  {:response {:status 200
+              :body ip}})
+
 (defmethod interf/webhook
   :bitbucket
   [arg]
   (u/*apply
-   [::mk-build]
+   [::verify]
    arg))


Refactors traces.

Refactors traces.

--- src/clj/game/cards-ice.clj
+++ src/clj/game/cards-ice.clj
@@ -11,13 +11,19 @@
    :msg "end the run"
    :effect (effect (end-run))})

+(defn trace-ability
+  "Run a trace with specified base strength.
+   If successful trigger specified ability"
+  [base ability]
+  {:label (str "Trace " base " - " (:label ability))
+   :trace (assoc ability :base base)})
+
 (defn tag-trace
   "Trace ability for giving a tag, at specified base strength"
   [base]
-  {:label (str "Trace " base " - Give the Runner 1 tag")
-   :trace {:base base
-           :msg "give the Runner 1 tag"
-           :effect (effect (tag-runner :runner 1))}})
+  (trace-ability base {:label "Give the Runner 1 tag"
+                       :msg "give the Runner 1 tag"
+                       :effect (effect (tag-runner :runner 1))}))

 (defn do-net-damage
   "Do specified amount of net-damage."
@@ -39,6 +45,7 @@
   {:label (str "Gain " credits " [Credits]")
    :msg (str "gain " credits " [Credits]")
    :effect (effect (gain :credit credits))})
+

 ;;; For Advanceable ICE
 (def advance-counters
@@ -101,15 +108,18 @@
               :prompt "Pay 3 [Credits] to force Runner to encounter Archangel?"
               :yes-ability {:cost [:credit 3]
                             :effect (req (system-msg state :corp "pays 3 [Credits] to force the Runner to encounter Archangel"))}}}
-    :abilities [{:label "Trace 6 - Add 1 installed card to the Runner's Grip"
-                 :trace {:base 6 :choices {:req #(:installed %)}
-                         :msg "add 1 installed card to the Runner's Grip"
-                         :effect (effect (move :runner target :hand true) (system-msg (str "adds " (:title target) " to the Runner's Grip")))}}]}
+    :abilities [(trace-ability 6 {:choices {:req installed?}
+                                  :label "Add 1 installed card to the Runner's Grip"
+                                  :msg "add 1 installed card to the Runner's Grip"
+                                  :effect (effect (move :runner target :hand true)
+                                                  (system-msg (str "adds " (:title target)
+                                                                   " to the Runner's Grip")))})]}

    "Archer"
    {:additional-cost [:forfeit]
-    :abilities [{:msg "gain 2 [Credits]" :effect (effect (gain :credit 2))}
-                trash-program end-the-run]}
+    :abilities [(gain-credits 2)
+                trash-program
+                end-the-run]}

    "Architect"
    {:flags {:untrashable-while-rezzed true}
@@ -121,7 +131,8 @@
                                 (not (is-type? target "Operation"))))
                  :not-distinct true
                  :choices (req (conj (take 5 (:deck corp)) "No install"))
-                 :effect (effect (corp-install (move state side target :play-area) nil {:no-install-cost true}))}
+                 :effect (effect (corp-install (move state side target :play-area)
+                                               nil {:no-install-cost true}))}
                 {:label "Install a card from HQ or Archives"
                  :prompt "Choose a card to install from Archives or HQ"
                  :show-discard true
@@ -136,10 +147,8 @@
    {:abilities [end-the-run]}

    "Assassin"
-   {:abilities [{:label "Trace 5 - Do 3 net damage"
-                 :trace (assoc (do-net-damage 3) :base 5)}
-                {:label "Trace 4 - Trash a program"
-                 :trace (assoc trash-program :base 4 :msg "trash a program")}]}
+   {:abilities [(trace-ability 5 (do-net-damage 3))
+                (trace-ability 4 (assoc trash-program :msg "trash a program"))]}

    "Asteroid Belt"
    (space-ice end-the-run)
@@ -181,16 +190,14 @@
                                      (update-run-ice state side))}}}]}

    "Burke Bugs"
-   {:abilities [{:label "Trace 0 - Force the Runner to trash a program"
-                 :trace (assoc trash-program :base 0 :not-distinct true
-                                             :player :runner
-                                             :msg "force the Runner to trash a program")}]}
+   {:abilities [(trace-ability 0 (assoc trash-program :not-distinct true
+                                        :player :runner
+                                        :msg "force the Runner to trash a program"
+                                        :label "Force the Runner to trash a program"))]}

    "Caduceus"
-   {:abilities [{:label "Trace 3 - Gain 3 [Credits]"
-                 :trace (assoc (gain-credits 3) :base 3)}
-                {:label "Trace 2 - End the run"
-                 :trace (assoc end-the-run :base 2)}]}
+   {:abilities [(trace-ability 3 (gain-credits 3))
+                (trace-ability 2 end-the-run)]}

    "Cell Portal"
    {:abilities [{:msg "make the Runner approach the outermost ICE"
@@ -210,12 +217,15 @@

    "Checkpoint"
    {:effect (effect (gain :bad-publicity 1) (system-msg "takes 1 bad publicity"))
-    :abilities [{:label "Trace 5 - Do 3 meat damage when this run is successful"
-                 :trace {:base 5 :msg "do 3 meat damage when this run is successful"
-                         :effect (req (swap! state assoc-in [:run :run-effect :end-run]
-                                             {:req (req (:successful run)) :msg "do 3 meat damage"
-                                              :effect (effect (damage :meat 3 {:card card}))})
-                                      (swap! state assoc-in [:run :run-effect :card] card))}}]}
+    :abilities [(trace-ability 5 {:label "Do 3 meat damage when this run is successful"
+                                  :msg "do 3 meat damage when this run is successful"
+                                  :effect (req (swap! state assoc-in [:run :run-effect :end-run]
+                                                      {:req (req (:successful run))
+                                                       :msg "do 3 meat damage"
+                                                       :effect (effect (damage :meat 3
+                                                                               {:card card}))})
+                                               (swap! state assoc-in [:run :run-effect :card]
+                                                      card))})]}

    "Chimera"
    (let [ab {:effect (effect (derez :corp card)
@@ -270,12 +280,15 @@
               {:corp-install cw :trash cw :card-moved cw})}

    "Data Hound"
-   {:abilities [{:label "Trace 2 - Look at the top of Stack"
-                 :trace {:base 2 :msg "look at top X cards of Stack"
-                         :effect (req (doseq [c (take (- target (second targets)) (:deck runner))]
-                                        (move state side c :play-area))
-                                      (system-msg state :corp (str "looks at the top " (- target (second targets)) " cards of Stack"))
-                                      )}}]}
+   {:abilities [(trace-ability 2 {:label "Look at the top of Stack"
+                                  :msg "look at top X cards of Stack"
+                                  :effect (req (doseq [c (take (- target (second targets))
+                                                               (:deck runner))]
+                                                 (move state side c :play-area))
+                                               (system-msg state :corp
+                                                           (str "looks at the top "
+                                                                (- target (second targets))
+                                                                " cards of Stack")))})]}

    "Data Mine"
    {:abilities [{:msg "do 1 net damage"
@@ -290,20 +303,26 @@
                 end-the-run]}

    "Data Raven"
-   {:abilities [{:msg "give the Runner 1 tag" :effect (effect (tag-runner 1))}
+   {:abilities [{:msg "give the Runner 1 tag"
+                 :effect (effect (tag-runner 1))}
                 {:msg "give the Runner 1 tag using 1 power counter"
-                 :counter-cost 1 :effect (effect (tag-runner 1))}
-                {:label "Trace 3 - Add 1 power counter"
-                 :trace {:base 3 :msg "add 1 power counter" :effect (effect (add-prop card :counter 1))}}]}
+                 :counter-cost 1
+                 :effect (effect (tag-runner 1))}
+                (trace-ability 3 {:label "Add 1 power counter"
+                                  :msg "add 1 power counter"
+                                  :effect (effect (add-prop card :counter 1))})]}

    "Dracō"
-   {:prompt "How many power counters?" :choices :credit :msg (msg "add " target " power counters")
+   {:prompt "How many power counters?"
+    :choices :credit
+    :msg (msg "add " target " power counters")
     :effect (effect (set-prop card :counter target)
                     (update-ice-strength card))
     :strength-bonus (req (or (:counter card) 0))
-    :abilities [{:label "Trace 2 - Give the Runner 1 tag and end the run"
-                 :trace {:base 2 :msg "give the Runner 1 tag and end the run"
-                         :effect (effect (tag-runner :runner 1) (end-run))}}]}
+    :abilities [(trace-ability 2 {:label "Give the Runner 1 tag and end the run"
+                                  :msg "give the Runner 1 tag and end the run"
+                                  :effect (effect (tag-runner :runner 1)
+                                                  (end-run))})]}

    "Eli 1.0"
    {:abilities [end-the-run]}
@@ -343,17 +362,18 @@
     :strength-bonus advance-counters}

    "Flare"
-   {:abilities [{:label "Trace 6 - Trash 1 hardware, do 2 meat damage, and end the run"
-                 :trace {:base 6
-                         :msg "trash 1 hardware, do 2 meat damage, and end the run"
-                         :effect (effect (resolve-ability
-                                           {:prompt "Choose a piece of hardware to trash"
-                                            :label "Trash a piece of hardware"
-                                            :msg (msg "trash " (:title target))
-                                            :choices {:req #(is-type? % "Hardware")}
-                                            :effect (effect (trash target {:cause :subroutine}))} card nil)
-                                         (damage :meat 2 {:unpreventable true :card card})
-                                         (end-run))}}]}
+   {:abilities [(trace-ability 6 {:label "Trash 1 hardware, do 2 meat damage, and end the run"
+                                  :msg "trash 1 hardware, do 2 meat damage, and end the run"
+                                  :effect (effect (resolve-ability
+                                                   {:prompt "Choose a piece of hardware to trash"
+                                                    :label "Trash a piece of hardware"
+                                                    :msg (msg "trash " (:title target))
+                                                    :choices {:req #(is-type? % "Hardware")}
+                                                    :effect (effect (trash target {:cause :subroutine}))}
+                                                   card nil)
+                                                  (damage :meat 2 {:unpreventable true
+                                                                   :card card})
+                                                  (end-run))})]}

    "Galahad"
    (grail-ice end-the-run)
@@ -448,15 +468,17 @@

    "Ichi 1.0"
    {:abilities [trash-program
-                {:label "Trace 1 - Give the Runner 1 tag and do 1 brain damage"
-                 :trace {:base 1 :msg "give the Runner 1 tag and do 1 brain damage"
-                         :effect (effect (damage :brain 1 {:card card}) (tag-runner :runner 1))}}]}
+                (trace-ability 1 {:label "Give the Runner 1 tag and do 1 brain damage"
+                                  :msg "give the Runner 1 tag and do 1 brain damage"
+                                  :effect (effect (damage :brain 1 {:card card})
+                                                  (tag-runner :runner 1))})]}

    "Ichi 2.0"
    {:abilities [trash-program
-                {:label "Trace 3 - Give the Runner 1 tag and do 1 brain damage"
-                 :trace {:base 3 :msg "give the Runner 1 tag and do 1 brain damage"
-                         :effect (effect (damage :brain 1 {:card card}) (tag-runner :runner 1))}}]}
+                (trace-ability 3 {:label "Give the Runner 1 tag and do 1 brain damage"
+                                  :msg "give the Runner 1 tag and do 1 brain damage"
+                                  :effect (effect (damage :brain 1 {:card card})
+                                                  (tag-runner :runner 1))})]}

    "IQ"
    {:effect (req (add-watch state (keyword (str "iq" (:cid card)))
@@ -625,7 +647,9 @@

    "Pachinko"
    {:abilities [{:label "End the run if the Runner is tagged"
-                 :req (req tagged) :msg "end the run" :effect (effect (end-run))}]}
+                 :req (req tagged)
+                 :msg "end the run"
+                 :effect (effect (end-run))}]}

    "Paper Wall"
    {:abilities [end-the-run]}
@@ -653,8 +677,7 @@

    "Resistor"
    {:strength-bonus (req (get-in @state [:runner :tag]))
-    :abilities [{:label "Trace 4 - End the run"
-                 :trace {:base 4 :msg "end the run" :effect (effect (end-run))}}]}
+    :abilities [(trace-ability 4 end-the-run)]}

    "Rototurret"
    {:abilities [trash-program end-the-run]}
@@ -695,13 +718,11 @@

    "Shinobi"
    {:effect (effect (gain :bad-publicity 1) (system-msg "takes 1 bad publicity"))
-    :abilities [{:label "Trace 1 - Do 1 net damage"
-                 :trace {:base 1 :msg "do 1 net damage" :effect (effect (damage :net 1 {:card card}))}}
-                {:label "Trace 2 - Do 2 net damage"
-                 :trace {:base 2 :msg "do 2 net damage" :effect (effect (damage :net 2 {:card card}))}}
-                {:label "Trace 3 - Do 3 net damage and end the run"
-                 :trace {:base 3 :msg "do 3 net damage and end the run"
-                         :effect (effect (damage :net 3 {:card card}) (end-run))}}]}
+    :abilities [(trace-ability 1 (do-net-damage 1))
+                (trace-ability 2 (do-net-damage 2))
+                (trace-ability 3 {:label "Do 3 net damage and end the run"
+                                  :msg "do 3 net damage and end the run"
+                                  :effect (effect (damage :net 3 {:card card}) (end-run))})]}

    "Shiro"
    {:abilities [{:label "Rearrange the top 3 cards of R&D"
@@ -714,14 +735,18 @@
                                 (handle-access state side [c])))}]}

    "Snoop"
-   {:abilities [{:req (req (= current-ice card)) :label "Reveal all cards in the Runner's Grip"
+   {:abilities [{:req (req (= current-ice card))
+                 :label "Reveal all cards in the Runner's Grip"
                  :msg (msg "reveal " (join ", " (map :title (:hand runner))))}
-                {:label "Trace 3 - Place 1 power counter on Snoop"
-                 :trace {:base 3 :msg "place 1 power counter on Snoop" :effect (effect (add-prop card :counter 1))}}
-                {:req (req (> (get card :counter 0) 0))
-                 :counter-cost 1 :label "Hosted power counter: Reveal all cards in Grip and trash 1 card"
+                (trace-ability 3 {:label "Place 1 power counter on Snoop"
+                                  :msg "place 1 power counter on Snoop"
+                                  :effect (effect (add-prop card :counter 1))})
+                {:req (req (> (:counter card 0) 0))
+                 :counter-cost 1
+                 :label "Hosted power counter: Reveal all cards in Grip and trash 1 card"
                  :msg (msg "look at all cards in Grip and trash " (:title target))
-                 :choices (req (:hand runner)) :prompt "Choose a card to trash"
+                 :choices (req (:hand runner))
+                 :prompt "Choose a card to trash"
                  :effect (effect (trash target))}]}

    "Snowflake"
@@ -768,7 +793,10 @@
                                               :kicker (assoc trash-hardware :min 5))}]}

    "TMI"
-   {:trace {:base 2 :msg "keep TMI rezzed" :unsuccessful {:effect (effect (derez card))}} :abilities [end-the-run]}
+   {:trace {:base 2
+            :msg "keep TMI rezzed"
+            :unsuccessful {:effect (effect (derez card))}}
+    :abilities [end-the-run]}

    "Tollbooth"
    {:abilities [{:msg "make the Runner pay 3 [Credits], if able"
@@ -779,13 +807,16 @@
    {:abilities [end-the-run]}

    "Troll"
-   {:abilities [{:label "Trace 2 - Force the Runner to lose [Click] or end the run"
-                 :trace {:base 2 :player :runner
-                         :msg "force the Runner to lose [Click] or end the run"
-                         :prompt "Choose one" :choices ["Lose [Click]" "End the run"]
-                         :effect (req (if-not (and (= target "Lose [Click]") (pay state side card :click 1))
-                                        (do (end-run state side) (system-msg state side "ends the run"))
-                                        (system-msg state side "loses [Click]")))}}]}
+   {:abilities [(trace-ability 2 {:label "Force the Runner to lose [Click] or end the run"
+                                  :msg "force the Runner to lose [Click] or end the run"
+                                  :player :runner
+                                  :prompt "Choose one"
+                                  :choices ["Lose [Click]" "End the run"]
+                                  :effect (req (if-not (and (= target "Lose [Click]")
+                                                            (pay state side card :click 1))
+                                                 (do (end-run state side)
+                                                     (system-msg state side "ends the run"))
+                                                 (system-msg state side "loses [Click]")))})]}

    "Tsurugi"
    {:abilities [end-the-run
@@ -801,7 +832,8 @@
                 (tag-trace 5)]}

    "Tyrant"
-   {:advanceable :while-rezzed :abilities [end-the-run]}
+   {:advanceable :while-rezzed
+    :abilities [end-the-run]}

    "Universal Connectivity Fee"
    {:abilities [{:msg (msg "force the Runner to lose " (if (pos? (:tag runner)) "all credits" "1 [Credits]"))
@@ -810,11 +842,10 @@
                                 (lose state :runner :credit 1)))}]}

    "Uroboros"
-   {:abilities [{:label "Trace 4 - Prevent the Runner from making another run"
-                 :trace {:base 4 :msg "prevent the Runner from making another run"
-                         :effect (effect (prevent-run))}}
-                {:label "Trace 4 - End the run"
-                 :trace {:base 4 :msg "end the run" :effect (effect (end-run))}}]}
+   {:abilities [(trace-ability 4 {:label "Prevent the Runner from making another run"
+                                  :msg "prevent the Runner from making another run"
+                                  :effect (effect (prevent-run))})
+                (trace-ability 4 end-the-run)]}

    "Viktor 1.0"
    {:abilities [(do-brain-damage 1)
@@ -824,18 +855,16 @@
    {:abilities [{:msg "do 1 brain damage using 1 power counter"
                  :counter-cost 1
                  :effect (effect (damage :brain 1 {:card card}))}
-                {:label "Trace 2 - Add 1 power counter"
-                 :trace {:base 2
-                         :msg "add 1 power counter"
-                         :effect (effect (add-prop card :counter 1))}}
+                (trace-ability 2 {:label "Add 1 power counter"
+                                  :msg "add 1 power counter"
+                                  :effect (effect (add-prop card :counter 1))})
                 end-the-run]}

    "Viper"
-   {:abilities [{:label "Trace 3 - The Runner loses 1 [Click] if able"
-                 :trace {:base 3 :msg  "force the Runner to lose 1 [Click] if able"
-                         :effect (effect (lose :runner :click 1))}}
-                {:label "Trace 3 - End the run"
-                 :trace {:base 3 :msg "end the run" :effect (effect (end-run))}}]}
+   {:abilities [(trace-ability 3 {:label "The Runner loses 1 [Click] if able"
+                                  :msg "force the Runner to lose 1 [Click] if able"
+                                  :effect (effect (lose :runner :click 1))})
+                (trace-ability 3 end-the-run)]}

    "Virgo"
    {:abilities [{:label "Trace 2 - Give the Runner 1 tag"


done-working needs an empty arg

done-working needs an empty arg

--- src/lt/objs/langs/clj.cljs
+++ src/lt/objs/langs/clj.cljs
@@ -237,12 +237,12 @@
                   :triggers #{:editor.eval.cljs.no-op
                               :editor.eval.clj.no-op}
                   :reaction (fn [this]
-                              (notifos/done-working)))
+                              (notifos/done-working "")))

 (object/behavior* ::cljs-result
                   :triggers #{:editor.eval.cljs.result}
                   :reaction (fn [obj res]
-                              (notifos/done-working)
+                              (notifos/done-working "")
                               (let [type (or (-> res :meta :result-type) :inline)
                                     ev (->dottedkw :editor.eval.cljs.result type)]
                                 (object/raise obj ev res))))
@@ -275,7 +275,7 @@
 (object/behavior* ::clj-result
                   :triggers #{:editor.eval.clj.result}
                   :reaction (fn [obj res]
-                              (notifos/done-working)
+                              (notifos/done-working "")
                               (let [type (or (-> res :meta :result-type) :inline)
                                     ev (->dottedkw :editor.eval.clj.result type)]
                                 (object/raise obj ev res))))
@@ -367,7 +367,7 @@
 (object/behavior* ::handle-cancellation
                   :triggers #{:editor.eval.clj.cancel}
                   :reaction (fn [this]
-                              (notifos/done-working)
+                              (notifos/done-working "")
                               (notifos/set-msg! "Canceled clj eval." {:class "error"})))

 (object/behavior* ::print-length
@@ -762,7 +762,7 @@
                                 (object/update! this [:buffer] str out)
                                 (if (> (.indexOf out "nREPL server started") -1)
                                   (do
-                                    (notifos/done-working)
+                                    (notifos/done-working "")
                                     (object/merge! this {:connected true})
                                     (let [client (clients/by-id (:cid @this))]
                                       (object/merge! client {:port (-> (re-seq #"port ([\d]+)" out) first second)})
@@ -789,8 +789,8 @@
                   :reaction (fn [this data]
                               ;(object/update! this [:buffer] str data)
                               (when-not (:connected @this)
-                                (notifos/done-working)
-                                (notifos/done-working)
+                                (notifos/done-working "")
+                                (notifos/done-working "")
                                 (popup/popup! {:header "We couldn't connect."
                                                :body [:span "Looks like there was an issue trying to connect
                                                       to the project. Here's what we got:" [:pre (:buffer @this)]]


added rm_case_asses

added rm_case_asses


fix an incorrectly named link

fix an incorrectly named link

--- pp-cljs-client/src-cljs/pp_client/html.cljs
+++ pp-cljs-client/src-cljs/pp_client/html.cljs
@@ -52,7 +52,7 @@
   (sablono/html
   [:div.col-ace4b
     [:ul
-      [:li [:a.ftr-link-67c8e {:href docs-url} "Contribute"]]
+      [:li [:a.ftr-link-67c8e {:href docs-url} "Rationale"]]
       [:li [:a.ftr-link-67c8e {:href github-url} "GitHub"]]
       [:li [:a.ftr-link-67c8e {:href issues-url} "Issues"]]]]))


CMR-1863 Updates comments in xml generation DSL.

--- umm-spec-lib/src/cmr/umm_spec/umm_to_xml_mappings/dsl.clj
+++ umm-spec-lib/src/cmr/umm_spec/umm_to_xml_mappings/dsl.clj
@@ -69,13 +69,12 @@
   [:gco:CharacterString value])

 (defn simple-field
-  "Returns a mapping description for an XML element that is named by and pulled from the
-  corresponding key in the current context."
+  "Returns an element mapping with an XML element name matching the corresponding UMM field."
   [k]
   [k (xpath (name k))])

 (defn simple-object
-  "Returns a mapping describing an element with given tag and child mappings using simple-field over
-  ks."
+  "Returns an element named by tag, with child XML element names matching the corresponding UMM
+  fields."
   [tag & ks]
   (vec (cons tag (map simple-field ks))))


markdown display for method config documentation [risk: low] (#1509)

markdown display for method config documentation

--- src/cljs/main/broadfcui/components/entity_details.cljs
+++ src/cljs/main/broadfcui/components/entity_details.cljs
@@ -6,7 +6,9 @@
    [broadfcui.common.codemirror :refer [CodeMirror]]
    [broadfcui.common.icons :as icons]
    [broadfcui.common.links :as links]
+   [broadfcui.common.markdown :as markdown]
    [broadfcui.common.style :as style]
+   [broadfcui.components.collapse :refer [Collapse]]
    [broadfcui.config :as config]
    [broadfcui.nav :as nav]
    [broadfcui.utils :as utils]
@@ -101,8 +103,11 @@
             (make-field :synopsis "Synopsis" :width "150px")
             (make-field :snapshotComment "Snapshot Comment" :wrap? true :width "150px")])]
         (when-not (or redacted? (= repo "dockstore"))
-          [:div {:style {:fontWeight 500 :padding "0.5rem 0 0.3rem 0"}}
-           "Documentation:"
-           (if (string/blank? (:documentation entity))
-             [:div {:style {:fontStyle "italic" :fontSize "90%"}} "No documentation provided"]
-             [:div {:style {:fontSize "90%"}} (:documentation entity)])])]))})
+          [Collapse
+           {:style {:marginBottom "2rem"}
+            :title [:div {:style {:fontWeight 500 :padding "0.5rem 0 0.3rem 0"}}  "Documentation:"]
+            :contents
+             [:div {:style {:marginTop "1rem" :fontSize "90%" :lineHeight 1.5}}
+              (if (string/blank? (:documentation entity))
+               [:em {} "No documentation provided"]
+               [markdown/MarkdownView {:text (:documentation entity)}])]}])]))})


Minor adjustments to sponsor layout.

Minor adjustments to sponsor layout.

--- src/clojars/web/common.clj
+++ src/clojars/web/common.clj
@@ -20,15 +20,14 @@
    (link-to "/security" "security")
    (link-to "https://github.com/ato/clojars-web/wiki/" "help")
    [:div.row.sponsors
-    "sponsored by"
-    (link-to {:target "_blank"}
-             "http://www.redhat.com/"
-             (image "/images/rht-logo.png" "Red Hat, Inc."))]
-   [:div.row.sponsors
-    "sponsored by"
-    (link-to {:target "_blank"}
-             "http://yellerapp.com/"
-             (image "/images/yeller-logo.png" "Yeller"))]
+    [:div "sponsored by"]
+    [:div
+     (link-to {:target "_blank"}
+       "http://www.redhat.com/"
+       (image "/images/rht-logo.png" "Red Hat, Inc."))
+     (link-to {:target "_blank"}
+       "http://yellerapp.com/"
+       (image "/images/yeller-logo.png" "Yeller"))]]
    [:div.row.sponsors
     "remixed by"
     (link-to {:target "_blank"}


separate speed-tests into individual (deftest)s

--- test/babel/test/fr.cljc
+++ test/babel/test/fr.cljc
@@ -643,7 +643,7 @@
     (is (= "nous acheterons" (fo generated)))))

-(deftest speed-test
+(deftest speed-test-1
   ;; these should all take relatively the same time, but
   ;; for now, the more general the spec, the longer it takes to generate
   (is (= 10
@@ -654,8 +654,9 @@
                                                                      :subj {:pred :noi}
                                                                      :tense :past
                                                                      :aspect :progressive}}}
-                                                     :model (medium))))))))))
-  (is (nil? (println "------")))
+                                                     :model (medium)))))))))))
+
+(deftest speed-test-2
   (is (= 10
          (count
           (take 10
@@ -665,8 +666,9 @@
                                                  :sem {:pred :speak
                                                        :subj {:pred :noi}
                                                        :tense :conditional}}}
-                                       :model (medium))))))))))
-  (is (nil? (println "------")))
+                                       :model (medium)))))))))))
+
+(deftest speed-test-3
   (is (= 10
          (count
           (take
@@ -676,8 +678,9 @@
                     (fo (generate {:synsem {:subcat '()
                                             :sem {:pred :speak
                                                   :tense :conditional}}}
-                                  :model (medium))))))))))
-  (is (nil? (println "------")))
+                                  :model (medium)))))))))))
+
+(deftest speed-test-4
   (is (= 10
          (count
           (take
@@ -686,8 +689,8 @@
             #(time (println
                     (fo (generate {:synsem {:subcat '()
                                             :sem {:pred :speak}}}
-                                  :model (medium))))))))))
-  (is (nil? (println "------")))
+                                  :model (medium)))))))))))
+(deftest speed-test-5
   (is (= 10
          (count
           (take
@@ -696,16 +699,16 @@
             #(time (println
                     (fo (generate {:synsem {:subcat '()
                                             :sem {:tense :conditional}}}
-                                  :model (medium))))))))))
-  (is (nil? (println "------")))
+                                  :model (medium)))))))))))
+(deftest speed-test-6
   (is (= 10
          (count
           (take 10
                 (repeatedly
                  #(time (println
                          (fo (generate {:synsem {:subcat '()}}
-                                       :model (medium))))))))))
-  (is (nil? (println "------")))
+                                       :model (medium)))))))))))
+(deftest speed-test-7
   (is (= 10
          (count
           (take 10
@@ -716,8 +719,9 @@
                                                        :subj {:pred :noi}
                                                        :tense :present
                                                        :aspect :perfect}}}
-                                       :model (medium))))))))))
-  (is (nil? (println "------")))
+                                       :model (medium)))))))))))
+
+(deftest speed-test-8
   (is (= 10
          (count
           (take 10
@@ -727,8 +731,8 @@
                                                  :sem {:pred :speak
                                                        :tense :present
                                                        :aspect :perfect}}}
-                                       :model (medium))))))))))
-  (is (nil? (println "------")))
+                                       :model (medium)))))))))))
+(deftest speed-test-9
   (is (= 10
          (count
           (take 10
@@ -737,7 +741,8 @@
                          (fo (generate {:synsem {:subcat '()
                                                  :sem {:tense :present
                                                        :aspect :perfect}}}
-                                       :model (medium)))))))))))
+                                         :model (medium)))))))))))
+


fixing basket saving

fixing basket saving

--- src/eatme/client/main.cljs
+++ src/eatme/client/main.cljs
@@ -106,7 +106,8 @@
      :on-error (js/alert (str "Error loading basket: " basket-id)))))

-(defn nav-handler [{:keys [token navigation?]}]
+(defn nav-handler [{:keys [token navigation? type]}]
+  (js/console.log token " " navigation? " " type)
   (when navigation?
     (load-basket)))

@@ -116,7 +117,7 @@
     (srm/rpc
      (api/save-basket (serialise-basket)) [response]
      :on-success (do (js/alert (str "Basket saved! Id: " (:id response)))
-                     (history/set-token (str (:id response)))
+                     (history/set-token session-history (str (:id response)))
                      (set-basket-saved!)
                      (load-user-baskets))
      :on-error (js/alert (str "Error saving basket"))))


fix test

fix test

--- test/babel/test/fr.cljc
+++ test/babel/test/fr.cljc
@@ -109,7 +109,8 @@
 (deftest generate-regular-conditional
   (let [result (generate {:synsem {:subcat '()
                                    :sem {:subj {:pred :I}
-                                         :tense :conditional}}}
+                                         :tense :conditional}}
+                          :root {:français {:français "dormir"}}}
                          :model (small))]
     (is (= "je dormirais" (fo result)))))


testing babel.reader functionality

testing babel.reader functionality

--- test/babel/test/la.cljc
+++ test/babel/test/la.cljc
@@ -1,5 +1,6 @@
 (ns babel.test.la
   (:require
+   [babel.directory :refer [models]]
    [babel.engine :as engine]
    [babel.latin.morphology :refer [analyze conjugate]]
    [babel.latin :refer [fo generate lexicon model]]
@@ -45,4 +46,31 @@
                               :tense :present}}}
               model)))))

+(deftest reader1
+  (let [source-language :en

+        ;; function to generate expression in target langage
+        source-generate-fn (-> models source-language :generate-fn)
+
+        ;; function to render target expression as text. show-notes=false because
+        ;; we are translating from Latin which (at least for the purposes of this
+        ;; implemetation) lacks the same kind of gender differences that Italian, for
+        ;; example, has.
+        source-format-fn #((-> models source-language :morph) % :show-notes false)
+
+        generated (->
+                   {:synsem {:sem {:subj {:pred :lui}
+                                   :obj :unspec
+                                   :tense :past
+                                   :aspect :progressive
+                                   :pred :answer}}}
+                   source-generate-fn
+                   source-format-fn)]
+
+    (or (= generated "he used to answer")
+        (= generated "he was answering"))))
+
+
+
+
+


add min height to bottom bar to prevent sizing into nothing

Signed-off-by: Chris Granger <5654cde260ae99bc4d30054171b8bcd902efd19a@gmail.com>

--- src/lt/objs/bottombar.cljs
+++ src/lt/objs/bottombar.cljs
@@ -8,6 +8,8 @@
             [crate.binding :refer [map-bound bound subatom]])
   (:require-macros [lt.macros :refer [behavior defui]]))

+
+(def min-height 30)
 (def default-height 130)

 (defui horizontal-grip [this]
@@ -78,7 +80,7 @@
                   :reaction (fn [this e]
                               (when-not (= 0 (.-clientY e))
                                 (let [win-height (.-innerHeight js/window)
-                                      height (- win-height (.-clientY e))]
+                                      height (max (- win-height (.-clientY e)) min-height)]
                                 (object/raise tabs/multi :bottom! (- height (:height @this)))
                                 (object/merge! this {:height height
                                                      :max-height height})))


Always use vectors for seqs when dekeywordising

--- src/muon_clojure/utils.clj
+++ src/muon_clojure/utils.clj
@@ -12,13 +12,13 @@
                              (if (map? v)
                                (dekeywordize v)
                                (if (sequential? v)
-                                 (into (empty v) (map dekeywordize v))
+                                 (into [] (map dekeywordize v))
                                  (if (keyword? v)
                                    (name v)
                                    v)))})
                 m))
     (if (sequential? m)
-      (into (empty m) (map dekeywordize m))
+      (into [] (map dekeywordize m))
       (if (keyword? m)
         (name m)
         m))))


add distinct 1 and 2 methods perf tests

add distinct 1 and 2 methods perf tests

--- perf/calfpath/perf_test.clj
+++ perf/calfpath/perf_test.clj
@@ -67,14 +67,12 @@
                                            :put {:status 200
                                                  :headers {"Content-Type" "text/plain"}
                                                  :body "2.2"})
-    "/company/:cid/dept/:did/" [cid did] (->post request
-                                           {:status 200
-                                            :headers {"Content-Type" "text/plain"}
-                                            :body "3"})
-    "/this/is/a/static/route"  []        (->put request
-                                           {:status 200
-                                            :headers {"Content-Type" "text/plain"}
-                                            :body "4"})))
+    "/company/:cid/dept/:did/" [cid did] (->put request {:status 200
+                                                         :headers {"Content-Type" "text/plain"}
+                                                         :body "3"})
+    "/this/is/a/static/route"  []        (->put request {:status 200
+                                                         :headers {"Content-Type" "text/plain"}
+                                                         :body "4"})))

 (use-fixtures :once (c/make-bench-wrapper ["Compojure" "CalfPath"]
@@ -97,8 +95,11 @@
   (testing "static route match"
     (let [request {:request-method :put
                    :uri "/this/is/a/static/route"}]
-      (c/compare-perf "static route match" (handler-compojure request) (handler-calfpath request))))
+      (c/compare-perf "static URI match, 1 method" (handler-compojure request) (handler-calfpath request))))
   (testing "pattern route match"
     (let [request {:request-method :get
                    :uri "/user/1234/profile/compact/"}]
-      (c/compare-perf "pattern route match" (handler-compojure request) (handler-calfpath request)))))+      (c/compare-perf "pattern URI match, 2 methods" (handler-compojure request) (handler-calfpath request)))
+    (let [request {:request-method :get
+                   :uri "/company/1234/dept/5678/"}]
+      (c/compare-perf "pattern URI match, 1 method" (handler-compojure request) (handler-calfpath request)))))


Improve sample-player docstring

Improve sample-player docstring

- this behaviour should probably change though.

--- src/overtone/sc/sample.clj
+++ src/overtone/sc/sample.clj
@@ -174,7 +174,12 @@

    Accepts same args as both players, namely:

-   [buf 0 rate 1.0 start-pos 0.0 loop? 0 amp 1 out-bus 0]"
+   {:buf 0 :rate 1.0 :start-pos 0.0 :loop? 0 :amp 1 :out-bus 0}
+
+   If you wish to specify a group target vector i.e. [:head foo-g] this
+   argument must go *after* the smpl argument:
+
+   (sample-player my-samp [:head foo-g] :rate 0.5)"
   [smpl & pargs] {:pre [(sample? smpl)]}
   (let [{:keys [path args]}     smpl
         {:keys [id n-channels]} (get @cached-samples* [path args])


use new in-unested-osc-bundle macro to create OSC bundles. This means that bundles are never nested, and calls to at within an at are excecuted immediately regardless of the outer at.

--- src/overtone/sc/server.clj
+++ src/overtone/sc/server.clj
@@ -54,7 +54,7 @@
   have to worry about accidentally scheduling packets into a bundle
   started on another thread."
   [time-ms & body]
-  `(in-osc-bundle @server-osc-peer* ~time-ms (do ~@body)))
+  `(in-unested-osc-bundle @server-osc-peer* ~time-ms (do ~@body)))

 (defmacro snd-immediately
   [& body]


Try ensuring there is at least one repful agree at front

--- src/polismath/clusters.clj
+++ src/polismath/clusters.clj
@@ -350,9 +350,17 @@
   "Returns true if a given comment/group stat hash-map has a more representative z score than
   current-best-z. Used for making sure we have at least _one_ representative comment for every group,
   even if none are left over after the more thorough filters."
-  [{:keys [pat rat rdt] :as comment-conv-stats} current-best-z]
+  [{:keys [rat rdt] :as comment-conv-stats} current-best-z]
   (or (nil? current-best-z)
       (> (max rat rdt) current-best-z)))
+
+
+(defn beats-best-agrr-by-test?
+  "Like beats-best-by-test?, but only considers agrees."
+  [{:keys [repful-for rat] :as comment-conv-stats} current-best-z]
+  (and (= :agree repful-for)
+       (or (nil? current-best-z)
+           (> rat current-best-z))))

 (defn passes-by-test?
@@ -432,20 +440,31 @@
                 (if (and (empty? (gr-get gr :sufficient))
                          (beats-best-by-test? comment-conv-stats (gr-get gr :test)))
                   (gr-assoc gr :best (finalize-cmt-stats tid comment-conv-stats))
+                  gr)
+                ; Also keep track of best agree comment is, so we can throw that the front preferentially
+                (if (beats-best-agrr-by-test? comment-conv-stats (gr-get gr :test))
+                  (gr-assoc gr :best-agree (finalize-cmt-stats tid comment-conv-stats))
                   gr))))
           result
           (zip ids comment-stats)))
       ; initialize result hash
-      (into {} (map #(vector % {:best nil :sufficient []}) ids)))
+      (into {} (map #(vector % {:best nil :best-agree nil :sufficient []}) ids)))
     ; If no sufficient, use best; otherwise sort sufficient and take 5
     (map-vals
-      (fn [{:keys [best sufficient]}]
+      (fn [{:keys [best best-agree sufficient]}]
         (if (empty? sufficient)
-          [best]
+          ; If there weren't any matches of the criteria, just take the best match, and take the best agree if
+          ; possible, and if not just the best general
+          (if best-agree
+            [best-agree]
+            [best])
           (->> sufficient
-               (repness-sort)
-               (take 5)
-               (agrees-before-disagrees)))))))
+               ; Remove best agree if in list, since we'll be putting it in manually
+               (remove #(= best-agree %))
+               (repness-sort) ; sort by our complicated repness metric
+               (concat [best-agree]) ; put best agree at front, regardless
+               (take 5) ; take the top 5
+               (agrees-before-disagrees))))))) ; put the agrees before the disagrees

 (defn xy-clusters-to-nmat [clusters]


Pin clj-time dependency in spark subproject.

--- spark/project.clj
+++ spark/project.clj
@@ -15,6 +15,7 @@
     :exclusions [org.objenesis/objenesis]]

    ; Version pinning
+   [clj-time "0.10.0"]
    ;[com.fasterxml.jackson.core/jackson-databind "2.6.6"]
    ;[com.fasterxml.jackson.core/jackson-annotations "2.6.5"]
    ;[commons-codec "1.10"]


bump boot example to 0.1.7

bump boot example to 0.1.7

--- example/build.boot
+++ example/build.boot
@@ -4,7 +4,7 @@
  :dependencies '[[org.clojure/core.async      "0.1.346.0-17112a-alpha"]
                  [org.clojure/clojurescript   "1.7.170"]
                  [crisptrutski/boot-cljs-test "0.2.1-SNAPSHOT"]
-                 [doo                         "0.1.7-SNAPSHOT"]])
+                 [doo                         "0.1.7"]])

 (require
  '[crisptrutski.boot-cljs-test :refer [test-cljs]])


Mark body-string as returning String

Mark body-string as returning String

Prevent reflection in callers.

--- ring-core/src/ring/util/request.clj
+++ ring-core/src/ring/util/request.clj
@@ -44,7 +44,7 @@
   (if-let [^String type (content-type request)]
     (.startsWith type "application/x-www-form-urlencoded")))

-(defmulti body-string
+(defmulti ^String body-string
   "Return the request body as a string."
   {:arglists '([request]), :added "1.2"}
   (comp class :body))


working on moving morphology to database

--- src/babel/italiano/morphology/verbs.cljc
+++ src/babel/italiano/morphology/verbs.cljc
@@ -30,16 +30,38 @@
                 {:essere (get-in pattern [:synsem :essere] :top)}))
        patterns))

+(defn compile-morphology []
+  (let [tenses-map
+        {"conditional" {:synsem {:infl :conditional}}
+         "future"      {:synsem {:infl :future}}
+         "imperfetto"  {:synsem {:infl :imperfetto}}
+         "present"     {:synsem {:infl :present}}
+         "subjunctive" {:synsem {:infl :subjunctive}}
+         "gerund"      {:synsem {:infl :gerund}}
+
+         ;; TODO: make this :passato; then we can do away with this entire mapping of tense names to specs.
+         "passato"     {:synsem {:infl :past}}}]
+
+    (reduce
+     merge
+     (map (fn [tense]
+            (let [patterns
+                  (-> (str "babel/italiano/morphology/verbs/" tense ".edn")
+                      clojure.java.io/resource
+                      slurp
+                      read-string
+                      patterns-with-agr)]
+              {tense
+               (compile-patterns
+                (get tenses-map tense)
+                patterns)}))
+          (keys tenses-map)))))
+
+(def morph-map (compile-morphology))
+
 ;; <conditional>
-(let [patterns
-      (-> (clojure.java.io/resource "babel/italiano/morphology/verbs/conditional.edn")
-          slurp
-          read-string
-          patterns-with-agr)]
-  (defonce patterns-conditional
-    (compile-patterns
-     {:synsem {:infl :conditional}}
-     patterns)))
+(defonce patterns-conditional
+  (get morph-map "conditional"))

 (defn regular-conditional [word]
   (let [unifying-patterns
@@ -149,7 +171,7 @@
           patterns-with-agr)]
   (defonce patterns-subjunctive
     (compile-patterns
-     {:synsem {:infl :past}}
+     {:synsem {:infl :subjunctive}}
      source)))
 ;; </subjunctive>


close leader-elections on nimbus shutdown (release leadership mutex)

--- src/clj/backtype/storm/daemon/nimbus.clj
+++ src/clj/backtype/storm/daemon/nimbus.clj
@@ -1101,6 +1101,7 @@
         (.disconnect (:storm-cluster-state nimbus))
         (.cleanup (:downloaders nimbus))
         (.cleanup (:uploaders nimbus))
+        (.close leader-elections)
         (log-message "Shut down master")
         )
       DaemonCommon


More .navbar-nav -> tailwind

More .navbar-nav -> tailwind

--- src/cljs/my_money/components/navbar.cljs
+++ src/cljs/my_money/components/navbar.cljs
@@ -14,16 +14,17 @@
      :on-click #(reset! collapsed? true)} title]])

 (defn user-menu [e!]
-  (if-let [user (session/get :identity)]
-    [:ul.navbar-nav.ml-auto
-     [:li.nav-item
-      [:a.btn.btn-outline-danger.btn-sm-ml-1
-       {:href "#"
-        :on-click #(e! (ac/->Logout))}
-       [:i.fa.fa-user " " user " | log out"]]]]
-    [:ul.navbar-nav.ml-auto
-     [:li.nav-item [login/login-button]]
-     [:li.nav-item [registration/registration-button]]]))
+  [:ul.flex.pl-0.mb-0.list-none.ml-auto
+   (if-let [user (session/get :identity)]
+     [:<>
+      [:li.nav-item
+       [:a.btn.btn-outline-danger.btn-sm-ml-1
+        {:href "#"
+         :on-click #(e! (ac/->Logout))}
+        [:i.fa.fa-user " " user " | log out"]]]]
+     [:<>
+      [:li.nav-item [login/login-button]]
+      [:li.nav-item [registration/registration-button]]])])

 (defn navbar [e!]
   (let [collapsed? (r/atom true)]


refactor apply for badge link and button

--- src/cljs/salava/social/ui/dashboard.cljs
+++ src/cljs/salava/social/ui/dashboard.cljs
@@ -190,10 +190,10 @@
   (let [block (first (plugin-fun (session/get :plugins)  "application" "latestearnablebadges"))]
     (if block [block] [:div ""])))

-(defn application-button []
+(defn application-button [opt]
   (let [button (first (plugin-fun (session/get :plugins) "application" "button"))]
     (if button
-      [button]
+      [button opt]
       [:div ""])))

 (defn badges-block [state]
@@ -207,7 +207,7 @@
           [:div.heading_1
            [:i.fa.fa-certificate.icon]
            [:a {:href (path-for "/badge")} [:span.title (t :badge/Badges)]]]
-          (when-not (not-activated?)  [application-button]); [:button.btn.button "Earn badges"]
+          (when-not (not-activated?)  [application-button "button"]); [:button.btn.button "Earn badges"]
           [:div.content
            [:div.stats
             [:div.total-badges
@@ -353,7 +353,7 @@
        [:div.content[:a {:href (str (path-for "/user/profile/") (session/get-in [:user :id]))}[:p (t :social/Iwanttoseeprofile)]]
        [:a {:href (str (path-for "/user/edit/profile"))}[:p (t :social/Iwanttoeditprofile)]]
        [:a {:href (str (path-for "/badge"))}[:p (t :social/Iwanttoseemysbadges)]]
-       (when (some #(= % "extra/application") (session/get :plugins))[:p (t :social/Iwanttoearnnewbadges)])
+       [application-button "link"]
        [:a {:href (str (path-for "/gallery/badges"))} [:p (t :social/Iwanttofindbadges)]]]]]]]])

 (defn content [state]


handler remove redirecting to error page -> show errors in modal by default

--- src/cljs/swarmpit/component/handler.cljs
+++ src/cljs/swarmpit/component/handler.cljs
@@ -2,9 +2,9 @@
   (:refer-clojure :exclude [get])
   (:require [ajax.core :as ajax]
             [swarmpit.router :as router]
-            [swarmpit.routes :as routes]
             [swarmpit.url :refer [dispatch!]]
             [swarmpit.storage :as storage]
+            [swarmpit.component.message :as message]
             [swarmpit.component.progress :as progress]
             [clojure.walk :refer [keywordize-keys]]))

@@ -16,9 +16,10 @@
 (defn- command-error
   [resp-body resp-status]
   (case resp-status
+    400 (message/error (str (:error resp-body)))
     401 (router/set-location {:handler :login})
     403 (router/set-location {:handler :unauthorized})
-    500 (dispatch! (routes/path-for-frontend :error {} {:stacktrace resp-body}))))
+    500 (message/error (str (:cause resp-body)))))

 (defn- command
   [request]


adding send message to session

adding send message to session

--- src/clojure/my/company/superapp/main.clj
+++ src/clojure/my/company/superapp/main.clj
@@ -63,11 +63,15 @@
                                    (onOpen []
                                      (log/i "onOpen")
                                      ;; TODO - need to check how to get session-id
-                                     (swap! wsd-sessions :sessiond handshake))
+                                     (swap! wsd-sessions :sessiond this))
                                    (onClose [code, reason, initiated-by-remote]
                                      (log/i "onClose"))
                                    (onMessage [message]
-                                     (log/i "onMessage"))
+                                     (log/i "onMessage")
+                                     (.send this "thanks")
+                                     (dotimes [n 8]
+                                       (.send this (str "sending message:" n)))
+                                     (log/i "done with this session...")
                                    (onPong [pong]
                                      (log/i "onPong"))
                                    (onException [exception]


new option compliance

new option compliance

--- src/clojure/zensols/actioncli/log4j2.clj
+++ src/clojure/zensols/actioncli/log4j2.clj
@@ -40,7 +40,7 @@
    (log-level-set-option "-l" "--level"))
   ([short long]
    [short long "Log level to set in the Log4J2 system."
-    :required "LOG LEVEL"
+    :required "log level"
     :default (Level/toLevel "info")
     :parse-fn #(Level/toLevel % nil)
     :validate [(fn [level]


Add :new-errors-prospective-when-necessary diversification test

--- src/clojush/pushgp/genetic_operators.clj
+++ src/clojush/pushgp/genetic_operators.clj
@@ -1718,6 +1718,36 @@
              (not= errs (take (count errs) (:parent2-errors argmap))))))
     (assoc ind :diversifying true)))

+(defn new-errors-prospective-when-necessary-diversifying?
+  [ind argmap]
+  (if (not (:print-history argmap))
+    (throw
+     (Exception.
+      ":print-history must be true for :new-errors-prospective-when-necessary diversification test"))
+    (let [errs (or (:errors ind)
+                   (do
+                     (swap! evaluations-count inc)
+                     (:errors ((:error-function argmap)
+                               {:genome (:genome ind)
+                                :program (translate-plush-genome-to-push-program
+                                          {:genome (:genome ind)}
+                                          argmap)}))))]
+      (assoc ind :diversifying
+             (if (not (empty? (:parent1-history argmap)))
+               (not (some #{errs} (:parent1-history argmap)))
+               (let [g (:genome ind)
+                     c (produce-child-genome-by-autoconstruction g g argmap)]
+                 (if (empty? c)
+                   false
+                   (not= errs
+                         (do
+                           (swap! evaluations-count inc)
+                           ((:error-function argmap)
+                            {:genome c
+                             :program (translate-plush-genome-to-push-program
+                                       {:genome c}
+                                       argmap)}))))))))))
+
 (defn new-instruction-diversifying?
   [ind {:keys [parent1-genome parent2-genome] :as argmap}]
   (let [child-instructions (set (map :instruction (:genome ind)))
@@ -1836,6 +1866,7 @@
                 :minimum-genetic-difference minimum-genetic-difference-diversifying?
                 :different-errors different-errors-diversifying?
                 :new-errors new-errors-diversifying?
+                :new-errors-prospective-when-necessary new-errors-prospective-when-necessary-diversifying?
                 :enough-new-errors enough-new-errors-diversifying?
                 :at-least-half-new-errors at-least-half-new-errors-diversifying?
                 :new-instruction new-instruction-diversifying?


Changed produce-child-genome-by-autoconstruction to return genome as vector.

--- src/clojush/pushgp/genetic_operators.clj
+++ src/clojush/pushgp/genetic_operators.clj
@@ -285,8 +285,8 @@
                                  (assoc :parent1-genome parent1-genome)
                                  (assoc :parent2-genome parent2-genome))))]
     (if (or (seq? run-result) (vector? run-result))
-      run-result
-      ())))
+      (vec run-result)
+      [])))

 (defn expressed-program-sequence-from-genome
   "Returns an open-close sequenc for the program produced by expressing


Changed grain size with dummy parent to be 1.

--- src/clojush/pushgp/genetic_operators.clj
+++ src/clojush/pushgp/genetic_operators.clj
@@ -102,7 +102,7 @@
            (empty? genome))
      1
      (if (some :dummy [parent1 parent2])
-       0
+       1
        (case (:criterion random-screen)
          ;
          :genetic-similarity-to-parent


godef doesn't like the full path for some packages.

--- src/cljs/go.clj
+++ src/cljs/go.clj
@@ -44,7 +44,7 @@
      (let [in (str "package _;"
                    (when (seq (str package))
                      (str "import \"" package "\";"))
-                   "var _ = " (cond->> var package (str package ".")))
+                   "var _ = " (cond->> var package (str (last (s/split package #"\.")) ".")))
            {:keys [exit err out]} (sh/sh "godef" "-i" "-t" "-o" (str (count in)) :in in)]
        (if (zero? exit)
          (let [[loc & def] (s/split-lines out)


make .nrepl-port more reliable

make .nrepl-port more reliable

by either not writing it at all or always writing it depending
on :nrepl {:write-port-file true} config.

"smart" clients should be using ".shadow-cljs/nrepl.port".

".nrepl-port" is only for fake compatibility

--- src/main/shadow/cljs/devtools/server.clj
+++ src/main/shadow/cljs/devtools/server.clj
@@ -388,12 +388,14 @@
               (assoc :socket-repl (:port socket-repl)))
             )))

-    (when nrepl
+    ;; this will clash with lein writing its own .nrepl-port so it is disabled by default
+    (when (and nrepl
+               (or (get-in config [:nrepl :write-port-file])
+                   (get-in config [:system-config :nrepl :write-port-file])))
       (let [nrepl-port-file (io/file ".nrepl-port")]
-        (when-not (.exists nrepl-port-file)
-          (spit nrepl-port-file (str (:port nrepl)))
-          (swap! port-files-ref assoc :nrepl-port nrepl-port-file)
-          (.deleteOnExit nrepl-port-file))))
+        (spit nrepl-port-file (str (:port nrepl)))
+        (swap! port-files-ref assoc :nrepl-port nrepl-port-file)
+        (.deleteOnExit nrepl-port-file)))

     (. (Runtime/getRuntime) (addShutdownHook shutdown-hook))


Remove leftover dev file

Remove leftover dev file

--- src/braid/dev.clj
+++ src/braid/dev.clj
@@ -1,20 +0,0 @@
-(ns braid.dev.core
-  (:require
-    [mount.core :as mount]
-    ; require core so that all mount modules are pulled in
-    [braid.core]
-    [braid.dev.figwheel :refer [figwheel]]))
-
-(defn start!
-  "Helper function to start Braid components in dev.
-   Does not start the email worker."
-  [port]
-  (->
-    (mount/except #{#'braid.core.server.email-digest/email-jobs})
-    (mount/with-args {:port port})
-    (mount/start)))
-
-(defn stop!
-  "Helper function for stopping all Braid components."
-  []
-  (mount/stop))


Fix bug when printing pipeline doc strings in the plugin

--- src/pipeline/grafter/pipeline/plugin.clj
+++ src/pipeline/grafter/pipeline/plugin.clj
@@ -13,7 +13,8 @@
 ;; form the better!

 (defn collapse-whitespace [s]
-  (string/replace s #"(\n| )+" " "))
+  (when s
+    (string/replace s #"(\n| )+" " ")))

 (def format-str "%-60s %-9s %-20s %s")


Return run pairs sorted by size of input - smallest to largest


(PDB-2478) services: extract gc code

(PDB-2478) services: extract gc code

Move the gc/maintenance code to a separate function.

--- src/puppetlabs/puppetdb/cli/services.clj
+++ src/puppetlabs/puppetdb/cli/services.clj
@@ -63,14 +63,17 @@
             [puppetlabs.puppetdb.scf.migrate :refer [migrate! indexes!]]
             [puppetlabs.puppetdb.scf.storage :as scf-store]
             [puppetlabs.puppetdb.scf.storage-utils :as sutils]
+            [puppetlabs.puppetdb.schema :as pls :refer [defn-validated]]
             [puppetlabs.puppetdb.time :refer [to-seconds to-millis parse-period
                                               format-period period?]]
             [puppetlabs.puppetdb.utils :as utils]
             [puppetlabs.trapperkeeper.core :refer [defservice] :as tk]
             [puppetlabs.trapperkeeper.services :refer [service-id service-context]]
             [robert.hooke :as rh]
+            [schema.core :as s]
             [slingshot.slingshot :refer [throw+ try+]])
-  (:import [javax.jms ExceptionListener]))
+  (:import [javax.jms ExceptionListener]
+           [org.joda.time Period]))

 (def cli-description "Main PuppetDB daemon")
 (def database-metrics-registry (get-in metrics/metrics-registries [:database :registry]))
@@ -97,7 +100,8 @@
       (log/error e "Error while deactivating stale nodes"))))

 (defn purge-nodes!
-  "Delete nodes which have been *deactivated or expired* longer than `node-purge-ttl`."
+  "Delete nodes which have been *deactivated or expired* longer than
+  `node-purge-ttl`."
   [node-purge-ttl db]
   {:pre [(map? db)
          (period? node-purge-ttl)]}
@@ -147,6 +151,33 @@
       (scf-store/garbage-collect! db))
     (catch Exception e
       (log/error e "Error during garbage collection"))))
+
+(def clean-options #{"expire_nodes" "purge_nodes" "purge_reports" "other"})
+
+(def clean-request-schema
+  [(apply s/enum clean-options)])
+
+(defn-validated clean-up
+  "Cleans up the resources specified by request, or everything if
+  request is empty?."
+  [db
+   {:keys [node-ttl node-purge-ttl report-ttl]} :- {:node-ttl Period
+                                                    :node-purge-ttl Period
+                                                    :report-ttl Period
+                                                    s/Keyword s/Any}
+   ;; Later, the values might be maps, i.e. {:limit 1000}
+   request :- clean-request-schema]
+  (let [request (if (empty? request) clean-options (set request))]
+    (when (request "expire_nodes")
+      (auto-expire-nodes! node-ttl db))
+    (when (request "purge_nodes")
+      (purge-nodes! node-purge-ttl db))
+    (when (request "purge_reports")
+      (sweep-reports! report-ttl db))
+    ;; It's important that this go last to ensure anything referencing
+    ;; an env or resource param is purged first.
+    (when (request "other")
+      (garbage-collect! db))))

 (defn maybe-check-for-updates
   [config read-db]
@@ -242,8 +273,7 @@
                 database read-database
                 puppetdb command-processing]} config
         {:keys [pretty-print]} developer
-        {:keys [gc-interval dlo-compression-interval node-ttl
-                node-purge-ttl report-ttl]} database
+        {:keys [gc-interval dlo-compression-interval]} database
         {:keys [dlo-compression-threshold]} command-processing
         {:keys [disable-update-checking]} puppetdb

@@ -285,21 +315,26 @@
       ;; Pretty much this helper just knows our job-pool and gc-interval
       (let [job-pool (mk-pool)
             gc-interval-millis (to-millis gc-interval)
-            dlo-compression-interval-millis (to-millis dlo-compression-interval)
-            seconds-pos? (comp pos? to-seconds)
-            db-maintenance-tasks (fn []
-                                   (do
-                                     (when (seconds-pos? node-ttl) (auto-expire-nodes! node-ttl write-db))
-                                     (when (seconds-pos? node-purge-ttl) (purge-nodes! node-purge-ttl write-db))
-                                     (when (seconds-pos? report-ttl) (sweep-reports! report-ttl write-db))
-                                     ;; Order is important here to ensure
-                                     ;; anything referencing an env or resource
-                                     ;; param is purged first
-                                     (garbage-collect! write-db)))]
+            dlo-compression-interval-millis (to-millis dlo-compression-interval)]
         (when (pos? gc-interval-millis)
-          ;; Run database maintenance tasks seqentially to avoid
-          ;; competition. Each task must handle its own errors.
-          (interspaced gc-interval-millis db-maintenance-tasks job-pool))
+          (let [seconds-pos? (comp pos? to-seconds)
+                what (filter identity
+                             [(when-let [node-ttl (:node-ttl database)]
+                                (when (seconds-pos? node-ttl)
+                                  "expire_nodes"))
+                              (when-let [node-purge-ttl (:node-purge-ttl database)]
+                                (when (seconds-pos? node-purge-ttl)
+                                  "purge_nodes"))
+                              (when-let [report-ttl (:report-ttl database)]
+                                (when (seconds-pos? report-ttl)
+                                  "purge_reports"))
+                              "other"])]
+            (interspaced gc-interval-millis
+                         #(try
+                            (clean-up write-db database what)
+                            (catch Exception ex
+                              (log/error ex)))
+                         job-pool)))
         (when (pos? dlo-compression-interval-millis)
           (interspaced dlo-compression-interval-millis
                        #(compress-dlo! dlo-compression-threshold discard-dir)


refactoring betweenness

refactoring betweenness

--- src/clj/owl/betweenness.clj
+++ src/clj/owl/betweenness.clj
@@ -11,71 +11,76 @@
     (or (nil? entry) (< entry 0))))

 (defn visit-neighbor
-  [found neighbor dependence queue]
-  (if (undiscovered? neighbor dependence)
-    (let [preexisting (get dependence found)
-          dependence (assoc dependence neighbor (inc preexisting))
-          queue (conj queue neighbor)]
-      [dependence queue])
-    [dependence queue]))
+  [state found neighbor]
+  (if (undiscovered? neighbor (:dependence state))
+    (let [preexisting (get-in state [:dependence found])]
+      (-> state
+          (assoc-in [:dependence neighbor] (inc preexisting))
+          (update-in [:queue] #(conj % neighbor))))
+    state))

 (defn shortest-path?
   [found neighbor dependence]
-  (= (get dependence neighbor) (inc (get dependence found))))
+  (= (get dependence neighbor)
+     (inc (get dependence found))))

 (defn find-shortest
-  [found neighbor dependence paths visited]
-  (if (shortest-path? found neighbor dependence)
-    (let [found-path (get paths found)
-          paths (update-in paths [neighbor] #(+ (or % 0) found-path))
-          visited (update-in visited [neighbor] #(conj % found))]
-      [paths visited])
-    [paths visited]))
+  [state found neighbor]
+  (if (shortest-path? found neighbor (:dependence state))
+    (let [found-path (get-in state [:paths found])]
+      (-> state
+          (update-in [:paths neighbor] #(+ (or % 0) found-path))
+          (update-in [:visited neighbor] #(conj % found))))
+    state))
+
+(defn dependence-state
+  [node]
+  {:stack (list)
+   :dependence {node 0}
+   :queue (conj (empty-queue) node)
+   :paths {node 1}
+   :visited {}})
+
+(defn process-neighbor
+  [found state neighbor]
+  (-> state
+      (visit-neighbor found neighbor)
+      (find-shortest found neighbor)))

 (defn node-dependence
   [node network]
-  (loop [stack (list)
-         dependence {node 0}
-         queue (conj (empty-queue) node)
-         paths {node 1}
-         visited {}]
-    (if-let [found (first queue)]
-      (let [queue (pop queue)
-            stack (conj stack found)
+  (loop [state (dependence-state node)]
+    (if-let [found (-> state :queue first)]
+      (let [state (-> state
+                      (update-in [:queue] pop)
+                      (update-in [:stack] #(conj % found)))
             neighbors (get network found)
-            [dependence queue paths visited]
-            (reduce
-             (fn [[dependence queue paths visited] neighbor]
-               (let [[dependence queue] (visit-neighbor found neighbor dependence queue)
-                     [paths visited] (find-shortest
-                                      found neighbor dependence paths visited)]
-                 [dependence queue paths visited]))
-             [dependence queue paths visited]
-             neighbors)]
-        (recur stack dependence queue paths visited))
-      [stack dependence queue paths visited])))
+            state (reduce (partial process-neighbor found) state neighbors)]
+        (recur state))
+      state)))
+
+(defn distance-paths
+  [distance paths distant visit]
+  (let [ratio (double (/ (get paths visit 0) (get paths distant 0)))
+        scale (* ratio (inc (get distance distant 0)))]
+    (+ scale (get distance visit 0))))
+
+(defn node-distance
+  [distance paths visited distant]
+  (reduce
+   (fn [distance visit]
+     (assoc-in
+      distance [visit]
+      (distance-paths distance paths distant visit)))
+   distance (get visited distant)))

 (defn node-betweenness
-  [node network betweenness]
-  (let [[stack dependence queue paths visited] (node-dependence node network)
+  [network betweenness node]
+  (let [{:keys [stack paths visited]} (node-dependence node network)
         [betweenness distance]
         (reduce
          (fn [[betweenness distance] distant]
-           (let [distance
-                 (reduce
-                  (fn [distance visit]
-                    (update-in
-                     distance [visit]
-                     (fn [previous]
-                       (let [distant-distance (get distance distant 0)
-                             distant-path (get paths distant 0)
-                             visit-distance (get distance visit 0)
-                             visit-path (get paths visit 0)
-                             ratio (double (/ visit-path distant-path))
-                             scale (* ratio (inc distant-distance))]
-                         (+ scale visit-distance)))))
-                  distance (get visited distant))
-
+           (let [distance (node-distance distance paths visited distant)
                  betweenness
                  (if (= node distant)
                    betweenness
@@ -89,8 +94,7 @@
 (defn pure-network-betweenness
   [network]
   (reduce
-   (fn [betweenness node]
-     (node-betweenness node network betweenness))
+   (partial node-betweenness network)
    {} (keys network)))

 (defn network-betweenness


only write threads with posts

only write threads with posts

--- src/clueweb_disqus/core.clj
+++ src/clueweb_disqus/core.clj
@@ -154,7 +154,8 @@
           (doall
            (doseq [c content-to-write]
              (pprint c wrtr)
-             (println (get c "id") threads-wrtr))))
+             (when (< 0 (get c "posts"))
+               (println (get c "id") threads-wrtr)))))
         (if (.exists (java.io.File. stats-f-to-write))
           (let [cnt
                 (+ (read-string (slurp stats-f-to-write))


Add mongo to repl conveniences

Add mongo to repl conveniences

--- backend/src/circle/repl.clj
+++ backend/src/circle/repl.clj
@@ -7,7 +7,8 @@
     (use 'clojure.repl)
     (use '[clojure.contrib.ns-utils :only (docs)])
     (use '[clojure.contrib.repl-utils :exclude (apropos source)])
-    (use '[circle.backend.ec2 :only (instances print-instances)]))
+    (use '[circle.backend.ec2 :only (instances print-instances)])
+    (require '[somnium.congomongo :as mongo]))
   (println "repl/init done"))


Change implementation of typical-measured-depth

--- src/test_utils/fracture_diagnostics.cljc
+++ src/test_utils/fracture_diagnostics.cljc
@@ -137,8 +137,8 @@
   ([] (typical-measured-depth (rand-length-unit)))
   ([length-unit]
    (case length-unit
-     :ft (make-measurement (+ (tuc/draw-normal 8000 1216)  ;; horizontal portion
-                              (typical-measured-depth-of-vertical length-unit))
+     :ft (make-measurement (+ (magnitude (typical-measured-depth-of-vertical length-unit))
+                              (magnitude (typical-extent-of-horizontal length-unit)))
                            length-unit)
      :m (length-as (typical-measured-depth) length-unit))))


cmdline switch for userauth.

cmdline switch for userauth.

--- src/cavm/core.clj
+++ src/cavm/core.clj
@@ -135,14 +135,20 @@
                          java.io.PushbackReader.)]
     (clojure.edn/read reader)))

+(defn wrap-authentication [app userauth port]
+  (if userauth
+    (auth/wrap-google-authentication
+      app
+      (str (local-url port) "/") ; XXX local-url? Is this correct?
+      "/code"
+      (auth/load-users "users.txt")
+      (load-edn-from "auth.config"))
+    app))
+
 ; XXX add ring jsonp?
-(defn- get-app [docroot db loader port]
+(defn- get-app [docroot db loader port userauth]
   (-> cavm.views.datasets/routes
-      (auth/wrap-google-authentication
-       (str (local-url port) "/")
-       "/code"
-       (auth/load-users "users.txt")
-       (load-edn-from "auth.config"))
+      (wrap-authentication userauth port)
       (wrap-trace :header :ui)
       (attr-middleware :docroot docroot)
       (attr-middleware :db db)
@@ -240,6 +246,7 @@
    [nil "--certfile FILE" "Cert file to use (requires --keyfile)"]
    [nil "--version" "Print version and exit"]
    ["-j" "--json" "Fix json"]
+   [nil "--userauth" "Enable user-based authentication"]
    ["-t" "--tmp DIR" "Set tmp dir" :default tmp-dir-default]])

 (defn- mkdir [dir]
@@ -319,6 +326,7 @@
         gui (:gui options)
         certfile (:certfile options)
         keyfile (:keyfile options)
+        userauth (:userauth options)
         keystore (if keyfile
                    {:keystore (ssl/key-store keyfile certfile)
                     :password (String. ^chars ssl/key-store-password)}
@@ -365,7 +373,7 @@
                               (println "Failed to start gui. Logging error.")
                               (error "Failed to start gui." ex)))))
                       (when (:serve options)
-                        (serv (get-app docroot db loader port) host port keystore))))))
+                        (serv (get-app docroot db loader port userauth) host port keystore))))))
         (catch Exception ex
           ; XXX maybe should enable ERROR logging to console, instead of this.
           (binding [*out* *err*]


Add HoursOpen validation to v5 validations

--- src/vip/data_processor/validation/v5.clj
+++ src/vip/data_processor/validation/v5.clj
@@ -5,7 +5,8 @@
             [vip.data-processor.validation.v5.precinct :as precinct]
             [vip.data-processor.validation.v5.source :as source]
             [vip.data-processor.validation.v5.retention-contest :as retention-contest]
-            [vip.data-processor.validation.v5.state :as state]))
+            [vip.data-processor.validation.v5.state :as state]
+            [vip.data-processor.validation.v5.hours-open :as hours-open]))

 (def validations
   [candidate/validate-no-missing-ballot-names
@@ -22,4 +23,5 @@
    source/validate-vip-id
    source/validate-vip-id-valid-fips
    retention-contest/validate-no-missing-candidate-ids
-   state/validate-no-missing-names])
+   state/validate-no-missing-names
+   hours-open/validate-times])


Add PreElectionStatus validation to v5 validators

--- src/vip/data_processor/validation/v5.clj
+++ src/vip/data_processor/validation/v5.clj
@@ -5,6 +5,7 @@

 (def validations
   [candidate/validate-no-missing-ballot-names
+   candidate/validate-pre-election-statuses
    candidate/validate-post-election-statuses
    email/validate-emails
    id/validate-unique-ids


Fix issue with aliases and letter highlighting

--- ccw.core/src/clj/ccw/editors/clojure/clojure_proposal_processor.clj
+++ ccw.core/src/clj/ccw/editors/clojure/clojure_proposal_processor.clj
@@ -159,8 +159,9 @@
       ICompletionProposalExtension6
       (getStyledDisplayString [this]
         (let [s (StyledString. (or display-string ""))]
-          (doseq [i (reductions (partial + 1) filter)]
-            (.setStyle s i 1 StyledString/COUNTER_STYLER))
+          (when (seq filter)
+            (doseq [i (reductions (partial + 1) filter)]
+              (.setStyle s i 1 StyledString/COUNTER_STYLER)))
           s)))))

 (defn context-information


Refactor tests

Refactor tests


[#1077] First steps on data options

[#1077] First steps on data options

--- backend/src/akvo/lumen/lib/visualisation/map_config.clj
+++ backend/src/akvo/lumen/lib/visualisation/map_config.clj
@@ -1,5 +1,6 @@
 (ns akvo.lumen.lib.visualisation.map-config
-  (:require [clojure.string :as str]
+  (:require [clojure.java.jdbc :as jdbc]
+            [clojure.string :as str]
             [honeysql.core :as sql]
             [hugsql.core :as hugsql]))

@@ -25,7 +26,6 @@
 (defn compile-sql
   [table geom-column popups]
   (let [geom-spec [geom-column "geom"]
-
         selects (vec (map #(let [[alias column] (first %)]
                              [column alias])
                           popups))
@@ -34,11 +34,25 @@
         fmt-string (str/replace prepared-statement #"\?" "%s")]
     (apply (partial format fmt-string) args)))

+#_(defn point-colors
+    [tenant-conn table-name pointColorColumn]
+    (prn tenant-conn)
+    (prn table-name)
+    (prn pointColorColumn)
+    (jdbc/query tenant-conn (sql/format {:select [[pointColorColumn "options"]
+                                                  [:%count.* "n"]]
+                                         :from [table-name]
+                                         :group-by [pointColorColumn]
+                                         :limit 5})))
+
 (defn map-config-layer
-  [tenant-conn {:strs [datasetId popup pointSize]}]
+  [tenant-conn {:strs [datasetId popup pointSize pointColorColumn]}]
   (let [dataset (dataset-by-id tenant-conn {:id datasetId})
         table-name (:table-name dataset)
-        geom-column "d1"]
+        geom-column "d1"
+        ;; point-options (point-colors tenant-conn table-name pointColorColumn)
+        ;; _ (prn point-options)
+        ]
     {"type" "mapnik"
      "options" {"cartocss" (cartocss pointSize)
                 "cartocss_version" "2.0.1"


placeholder: ordering of map values in Clojure

--- clojure/maps.clj
+++ clojure/maps.clj
@@ -1,5 +1,5 @@
-(def scores {"Fred"  1400
-             "Bob"   1240
+(def scores {"Fred"   1400
+             "Bob"    1240
              "Angela" 1024})
 (println scores)


added a git configure step when adding heroku repo as a remote

--- src/dmgr/core.clj
+++ src/dmgr/core.clj
@@ -45,10 +45,12 @@
   {:fetch-and-reset  (format   "cd  %s /repo && git fetch && git reset --hard origin/master" app-name)
    :clone (format "cd %s  && git clone https://%s repo" app-name  github-repo-uri)
    ;;   :push-to-heroku (format "cd %s/repo && heroku git:remote -a %s && git push heroku master" app-name app-name app-name  heroku-repo-uri)
-   :push-to-heroku (format "cd %s/repo && git remote add heroku git@heroku.com:%s.git && git push heroku master"
+   :push-to-heroku (format "cd %s/repo && git remote add heroku git@heroku.com:%s.git &&  git config heroku.remote heroku && git push heroku master"
                            app-name app-name)
    :remove-staging-dir (format "rm -rf %s" app-name)})

+:push-to-heroku
+;;   (run app-path (str "cd " app "/repo && bundle install --without=production && bundle exec jekyll build && git add . && git commit -am 'auto-build update' && git push -f " (env (str app "_HEROKU_REPO")) " master"))

 (defn prepare-staging-area
   "Create a staging area"


Fix copyright year on session backend namespace.

--- src/clojure/buddy/auth/backends/session.clj
+++ src/clojure/buddy/auth/backends/session.clj
@@ -1,4 +1,4 @@
-;; Copyright 2013 Andrey Antukh <niwi@niwi.be>
+;; Copyright 2014 Andrey Antukh <niwi@niwi.be>
 ;;
 ;; Licensed under the Apache License, Version 2.0 (the "License")
 ;; you may not use this file except in compliance with the License.


Caching works now, just multiple preconditions left.

--- src/exp/sas.clj
+++ src/exp/sas.clj
@@ -244,7 +244,7 @@
         extended-rdtgs              (make-extended-reverse-dtgs vars actions)]
     (filter
      (fn [[[var1 val1] [var2 val2]]]
-       (when (< (.compareTo var1 var2) 0)
+       (when (< (.compareTo #^Comparable var1 #^Comparable var2) 0)
          (every? (fn [[var val other-var other-val]]
                    (every? (fn [a] (not (= (get (:effect-map a) other-var other-val) other-val)))
                            (apply concat (vals ((extended-dtgs var) val)))))
@@ -426,7 +426,7 @@
 (defn backward-simplify [sas-problem]
   (let [{:keys [vars actions init]} sas-problem
         extended-dtgs               (make-extended-dtgs vars actions)
-        dead-actions                (HashSet. actions)
+        dead-actions                (HashSet. #^java.util.Collection actions)
         now-live-actions            (HashSet.)
         new-goals                   (make-map-of-sets (keys vars))
         new-srcs                    (make-map-of-sets (keys vars))
@@ -441,20 +441,20 @@
     (while (not (.isEmpty dirty-var-set))
       (let [var (first dirty-var-set)]
         (println "doing" var)
-        (while (or (not (.isEmpty (get new-goals var))) (not (.isEmpty (get new-srcs var))))
+        (while (or (not (.isEmpty #^HashSet (get new-goals var))) (not (.isEmpty #^HashSet (get new-srcs var))))
           (if (not (empty? (get new-goals var)))
             (let [new-goal (first (get new-goals var))]
               (println " doing goal" new-goal)
               (doseq [old-src (get old-srcs var)]
                 (assert (exhaustive-dfs old-src new-goal (get extended-dtgs var) #{} dead-actions now-live-actions)))
-              (.remove (get new-goals var) new-goal)
-              (.add    (get old-goals var) new-goal))
+              (.remove #^HashSet (get new-goals var) new-goal)
+              (.add    #^HashSet (get old-goals var) new-goal))
             (let [new-src (first (get new-srcs var))]
               (println " doing src" new-src)
               (doseq [old-goal (get old-goals var)]
                 (assert (exhaustive-dfs new-src old-goal (get extended-dtgs var) #{} dead-actions now-live-actions)))
-              (.remove (get new-srcs var) new-src)
-              (.add    (get old-srcs var) new-src)))
+              (.remove #^HashSet (get new-srcs var) new-src)
+              (.add    #^HashSet (get old-srcs var) new-src)))
           (doseq [a (seq now-live-actions)]
             (doseq [[pvar pval] (:precond-map a)]
               (add-mos-new dirty-var-set old-goals new-goals pvar pval))
@@ -473,24 +473,27 @@

 (def *vars* nil)
 (def *reverse-dtgs* nil)
-(def #^HashMap *hla-cache* nil) ; a map from [action-name] to map from init-sets to action.
+(def #^HashMap *hla-cache* (HashMap.)) ; a map from [action-name] to map from init-sets to action.

 (defprotocol SAS-Induced-Action
   (precond-var-set [a])
-;  (init-sets       [a])
+  (initial-sets    [a])
   (effect-sets     [a]))

 (extend ::env/FactoredPrimitive
   SAS-Induced-Action
     {:precond-var-set (fn [a] (util/keyset (:precond-map a)))
+     :initial-sets    (fn [a] (util/map-vals (fn [x] #{x}) (:precond-map a)))
      :effect-sets     (fn [a] (util/map-vals (fn [x] #{x}) (:effect-map a)))})

+(defn vv-hla-name [var val] [::VV var val])
 (deftype SAS-VV-HLA     [var val precond-vars init-sets effect-sets refinements]
   SAS-Induced-Action
     (precond-var-set [] precond-vars)
+    (initial-sets    [] init-sets)
     (effect-sets     [] effect-sets)
   env/Action
-    (action-name [] [::VV var val])
+    (action-name [] (vv-hla-name var val))
     (primitive?  [] false)
   env/ContextualAction
     (precondition-context [s] (assert (util/subset? (util/keyset effect-sets) precond-vars)) precond-vars)
@@ -498,12 +501,14 @@
     (immediate-refinements- [s] refinements)
     (cycle-level-           [s] nil))

+(defn action-hla-name [action] [::A (env/action-name action)])
 (deftype SAS-Action-HLA [action  precond-vars init-sets effect-sets refinements]
   SAS-Induced-Action
     (precond-var-set [] precond-vars)
+    (initial-sets    [] init-sets)
     (effect-sets     [] effect-sets)
   env/Action
-    (action-name [] [::A (env/action-name action)])
+    (action-name [] (action-hla-name action))
     (primitive?  [] false)
   env/ContextualAction
     (precondition-context [s] (assert (util/subset? (util/keyset effect-sets) precond-vars)) precond-vars)
@@ -546,7 +551,8 @@
 ;; Want to look at acyclic paths, which include at most one free-action. (with no precond on var.)
 ;; Two things we can do here; recursive style (works from any src, more caching) or direct style
  ;; (avoid cycles, more focused description/pruning, but less caching and less general).
-(defn induce-vv-hla [var goal-val init-sets ]
+
+(defn induce-vv-hla- [var goal-val init-sets]
   (println "Inducing HLA to get" var "to val" goal-val "from" (init-sets var))
   (let [inits        (init-sets var)
         reverse-dtg  (*reverse-dtgs* var)
@@ -555,19 +561,22 @@
     (if (and (util/singleton? refs-results) (util/singleton? (ffirst refs-results)))
         (first (ffirst refs-results))
       (when (seq refs-results)
+        (assert (apply = (map util/keyset (map second refs-results)))) ;; Otherwise, no-effect not handled properly when not in PC.
         (SAS-VV-HLA var goal-val
                     (set (for [[ref _] refs-results, a ref, v (precond-var-set a)] v))
                     init-sets
                     (apply merge-with clojure.set/union (map second refs-results))
                     (map first refs-results))))))

-(defn induce-action-hla [a init-sets ]
+
+(defn induce-action-hla- [a init-sets ]
   (println "Inducing HLA for preconds + action" (:name a))
   (let [first-bits (for [[pvar pval] (:precond-map a)
                          :when (not (= (init-sets pvar) #{pval}))]
                      (induce-vv-hla pvar pval init-sets ))]
-;    (doall first-bits)
-;    (doseq [b first-bits] (println "\n" b "\n\n"))
+    (doall first-bits)
+;    (println (:name a) (count first-bits))
+;    (doseq [b first-bits] (println "\n" (env/action-name b) "\n\n"))
     (when (every? identity first-bits)
      (if (empty? first-bits)
          a
@@ -580,19 +589,47 @@
           (merge (effect-sets bit) (util/map-vals (fn [x] #{x}) (:effect-map a)))
           [[bit a]]))))))

+
+;; TODO: figure out how much to generalize here.
+(defn cached-induce [name init-sets result-fn]
+  (let [entries (.get *hla-cache* name)]
+    (assert (not (identical? entries :STACK)))
+    (if-let [v (first (filter #(let [ks (precond-var-set %)]
+                                 (= (select-keys init-sets ks) (select-keys (initial-sets %) ks)))
+                              entries))]
+        (do (println "Cache hit for" name)
+            v)
+      (do (.put *hla-cache* name :STACK)
+          (let [ret (result-fn)]
+            (assert ret) ;; If we run into this, need to figure out how to properly cache failures.
+            (.put *hla-cache* name (cons ret entries))
+            ret)))))
+
+(defn induce-action-hla [a init-sets]
+  (cached-induce (action-hla-name a) init-sets #(induce-action-hla- a init-sets)))
+
+(defn induce-vv-hla [var goal-val init-sets ]
+  (cached-induce (vv-hla-name var goal-val) init-sets #(induce-vv-hla- var goal-val init-sets)))
+
 (defn induce-hierarchy [sas-problem]
   (let [{:keys [vars actions init]} sas-problem]
     (binding [*vars*         vars
-              *reverse-dtgs* (make-extended-reverse-dtgs vars actions)]
+              *reverse-dtgs* (make-extended-reverse-dtgs vars actions)
+              *hla-cache*    (HashMap.)
+              ]
       (hierarchy/SimpleHierarchicalEnv sas-problem
         [(util/make-safe
           (induce-action-hla (util/safe-singleton (get-in *reverse-dtgs* [:goal [:true] [:false]]))
                              (util/map-vals (fn [x] #{x}) init)))]))))

+
+
+
+
 (defmulti pretty-print-action type)

 (defn pretty-print-hla [h]
-  (println (str "\nRefs for HLA" (env/action-name h)) (precond-var-set h) (effect-sets h))
+  (println (str "\nRefs for HLA" (env/action-name h)) (precond-var-set h) #_ (effect-sets h))
   (doseq [ref (:refinements h)]
     (println " " (util/str-join ", " (map env/action-name ref))))
   (doseq [ref (:refinements h), a ref]