Lifecycles should be inside task key

Lifecycles should be inside task key

--- src/leiningen/new/onyx_app/src/onyx_app/tasks/sql.clj
+++ src/leiningen/new/onyx_app/src/onyx_app/tasks/sql.clj
@@ -27,18 +27,18 @@
 (s/defn partition-input
   [task-name :- s/Keyword opts :- SqlPartitionInput]
   {:task {:task-map (merge
-                     {:onyx/name task-name
-                      :onyx/plugin :onyx.plugin.sql/partition-keys
-                      :onyx/type :input
-                      :onyx/medium :sql
-                      :sql/columns [:*]
-                      :sql/rows-per-segment 500
-                      :onyx/max-pending 1000
-                      :onyx/max-peers 1
-                      :onyx/doc "Partitions a range of primary keys into subranges"}
-                     opts)}
-   :lifecycles [{:lifecycle/task task-name
-                 :lifecycle/calls :onyx.plugin.sql/read-rows-calls}]
+                      {:onyx/name task-name
+                       :onyx/plugin :onyx.plugin.sql/partition-keys
+                       :onyx/type :input
+                       :onyx/medium :sql
+                       :sql/columns [:*]
+                       :sql/rows-per-segment 500
+                       :onyx/max-pending 1000
+                       :onyx/max-peers 1
+                       :onyx/doc "Partitions a range of primary keys into subranges"}
+                      opts)
+          :lifecycles [{:lifecycle/task task-name
+                        :lifecycle/calls :onyx.plugin.sql/read-rows-calls}]}
    :schema {:task-map (merge os/TaskMap SqlPartitionInput)
             :lifecycles [os/Lifecycle]}})

@@ -60,6 +60,5 @@
                      opts)
           :lifecycles [{:lifecycle/task task-name
                         :lifecycle/calls :onyx.plugin.sql/write-rows-calls}]}
-
    :schema {:task-map (merge os/TaskMap SqlInsertOutput)
             :lifecycles [os/Lifecycle]}})


s/clojure.test.report/clojure.test\/report/

--- src/main/clojure/clojure/test/check/clojure_test.cljc
+++ src/main/clojure/clojure/test/check/clojure_test.cljc
@@ -165,7 +165,7 @@

 (if-not (instance? #?(:clj clojure.lang.MultiFn :cljs MultiFn) ct/report)
   (binding [*out* *err*]
-    (println "clojure.test.report is not a multimethod, some reporting functions have been disabled."))
+    (println "clojure.test/report is not a multimethod, some reporting functions have been disabled."))
   (let [begin-test-var-method (get-method ct/report #?(:clj  :begin-test-var
                                                        :cljs [::ct/default :begin-test-var]))]
     (defmethod ct/report #?(:clj  :begin-test-var


Add summary to dot-report and spec-report

--- src/main/clojure/com/stuartsierra/lazytest/report.clj
+++ src/main/clojure/com/stuartsierra/lazytest/report.clj
@@ -71,25 +71,28 @@
       (do (print ".") (flush))
       (do (newline) (print-details c))))
   (newline)
-  (println "Done."))
+  (print-summary r))

 (defn- spec-report* [r parents]
   (if (seq (:children r))
     (doseq [c (:children r)]
       (spec-report* c (conj parents r)))
-    (when-not (success? r)
-      (newline)
-      (print-details
-       (assoc r :source
-              (vary-meta (:source r) assoc :doc
-                         (apply str (interpose " "
-                                               (filter identity
-                                                       (map #(:doc (details %))
-                                                            (conj parents r)))))))))))
+    (if (success? r)
+      (do (print ".") (flush))
+      (do (newline)
+          (print-details
+           (assoc r :source
+                  (vary-meta (:source r) assoc :doc
+                             (apply str (interpose " "
+                                                   (filter identity
+                                                           (map #(:doc (details %))
+                                                                (conj parents r))))))))))))

-(defn spec-report [r]
+(defn spec-report
+  "Like dot-report but concatenates :doc strings for nested specs."
+  [r]
   (println "Running" (:name (details r)))
   (spec-report* r [])
   (newline)
-  (println "Done."))
+  (print-summary r))


only strip-ansi on strings in auto-flush

this fixes https://github.com/boot-clj/boot/issues/136

--- boot/pod/src/boot/util.clj
+++ boot/pod/src/boot/util.clj
@@ -129,7 +129,11 @@

 (defn auto-flush
   [writer]
-  (let [fmt #(if @*colorize?* % (ansi/strip-ansi %))]
+  (let [fmt (if @*colorize?*
+              identity
+              (fn [s] (if (string? s)
+                        (ansi/strip-ansi s)
+                        s)))]
     (proxy [java.io.PrintWriter] [writer]
       (write [s] (.write writer (fmt s)) (flush)))))


better implementation, yo

better implementation, yo

--- browser/cljs/settings.cljs
+++ browser/cljs/settings.cljs
@@ -1,6 +1,6 @@
 (ns mediakeys.browser.settings
     (:use [mediakeys.browser.events :only [modifiers characters subscribe]]
-          [mediakeys.browser.rx :only [from-async bettersub]])
+          [mediakeys.browser.rx :only [from-async multi-sub]])
     (:require [rx-cljs.observable :as rx]))

@@ -38,7 +38,7 @@

 (def mods (from-async modifiers))

-(def mods1 (bettersub mods #(.log js/console %)))
+(def mods1 (multi-sub mods #(.log js/console %)))

 (rx/subscribe (rx/map mods1 #(str % " yoyoyo")) #(.log js/console %) )
 ; (subscribe modifiers (with-append))


[#8008] Error "No protocol method IDeref.-deref defined for type undefined:" and crash if open DApp permissions

Signed-off-by: Andrey Shovkoplyas <b713972e59b8e606e23253c4a13e948139fea4d1@gmail.com>

--- src/status_im/ui/screens/dapps_permissions/views.cljs
+++ src/status_im/ui/screens/dapps_permissions/views.cljs
@@ -17,16 +17,11 @@
   [react/view styles/icon-container
    [icons/icon :main-icons/dapp {:color colors/gray}]])

-(defn prepare-items [dapps]
-  (fn [{:keys [dapp permissions]}]
-    (merge
-     {:title       dapp
-      :accessories [:chevron]
-      :on-press    #(re-frame/dispatch [:navigate-to :manage-dapps-permissions {:dapp dapp :permissions permissions}])}
-     (let [path (get-in dapps [dapp :photo-path])]
-       (if path
-         {:image-path path}
-         {:image d-icon})))))
+(defn prepare-items [{:keys [dapp permissions]}]
+  {:title       dapp
+   :accessories [:chevron]
+   :on-press    #(re-frame/dispatch [:navigate-to :manage-dapps-permissions {:dapp dapp :permissions permissions}])
+   :image       d-icon})

 (defn prepare-items-manage [permission]
   {:title       (case permission
@@ -36,14 +31,13 @@
    :accessories [:check]})

 (views/defview dapps-permissions []
-  (views/letsubs [permissions [:get :dapps/permissions]
-                  dapps       [:contacts/dapps-by-name]]
+  (views/letsubs [permissions [:get :dapps/permissions]]
     [react/view {:flex 1 :background-color colors/white}
      [status-bar/status-bar]
      [toolbar/simple-toolbar
       (i18n/label :t/dapps-permissions)]
      [list/flat-list
-      {:data      (map (prepare-items dapps) (vals permissions))
+      {:data      (map prepare-items (vals permissions))
        :key-fn    (fn [_ i] (str i))
        :render-fn list-item/list-item}]]))

@@ -57,5 +51,5 @@
        :key-fn    (fn [_ i] (str i))
        :render-fn list-item/list-item}]
      [react/view {:padding-vertical 16}
-      [components.common/red-button {:label (i18n/label :t/revoke-access)
+      [components.common/red-button {:label    (i18n/label :t/revoke-access)
                                      :on-press #(re-frame/dispatch [:dapps/revoke-access dapp])}]]]))


Add `wait-for-condition`

Add `wait-for-condition`

--- test/com/nomistech/clojure_the_language/c_850_utils/s_200_test_utils.clj
+++ test/com/nomistech/clojure_the_language/c_850_utils/s_200_test_utils.clj
@@ -3,6 +3,7 @@
             [midje.sweet :refer :all]))

 ;;;; ___________________________________________________________________________
+;;;; ---- nomis-pp-classpath ----

 (defn nomis-pp-classpath []
   (clojure.pprint/pprint
@@ -10,6 +11,7 @@
                          #":")))

 ;;;; ___________________________________________________________________________
+;;;; ---- chan->seq ----

 (defn chan->seq [c]
   (lazy-seq
@@ -35,3 +37,70 @@
             (a/close! c))
       (chan->seq c))
     => [1 2 3]))
+
+;;;; ___________________________________________________________________________
+;;;; ---- wait-for-condition ----
+
+(defn wait-for-condition
+  "Waits for `test-fun` to return a logical true value, and, if that happens,
+  returns that logical true value.
+  Calls `test-fun` immediately and, after it returns, `delay-ms` later, and
+  so on.
+  After `timeout-ms`, returns logical false.
+  Blocks when waiting."
+  [test-fun & {:keys [timeout-ms
+                      delay-ms
+                      debug?]
+               :or {timeout-ms 1000
+                    delay-ms   50}}]
+  (let [timeout (a/timeout timeout-ms)
+        timed-out? (fn []
+                     (let [zero-timeout (a/timeout 0)
+                           [_ c] (a/alts!! [timeout
+                                            zero-timeout]
+                                           :priority true)]
+                       (= c timeout)))]
+    (loop [cnt 1]
+      (let [finished? (test-fun)]
+        (when debug? (println "cnt =" cnt "time =" (System/currentTimeMillis)))
+        (if finished?
+          finished?
+          (if (timed-out?)
+            false
+            (do
+              (a/<!! (a/timeout delay-ms))
+              (recur (inc cnt)))))))))
+
+(fact "`wait-for-condition` works"
+
+  (fact "works when `test-fun` eventually returns logical true"
+    (let [v (atom :not-done)]
+      (future
+        (Thread/sleep 70)
+        (reset! v :done))
+      (wait-for-condition #(if (= @v :done)
+                             :we-are-done
+                             false)))
+    => :we-are-done)
+
+  (fact "only one call when `test-fun` immediately returns logical true"
+    (let [cnt-atom (atom 0)
+          res (wait-for-condition (fn []
+                                    (swap! cnt-atom inc)
+                                    :we-are-done))]
+      [res @cnt-atom])
+    => [:we-are-done 1])
+
+  (fact "timeout when `test-fun` always returns logical false"
+    (wait-for-condition (fn [] (rand-nth [nil false]))
+                        :timeout-ms 70)
+    => false)
+
+  (fact "correct call count when `test-fun` always returns logical false"
+    (let [cnt-atom (atom 0)
+          res (wait-for-condition (fn []
+                                    (swap! cnt-atom inc)
+                                    nil)
+                                  :timeout-ms 70)]
+      [res @cnt-atom])
+    => [false 3]))


fix test assertion text

fix test assertion text

--- test/keypin/core_test.clj
+++ test/keypin/core_test.clj
@@ -467,11 +467,11 @@
   (is (= "New description"
         (:description mw-foo))  "description added by post-processor")
   (is (= 'config-map
-        (ffirst (:arglists (meta #'mw-foo)))) "config-map is a symbol")
+        (ffirst (:arglists (meta #'mw-foo)))) "ensure config-map argument")
   (is (= {:inject :app-config}
         (meta (ffirst (:arglists (meta #'mw-foo))))) "config-map meta works")
   (is (= 'not-found
-        (second (fnext (:arglists (meta #'mw-foo))))) "not-found is a symbol")
+        (second (fnext (:arglists (meta #'mw-foo))))) "ensure not-found argument")
   (is (= {:foo :bar}
         (meta (second (fnext (:arglists (meta #'mw-foo)))))) "not-found meta works")
   (is (= 1000


update lein-ring to fix main class issue under leiningen 2.5.0

--- src/leiningen/new/yawt/project.clj
+++ src/leiningen/new/yawt/project.clj
@@ -35,7 +35,7 @@
                  [edn-config "0.2"]
                  [prone "0.6.0"]]

-  :plugins      [[lein-ring "0.8.10"]
+  :plugins      [[lein-ring "0.8.12"]
 {{#webapp}}
                  [lein-cljsbuild "1.0.3"]
 {{/webapp}}


CMR-2416: Fixing failing tests

CMR-2416: Fixing failing tests

--- system-int-test/test/cmr/system_int_test/search/granule_search_format_test.clj
+++ system-int-test/test/cmr/system_int_test/search/granule_search_format_test.clj
@@ -367,7 +367,7 @@
                                 :spatial-coverage (dg/spatial
                                                     (poly/polygon
                                                       :geodetic
-                                                      [(rr/ords->ring :geodetic -70 20, 70 20, 70 30, -70 30, -70 20)])
+                                                      [(rr/ords->ring :geodetic [-70 20, 70 20, 70 30, -70 30, -70 20])])
                                                     polygon-with-holes
                                                     (p/point 1 2)
                                                     (p/point -179.9 89.4)


(PDB-5217) Redo trusted facts optimization

This was lost in a merge conflict with 442ff53f6

--- src/puppetlabs/puppetdb/query_eng/engine.clj
+++ src/puppetlabs/puppetdb/query_eng/engine.clj
@@ -1828,7 +1828,13 @@
   ;; when there's any match().  Perhaps change in the next X release,
   ;; or next endpoint version.
   (let [parts (parse/parse-field field)]
-    (when (some #(= ::parse/match-field-part (:kind %)) parts)
+    (if-not (some #(= ::parse/match-field-part (:kind %)) parts)
+      ;; dotted path without any match() parts, if querying trusted
+      ;; prepend "facts." so that it hits the merged jsonb index instead
+      ;; of needing to scan the table.
+      (if (= "trusted" (:name (first parts)))
+        [operator (str "facts." field) value]
+        [operator field value])
       (let [[head & path] parts
             path (if (= (:name head) "trusted")
                    ;; Real location is facts.trusted...


Fix tests

Fix tests

--- backend/test/akvo/lumen/lib/user_test.clj
+++ backend/test/akvo/lumen/lib/user_test.clj
@@ -18,7 +18,7 @@

 (def keycloak-config (let [c (tu/start-config)]
-                       (merge (select-keys (:akvo.lumen.component.keycloak/keycloak c) [:credentials])
+                       (merge (select-keys (:akvo.lumen.component.keycloak/keycloak c) [:credentials :max-user-ids-cache])
                               {:data (:akvo.lumen.component.keycloak/data c)}
                               )))


CMR-2029: Fixed ISO xml validation error on Distribution media.

--- umm-spec-lib/src/cmr/umm_spec/umm_to_xml_mappings/iso19115_2/distributions_related_url.clj
+++ umm-spec-lib/src/cmr/umm_spec/umm_to_xml_mappings/iso19115_2/distributions_related_url.clj
@@ -86,7 +86,7 @@
                 [:gmd:name
                  (char-string (su/nil-to-empty-string format))]
                 [:gmd:version {:gco:nilReason "unknown"}]
-                [:specification
+                [:gmd:specification
                  (char-string (su/nil-to-empty-string media))]]])
             (for [size (map su/nil-to-empty-string sizes)]
               [:gmd:distributorTransferOptions


Log Spark docker startup/shutdown

Log Spark docker startup/shutdown

--- test/powderkeg/docker.clj
+++ test/powderkeg/docker.clj
@@ -3,6 +3,17 @@
             [clojure.test :refer :all]
             [clojure.java.shell :refer [sh]]
             [clojure.string :as s]))
+
+(defmacro timing [log-prefix & body]
+  `(do
+     (println (str ~log-prefix " starting"))
+     (let [start# (System/currentTimeMillis)
+           result# (do ~@body)
+           end# (System/currentTimeMillis)
+           duration# (- end# start#)]
+       (println (str ~log-prefix " took: " (- end# start#) "ms" ))
+       {:result result#
+        :duration duration#})))

 (defn sh! [& args]
   (let [{:keys [exit out err] :as ret} (apply sh args)]
@@ -59,11 +70,13 @@
   (when-not (System/getenv "CIRCLECI")
     (sh! "docker" "rm" instance)))

-(defn start-spark [version]
+(defn start-cluster [version]
   (let [pwd (.getAbsolutePath (java.io.File. ""))]
-    (start-master pwd version)
+    (timing "Master startup"
+      (start-master pwd version))
     (Thread/sleep 2000)
-    (start-worker pwd version)
+    (timing "Worker startup"
+      (start-worker pwd version))
     (Thread/sleep 2000)))

 (defn stop-cluster [version]
@@ -72,5 +85,6 @@

 (defn spark [version]
   (fn []
-    (start-spark version)
-    #(stop-cluster version)))
+    (start-cluster version)
+    #(timing "Cluster shutdown"
+       (stop-cluster version))))


Clean up css links on refresh

Clean up css links on refresh

--- frontend/core.cljs
+++ frontend/core.cljs
@@ -271,10 +271,12 @@
   (install-om debug-state (find-app-container (find-top-level-node))))

 (defn refresh-css! []
-  (let [link (.createElement js/document "link")]
-    (.setAttribute link "rel" "stylesheet")
-    (.setAttribute link "href" "/assets/css/app.css.less")
-    (.appendChild (.-head js/document) link)))
+  (let [is-app-css? #(re-matches #"/assets/css/app.*?\.css(?:\.less)?" (dommy/attr % :href))
+        old-link (->> (sel [:head :link])
+                      (filter is-app-css?)
+                      first)]
+        (dommy/append! (sel1 :head) [:link {:rel "stylesheet" :href "/assets/css/app.css.less"}])
+        (dommy/remove! old-link)))

 (defn update-ui! []
   (reinstall-om!)


CMR-1239: Fix comment

CMR-1239: Fix comment

--- metadata-db-app/int_test/cmr/metadata_db/int_test/concepts/save_test.clj
+++ metadata-db-app/int_test/cmr/metadata_db/int_test/concepts/save_test.clj
@@ -224,7 +224,7 @@

       ;; We need to verify that the granule which was inserted and failed the post commit
       ;; constraint checks is cleaned up from the database. We do this by verifying that
-      ;; the db only contains the original collection.
+      ;; the db only contains the original granule.
       (let [found-concepts (util/find-concepts :granule
                                                {:granule-ur "GR-UR1" :provider-id "PROV1"})]
         (is (= [existing-granule]


Fix errors, optimize query

Fix errors, optimize query

--- src/org/spootnik/cyanite/store.clj
+++ src/org/spootnik/cyanite/store.clj
@@ -57,7 +57,7 @@
    session
    (str
     "SELECT path,data,time FROM metric WHERE "
-    "path IN ? AND tenant = ? AND rollup = ? AND period = ? "
+    "path = ? AND tenant = ? AND rollup = ? AND period = ? "
     "AND time >= ? AND time <= ? ORDER BY time ASC;")))

@@ -159,19 +159,18 @@
 (defn par-fetch [session fetch! paths tenant rollup period from to]
   (let [futures
         (doall (map #(future
-                       (let [path %]
-                         (debug "fetching path from store: " path
-                                tenant rollup period from to)
-                         (->> (alia/execute
-                               session fetch!
-                               {:values [[path] tenant (int rollup)
-                                         (int period)
-                                         from to]
-                                :fetch-size Integer/MAX_VALUE})
-                              (map detect-aggregate)
-                              (seq))))
+                       (debug "fetching path from store: " % tenant
+                              rollup period from to)
+                       (->> (alia/execute
+                             session fetch!
+                             {:values [% tenant (int rollup)
+                                       (int period)
+                                       from to]
+                              :fetch-size Integer/MAX_VALUE})
+                            (map detect-aggregate)
+                            (seq)))
                     paths))]
-    (seq (remove nil? (reduce concat (map deref futures))))))
+    (seq (remove nil? (reduce into (map deref futures))))))

 (defn cassandra-metric-store
   "Connect to cassandra and start a path fetching thread.


fixing endless loop bug:

fixing endless loop bug:

- when there are global "on" handlers, they can currently
  invoke themselves in cases when they throw errors.

  e.g. :pending-mails: when the handling component throws
  an error, the error handler will pick this up, but the
  pending-mails handler will also pick it up again, then
  throw an error again... and so on.

  we try to fix this by not allowing non-abort "on" handlers
  to pick up messages that cause an abort. An abort-capable
  handler though must ignore the existence of an Abort
  record in the rule, as otherwise it would trigger itself
  over and over again within fire-rules:
  - rule requires no Abort exists
  - rule sets Abort when fired
  - rule is being revoked as Abort now exists
  - Abort is being removed from session, as rule is no
    longer fired.
  - start over

--- src/ow/starbuck/message_router.clj
+++ src/ow/starbuck/message_router.clj
@@ -45,7 +45,7 @@

 (defrecord PendingMessage [route comp])
 (defrecord RoutedMessage [route comp])
-(defrecord AbortRoute [route])
+(defrecord Abort [route])

 (defn- concat-symbols [prefix & syms]
   (letfn [(sym-to-str [s]
@@ -82,7 +82,7 @@
         ]
     `(defrule ~rname
        [~reqsym ~'<- PendingMessage (= ~*route* ~'route) (contains? ~prev-comps ~'comp)]
-       [:not [AbortRoute (or (nil? ~'route) (= ~*route* ~'route))]]
+       [:not [Abort (or (nil? ~'route) (= ~*route* ~'route))]]
        ~'=>
        (debug ~logmsg)
        (insert! (map->RoutedMessage (assoc ~reqsym :comp ~(if (fn? next-comp)
@@ -96,11 +96,16 @@
         reqsym (gensym "?req-")
         keysym (symbol (name key))]
     `(defrule ~rname
-       [~reqsym ~'<- PendingMessage [{:keys [~'route ~keysym]}] ~@(when *route* `[(= ~*route* ~'route)]) (not (nil? ~keysym))]
+       [~reqsym ~'<- PendingMessage [{:keys [~'route ~keysym]}]
+        ~@(when *route* `[(= ~*route* ~'route)]) (not (nil? ~keysym))]
+       ~@(when (not abort-route?)
+           `[[:not ~(if *route*
+                      `[Abort (or (nil? ~'route) (= ~*route* ~'route))]
+                      `[Abort])]])
        ~'=>
        (debug ~logmsg)
        ~@(when abort-route?
-           `[(insert! (->AbortRoute ~*route*))])
+           `[(insert! (->Abort ~*route*))])
        (insert! (map->RoutedMessage (assoc ~reqsym :comp ~next-comp))))))

 (defn process [this req]


Add missing docstrings

Add missing docstrings

--- src/plumula/delta/spec/helper.cljc
+++ src/plumula/delta/spec/helper.cljc
@@ -19,11 +19,14 @@
                                         (gen/gen-for-pred any?))))))

 (def attributes
-  ""
+  "Specifies an operation’s attributes, which are encoded as a map of key-value
+  pairs. `nil` values are allowed, for instance they are needed in `:retain`
+  operations.
+  "
   (s/map-of keyword? any?))

 (def valued-attributes
-  ""
+  "Like `attributes`, except `nil` values are forbidden."
   (s/and attributes
          #(every? (comp some? val) %)))

@@ -33,20 +36,20 @@
   (boolean (:ns env)))

 (defmacro if-cljs
-  "Return then if we are generating cljs code and else for Clojure code.
+  "Return `then` if we are generating cljs code and `else` for Clojure code.
    https://groups.google.com/d/msg/clojurescript/iBY5HaQda4A/w1lAQi9_AwsJ"
   [then else]
   (if (cljs-env? &env) then else))

 (defmacro s-or
-  ""
+  "Logical disjunction of predicates, whether we’re running on Clojure or ClojureScript."
   [& args]
   `(if-cljs
      (cljs.spec.alpha/or ~@args)
      (clojure.spec.alpha/or ~@args)))

 (defmacro s-and
-  ""
+  "Logical conjunction of predicates, whether we’re running on Clojure or ClojureScript."
   [& args]
   `(if-cljs
      (cljs.spec.alpha/and ~@args)


placeholder: cartesian coordinates spiral in Clojure

--- clojure/lazy_seq_again.clj
+++ clojure/lazy_seq_again.clj
@@ -1,12 +1,12 @@
 (defrecord Square [x y])
 (defrecord Delta [dx dy])
-(defrecord SpiralMemory [memory square delta next-turn steps])
+(defrecord SpiralMemory [memory square delta])

 (defn make-spiral-memory
   ([]
-   (make-spiral-memory {(->Square 0 0) 1} 0 0 0 -1 0 0))
-  ([memory x y dx dy next-turn steps]
-   (->SpiralMemory memory (->Square x y) (->Delta dx dy) next-turn steps)))
+   (make-spiral-memory {(->Square 0 0) 1} 0 0 0 -1))
+  ([memory x y dx dy]
+   (->SpiralMemory memory (->Square x y) (->Delta dx dy))))

 (defn adj-nn [x, y] (->Square      x  (inc y)))
 (defn adj-ne [x, y] (->Square (inc x) (inc y)))
@@ -35,14 +35,12 @@
 (defn walk
   [{memory :memory
     {x :x y :y} :square
-    {dx :dx dy :dy} :delta
-    next-turn :next-turn
-    steps :steps}]
-  (let [should-turn (= steps next-turn)
-        next-turn (if (and should-turn (not (zero? dy))) (inc next-turn) next-turn)
-        steps (if should-turn 1 (inc steps))
+    {dx :dx dy :dy} :delta}]
+  (let [should-turn (or (= x y)
+                        (and (pos? y) (zero? (+ x y)))
+                        (and (<= y 0) (zero? (+ x y -1))))
         [dx dy] (if should-turn [(- dy) dx] [dx dy])]
-    (make-spiral-memory memory (+ x dx) (+ y dy) dx dy next-turn steps)))
+    (make-spiral-memory memory (+ x dx) (+ y dy) dx dy)))

 (defn write-squares
   ([]


Add a TODO comment on util.forms.

Add a TODO comment on util.forms.

--- frontend/src/uxbox/util/forms.cljs
+++ frontend/src/uxbox/util/forms.cljs
@@ -14,6 +14,8 @@
             [uxbox.util.mixins :as mx :include-macros true]
             [uxbox.util.i18n :refer (tr)]))

+;; TODO: rewrite form stuff using cljs.spec
+
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Form Validation
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


Better using a verb here

Better using a verb here

--- src/status_im/translations/de.cljs
+++ src/status_im/translations/de.cljs
@@ -79,19 +79,19 @@
    :image-source-cancel                   "Abbrechen"

    ;sign-up
-   :contacts-syncronized                  "Ihre Kontakte wurden synchronisiert"
-   :confirmation-code                     (str "Danke! Wir haben Ihnen eine Textnachricht mit einer Bestätigungscode"
-                                               "geschickt. Bitte geben Sie den Code ein, damit wir Ihre Telefonnummer verifizieren können")
+   :contacts-syncronized                  "Ihre Kontakte wurden synchronisiert."
+   :confirmation-code                     (str "Danke! Wir haben Ihnen eine Textnachricht mit einem Bestätigungscode "
+                                               "geschickt. Bitte geben Sie den Code ein, damit wir Ihre Telefonnummer verifizieren können.")
    :incorrect-code                        (str "Tut uns leid, der Code war nicht korrekt, bitte erneut eingeben")
    :generate-passphrase                   (str "Ich werde eine Passphrase für Sie generieren, damit Sie Ihren"
                                                "Zugriff wiederherstellen oder sich von einem anderen Gerät aus einloggen können")
-   :phew-here-is-your-passphrase          "*Puh* das war schwer, hier ist Ihr Passphrase, *bitte aufschreiben und sicher aufbewahren!*Sie benötigen dies, um Ihren Account wiederherzustellen."
+   :phew-here-is-your-passphrase          "*Puh* das war schwer, hier ist Ihr Passphrase, *bitte aufschreiben und sicher aufbewahren! *Sie benötigen dies, um Ihren Account wiederherzustellen."
    :here-is-your-passphrase               "Hier ist Ihr Passphrase, *bitte aufschreiben und sicher verwahren!*Sie benötigen dies, um Ihren Account wiederherzustellen."
    :written-down                          "Stellen Sie sicher, dass Sie es sicher aufgeschrieben haben"
    :phone-number-required                 "Tippen Sie hier, um Ihre Telefonnummer einzugeben & ich werde Ihre Freunde finden"
    :intro-status                          "Chatten Sie mit mir, um Ihren Account einzurichten und Ihre Einstellungen zu ändern!"
-   :intro-message1                        "Willkommen beim Status\nTippen Sie auf diese nachricht, um Ihr Passwort einzurichten und loszulegen!"
-   :account-generation-message            "Eine Sekunde, ich muss wahnsinnig schwere Mathematik machen, um Ihr Konto zu generieren!"
+   :intro-message1                        "Willkommen beim Status.\nTippen Sie auf diese Nachricht, um Ihr Passwort einzurichten und loszulegen!"
+   :account-generation-message            "Eine Sekunde, ich muss wahnsinnig schwierige Berechnungen durchführen, um Ihr Konto zu generieren!"

    ;chats
    :chats                                 "Chats"
@@ -99,7 +99,7 @@
    :new-group-chat                        "Neuer Gruppenchat"

    ;discover
-   :discover                             "Entdeckung"
+   :discover                             "Entdecken"
    :none                                  "Nichts"
    :search-tags                           "Geben Sie Ihre Suchbegriffe hier ein"
    :popular-tags                          "Beliebte Begriffe"


A little more work on azulenoitds.clj

A little more work on azulenoitds.clj

--- clojure/org/gavrog/clojure/azulenoids.clj
+++ clojure/org/gavrog/clojure/azulenoids.clj
@@ -1,6 +1,7 @@
 (ns org.gavrog.clojure.azulenoids
   (:import (org.gavrog.jane.numbers Whole)
-           (org.gavrog.joss.dsyms.basic DSymbol DynamicDSymbol)))
+           (org.gavrog.joss.dsyms.basic DSymbol DynamicDSymbol)
+           (org.gavrog.joss.dsyms.generators CombineTiles DefineBranching2d)))

 (def template
   (new DSymbol (str "1.1:60:"
@@ -12,7 +13,24 @@
                     "29 0 0 0 0 42 41 0 0 48 47 0 0 54 53 0 0 60 59 0 0:"
                     "3 3 3 3 3 3 3 3 3 3,0 0 5 0 7 0 0 0 0 0")))

-(defn initial-symbol []
-  (new DynamicDSymbol
-       (str "1.1:16:2 4 6 8 10 12 14 16,16 3 5 7 9 11 13 15,"
-            "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0:8,0 0 0 0 0 0 0 0")))
+(def octagon
+  (new DSymbol "1.1:16 1:2 4 6 8 10 12 14 16,16 3 5 7 9 11 13 15:8"))
+
+(def sets (new CombineTiles octagon))
+
+(defn max-curvature [ds]
+  (let [dsx (.clone ds)]
+    (do (.setVDefaultToOne dsx true) (.curvature2D dsx))))
+
+(defn syms-for [ds]
+  (if (.isNegative (max-curvature ds))
+    []
+    (new DefineBranching2d ds 3 2 Whole/ZERO)))
+
+(def syms (mapcat syms-for sets))
+
+(defn subdiv [ds pos]
+  )
+
+(defn subdivs-for [ds]
+  (map (partial subdiv ds) (range 1 16 2)))


Small changes.

Small changes.

--- clojure/org/gavrog/clojure/azulenoids.clj
+++ clojure/org/gavrog/clojure/azulenoids.clj
@@ -45,6 +45,9 @@
   (reduce #(when %1 (.op ds %2 %1)) D idxs))

 (defn chain-end [ds D i j]
+  "Returns the result of alternately applying operators indexed i and j,
+   starting with the element D, until the end of the chain is reached.
+   In case of a cycle, nil is returned."
   (loop [E (walk ds D i)]
     (let [E* (walk ds E j)]
       (cond
@@ -53,10 +56,7 @@
         (= D E*) nil
         :else (recur (walk ds E j i))))))

-(defn boundary-chambers [ds D i j k]
-  (iterate-cycle [#(walk ds %1 i) #(chain-end ds %1 j k)] D))
-
-(defn traversal [ds indices seeds]
+(defn pretty-traversal [ds indices seeds]
   (let [stacks (map #(vector % ()) (take 2 indices))
         queues (map #(vector % empty-queue) (drop 2 indices))
         as-root #(vector % :root)
@@ -86,12 +86,12 @@

 (defn orbit-reps
   ([ds indices seeds]
-    (for [[D i] (traversal ds indices seeds) :when (= :root i)] D))
+    (for [[D i] (pretty-traversal ds indices seeds) :when (= :root i)] D))
   ([ds indices]
     (orbit-reps ds indices (iterator-seq (.elements ds)))))

 (defn orbit-loopless? [ds indices D]
-  (empty? (for [[D i] (traversal ds indices [D])
+  (empty? (for [[D i] (pretty-traversal ds indices [D])
                 :when (and (not= i :root) (or (nil? D) (= D (walk ds D i))))]
             D)))

@@ -121,6 +121,9 @@

 (def octagon
   (DSymbol. "1.1:16 1:2 4 6 8 10 12 14 16,16 3 5 7 9 11 13 15:8"))
+
+(defn boundary-chambers [ds D i j k]
+  (iterate-cycle [#(walk ds %1 i) #(chain-end ds %1 j k)] D))

 (def boundary-mappings
   (let [template-boundary (boundary-chambers template (Integer. 1) 0 1 2)


remove debug and add nil check

remove debug and add nil check

--- kafka-clj/src/kafka_clj/pool.clj
+++ kafka-clj/src/kafka_clj/pool.clj
@@ -74,8 +74,8 @@
   (reify KeyedPooledObjectFactory
     (makeObject [_ k] (DefaultPooledObject. (create-f k conf)))
     (destroyObject [_ _ v]
-      (prn "destroyObject >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> v " v " lifted " (lift v))
-      (destroy-f (lift v) conf))
+      (when (and v (lift v))
+        (destroy-f (lift v) conf)))
     (validateObject [_ _ v] (validate-f (lift v) conf))
     (activateObject [_ _ _])
     (passivateObject [_ _ _])))


Remove debug logging

Remove debug logging

--- src/onyx/log/commands/peer_replica_view.clj
+++ src/onyx/log/commands/peer_replica_view.clj
@@ -19,7 +19,6 @@

 (defn build-pick-peer-fn [task-id egress-peers grouping?]
   (let [out-peers (egress-peers task-id)]
-    (info "OUTPEERS " out-peers egress-peers task-id)
     (cond (empty? out-peers)
           (fn [_] nil)
           grouping?


fix test

fix test

--- test/cljs/lambdacd/route_test.cljs
+++ test/cljs/lambdacd/route_test.cljs
@@ -34,7 +34,7 @@
     (let [build-number-atom (atom nil)
           step-id-to-display (atom nil)
           state-atom (atom nil)]
-      (is (= {:routing :failed :redirect-to "/builds/1" } (route/dispatch-route build-number-atom step-id-to-display state-atom "/i/dont/know")))
+      (is (= {:routing :failed } (route/dispatch-route build-number-atom step-id-to-display state-atom "/i/dont/know")))
       (is (= nil @build-number-atom)))))


fixed producer tests

fixed producer tests

--- test/ctia/events/producer_test.clj
+++ test/ctia/events/producer_test.clj
@@ -11,10 +11,16 @@
 (defmacro deftest-for-each-producer [test-name & body]
   `(helpers/deftest-for-each-fixture ~test-name
      {:es-producer (join-fixtures [es-helpers/fixture-properties:es-producer
+                                   helpers/fixture-ctia
                                    es-helpers/fixture-recreate-producer-indexes])}
      ~@body))

+(defn check-produce-response [produced]
+  (map #(is (string? %)) produced))
+
+
 (deftest-for-each-producer test-producer-event-create
+
   (testing "Produce CreatedModel Event"
     (let [event {:owner "test-owner"
                  :timestamp (java.util.Date.)
@@ -27,8 +33,7 @@

           produced (produce event)]

-      (is string? produced))))
-
+      (check-produce-response produced))))

 (deftest-for-each-producer test-producer-event-update
   (testing "Produce UpdatedModel Event"
@@ -45,7 +50,7 @@

           produced (produce event)]

-      (is string? produced))))
+      (check-produce-response produced))))

 (deftest-for-each-producer test-producer-event-delete
   (testing "Produce DeletedModel Event"
@@ -60,7 +65,7 @@

           produced (produce event)]

-      (is string? produced))))
+      (check-produce-response produced))))

 (deftest-for-each-producer test-producer-event-verdict-change
   (testing "Produce VerdictChange Event"
@@ -80,4 +85,4 @@

           produced (produce event)]

-      (is string? (produce event)))))
+      (check-produce-response produced))))


fixed browser loader

fixed browser loader

Signed-off-by: Andrey Shovkoplyas <b713972e59b8e606e23253c4a13e948139fea4d1@gmail.com>

--- src/status_im/ui/screens/browser/views.cljs
+++ src/status_im/ui/screens/browser/views.cljs
@@ -153,7 +153,7 @@

 (views/defview browser []
   (views/letsubs [webview (atom nil)
-                  width (reagent/atom nil)
+                  window-width [:dimensions/window-width]
                   {:keys [address settings]} [:account/account]
                   {:keys [browser-id dapp? name unsafe?] :as browser} [:get-current-browser]
                   {:keys [url error? loading? url-editing? show-tooltip show-permission resolving?]} [:get :browser/options]
@@ -163,11 +163,12 @@
           can-go-forward? (browser/can-go-forward? browser)
           url-original    (browser/get-current-url browser)
           opt-in?         (or (nil? (:web3-opt-in? settings)) (:web3-opt-in? settings))]
-      [react/view {:style styles/browser :on-layout #(reset! width (.-width (.-layout (.-nativeEvent %))))}
+      [react/view {:style styles/browser}
        [status-bar/status-bar]
        [toolbar error? url url-original browser browser-id url-editing?]
-       (when (and loading? (not (nil? @width)))
-         [connectivity/loading-indicator @width])
+       [react/view
+        (when loading?
+          [connectivity/loading-indicator window-width])]
        [browser-component {:webview         webview
                            :dapp?           dapp?
                            :error?          error?


removed the :reload tag from the test

removed the :reload tag from the test

--- test/foreclojure/test/settings.clj
+++ test/foreclojure/test/settings.clj
@@ -2,7 +2,7 @@
   (:require [sandbar.stateful-session :as   session]
             [ring.util.response       :as   response])
   (:import  [org.jasypt.util.password StrongPasswordEncryptor])
-  (:use [foreclojure.settings] :reload)
+  (:use [foreclojure.settings])
   (:use [clojure.test])
   (:use [midje.sweet])
   (:use [foreclojure.utils :only [get-user assuming flash-error flash-msg]])


Added deletion test for tag associations in metadata db

--- metadata-db-app/int_test/cmr/metadata_db/int_test/concepts/delete_test.clj
+++ metadata-db-app/int_test/cmr/metadata_db/int_test/concepts/delete_test.clj
@@ -24,6 +24,9 @@

 (deftest delete-tag-general
   (cd-spec/general-delete-test :tag ["CMR"]))
+
+(deftest delete-tag-association-general
+  (cd-spec/general-delete-test :tag-association ["CMR"]))

 (deftest delete-group-general
   (cd-spec/general-delete-test :access-group ["REG_PROV" "SMAL_PROV" "CMR"]))


CMR-2466: Correcting sql to find duplicates.

--- metadata-db-app/src/migrations/039_update_group_native_id_to_lowercase.clj
+++ metadata-db-app/src/migrations/039_update_group_native_id_to_lowercase.clj
@@ -10,10 +10,8 @@
   ;; Will throw an exception if duplicate group names are detected, they must be cleaned up manually.

   ;; to determine if there are any duplicates run this SQL:
-    ; select LOWER(native_id), count(native_id)
-    ; from METADATA_DB.CMR_GROUPS
-    ; group by LOWER(native_id)
-    ; having count (LOWER(native_id)) > 1;
+  ;; select a.native_id, a.concept_id, b.native_id, b.concept_id from cmr_groups a, cmr_groups b
+  ;; where lower(a.native_id) = lower(b.native_id) and a.provider_id = b.provider_id and a.concept_id != b.concept_id
   (h/sql "UPDATE METADATA_DB.CMR_GROUPS A SET A.native_id = LOWER(A.native_id)"))

 (defn down


add reminder note about testing transaction deletion

--- test/clj_money/models/transactions_test.clj
+++ test/clj_money/models/transactions_test.clj
@@ -281,3 +281,5 @@
 ; change account
 ;  old account balance and items are recalculated
 ;  new account balance and items are recalculated
+
+; delete a transaction


Performance optimizations for remote solution: it too long to collect response/diff after evolving

--- flatguicore/src/flatgui/focus.clj
+++ flatguicore/src/flatgui/focus.clj
@@ -60,6 +60,8 @@
             (inc i)))
         (sort-lines lines)))))

+;;; Sorts focusable components so that they are traversed in left->right, up->down direction.
+;;; To make such ad order, arranges components in a vector of horizontal "lines"
 (fg/defevolverfn :focus-traversal-order
   (let [accepting-children (get-accepting-children (get-property [:this] :children))]
     (if (pos? (count accepting-children))
@@ -110,7 +112,7 @@
      :focused-child child-id}
     (throw (IllegalArgumentException. (str "child-id must be a keyword but is: " child-id)))))

-;; For :parent-of-focused and :has-focus the latest focus movent direction (if any) is tracked in :throw-mode
+;;; For :parent-of-focused and :has-focus the latest focus movent direction (if any) is tracked in :throw-mode
 (defn focus-child-by-direction [child-id dir]
   (assoc (focus-child child-id) :throw-mode dir))


(SERVER-1630) Add comment to compatVersion test for JRuby 9k

This commit adds a comment to the compatVersion assertions done in the
`settings-plumbed-into-jruby-container` function.  The comment explains
why the assertion is different for JRuby 9k vs. what it had been for
JRuby 1.7.

--- test/integration/puppetlabs/services/jruby/jruby_puppet_pool_int_test.clj
+++ test/integration/puppetlabs/services/jruby/jruby_puppet_pool_int_test.clj
@@ -330,6 +330,13 @@
              container (:scripting-container jruby-instance)]
          (try
            (testing "compat version"
+             ;; We do a different assertion here for pre-JRuby 9k vs. 9k+ or
+             ;; later.  As of JRuby 9k, the CompatVersion is basically fixed to
+             ;; always return "RUBY_2_1" for a getCompatVersion call even if a
+             ;; caller tried to set it to something different via a call to the
+             ;; (now deprecated) setCompatVersion method.  This is because the
+             ;; compatVersion is hardcoded in the JRuby implementation for 9k
+             ;; and later.
              (if (some #(= (.toString %) "RUBY2_1")
                        (.getEnumConstants CompatVersion))
                (testing "fixed at '2.1' if '2.1' version available"


updated drugbank drug labels rule file formatting

--- resources/rules/post_identifier_merge/bio_labels/drugbank_drug_labels.clj
+++ resources/rules/post_identifier_merge/bio_labels/drugbank_drug_labels.clj
@@ -5,7 +5,7 @@
   :description "This rule creates a label for every drug record and types it as (IAO_EXT_0000367)"
   :head (
           ;; create a label for the drug
-          (?/drug rdfs/label ?/drug_name))
+         (?/drug rdfs/label ?/drug_name))

   :body ((?/record rdf/type ccp/IAO_EXT_0000426) ; ccp:DrugBank_drug_record
          (?/record obo/BFO_0000051 ?/drug_field_value) ; BFO:has_part


Improve hystrix-clj docs.

Improve hystrix-clj docs.

Expanded a bit on the behavior of :init-fn to hopefully head-off
confusion when trying to use Hystrix from the REPL.

--- hystrix-contrib/hystrix-clj/src/main/clojure/com/netflix/hystrix/core.clj
+++ hystrix-contrib/hystrix-clj/src/main/clojure/com/netflix/hystrix/core.clj
@@ -11,10 +11,15 @@
   A command or collapser definition map can be passed to the execute and queue functions to
   invoke the command.

+  The main Hystrix documentation can be found at https://github.com/Netflix/Hystrix. In particular,
+  you may find the Javadocs useful if you need to drop down into Java:
+  http://netflix.github.io/Hystrix/javadoc/
+
   # HystrixCommand

-  A HystrixCommand is a representation for an interaction network, or otherwise untrusted resource.
-  See the Hystrix documentation (https://github.com/Netflix/Hystrix) for more details.
+  A HystrixCommand is a representation for an interaction with a network dependency, or other
+  untrusted resource. See the Hystrix documentation (https://github.com/Netflix/Hystrix) for
+  more details.

   A command is defined by a map with the following keys:

@@ -59,6 +64,11 @@
             (.andCommandPropertiesDefaults setter ...))

       This is your escape hatch into raw Hystrix.
+      ... but NOTE: Hystrix does a fair bit of configuration caching and that caching is keyed
+      by command key. Thus, many of the settings you apply within :init-fn will only apply
+      the *first time it is invoked*. After that, they're ignored. This means that some REPL-based
+      dynamicism is lost and that :init-fn shouldn't be used to configure a HystrixCommand at
+      run-time. Instead use Archaius properties as described in the Hystrix docs.

   The com.netflix.hystrix.core/defcommand macro is a helper for defining this map and storing it
   in a var. For example, here's a definition for an addition command:
@@ -138,7 +148,8 @@
           (fn [_ setter]
             (.andCollapserPropertiesDefaults setter ...))

-      This is your escape hatch into raw Hystrix.
+      This is your escape hatch into raw Hystrix. Please see additional notes about :init-fn
+      above. They apply to collapsers as well.

   The com.netflix.hystric.core/defcollapser macro is a helper for defining this map and storing it
   in a callable var.
@@ -178,10 +189,49 @@
          :else
            (throw (IllegalArgumentException. (str "Don't know how to make " ~class " from " key-name#)))))))

-(def command-key     (key-fn com.netflix.hystrix.HystrixCommandKey))
-(def group-key       (key-fn com.netflix.hystrix.HystrixCommandGroupKey))
-(def thread-pool-key (key-fn com.netflix.hystrix.HystrixThreadPoolKey))
-(def collapser-key   (key-fn com.netflix.hystrix.HystrixCollapserKey))
+(def command-key
+  "Given a string or keyword, returns a HystrixCommandKey. nil and HystrixCommandKey instances
+  are returned unchanged.
+
+  This function is rarely needed since most hystrix-clj functions will do this automatically.
+
+  See:
+    com.netflix.hystrix.HystrixCommandKey
+  "
+  (key-fn com.netflix.hystrix.HystrixCommandKey))
+
+(def group-key
+  "Given a string or keyword, returns a HystrixCommandGroupKey. nil and HystrixCommandGroupKey
+  instances are returned unchanged.
+
+  This function is rarely needed since most hystrix-clj functions will do this automatically.
+
+  See:
+    com.netflix.hystrix.HystrixCommandGroupKey
+  "
+  (key-fn com.netflix.hystrix.HystrixCommandGroupKey))
+
+(def thread-pool-key
+  "Given a string or keyword, returns a HystrixThreadPoolGroupKey. nil and HystrixThreadPoolKey
+  instances are returned unchanged.
+
+  This function is rarely needed since most hystrix-clj functions will do this automatically.
+
+  See:
+    com.netflix.hystrix.HystrixThreadPoolKey
+  "
+  (key-fn com.netflix.hystrix.HystrixThreadPoolKey))
+
+(def collapser-key
+  "Given a string or keyword, returns a HystrixCollapserKey. nil and HystrixCollapserKey
+  instances are returned unchanged.
+
+  This function is rarely needed since most hystrix-clj functions will do this automatically.
+
+  See:
+    com.netflix.hystrix.HystrixCollapserKey
+  "
+  (key-fn com.netflix.hystrix.HystrixCollapserKey))

 (defn ^HystrixCollapser$Scope collapser-scope
   [v]
@@ -228,7 +278,19 @@
 ;################################################################################

 (defmacro with-request-context
-  "Executes body within a new Hystrix Context"
+  "Executes body within a new Hystrix Context.
+
+  Initializes a new HystrixRequestContext, executes the code and then shuts down the
+  context. Evaluates to the result of body.
+
+  Example:
+
+    (with-request-context
+      (... some code that uses Hystrix ...))
+
+  See:
+    com.netflix.hystrix.strategy.concurrency.HystrixRequestContext
+  "
   [& body]
   `(let [context# (HystrixRequestContext/initializeContext)]
      (try
@@ -240,8 +302,7 @@
   "Helper function that takes a definition map for a HystrixCommand and returns a normalized
   version ready for use with execute and queue.

-  See ns documentation for valid keys.
-
+  See com.netflix.hystrix.core ns documentation for valid keys.

   See:
     com.netflix.hystrix.core/defcommand
@@ -285,6 +346,8 @@
   The *var* defined by this macro can be passed to the execute and queue functions as if
   it were a HystrixCommand definition map. The complete definition map is stored under the
   :hystrix key in the var's metadata.
+
+  See com.netflix.hystrix.core ns documentation for valid keys.

   Example:

@@ -342,7 +405,7 @@
   "Helper function that takes a definition map for a HystrixCollapser and returns a normalized
   version ready for use with execute and queue.

-  See ns documentation for valid keys.
+  See com.netflix.hystrix.core ns documentation for valid keys.

   See:
     com.netflix.hystrix.core/defcollapser
@@ -369,6 +432,8 @@
   the :hystrix namespace, e.g. :scope becomes :hystrix/scope. Obviously,
   :hystrix/collapse-fn and :hystrix/map-fn are ignored since they're inferred from the body
   of the macro.
+
+  See com.netflix.hystrix.core ns documentation for valid keys.

   Example:

@@ -438,13 +503,18 @@
     * A normalized definition map for a command
     * A HystrixExecutable instance and no additional arguments

-  One typical use case for this function is to create a batch command in the :collapse-fn of a collapser.
+  One typical use case for this function is to create a batch command in the :collapse-fn of a collapser. Another is to get an actual HystrixCommand instance to get access to additional methods
+  it provides.

   See:
     com.neflix.hystrix.core/normalize
     com.neflix.hystrix.core/execute
     com.neflix.hystrix.core/queue
   "
+  {:arglists '[[defcommand-var & args]
+               [defcollapser-var & args]
+               [definition-map & args]
+               [HystrixExecutable] ]}
   [definition & args]
   (cond
     (var? definition)


(TK-343) Switched order of import and require in normalized-uri-helpers

This commit switches the order of the namespace imports and requires in
the normalized-uri-helpers namespace.  The order of imports first,
requires second seems more standard.

--- src/puppetlabs/trapperkeeper/services/webserver/normalized_uri_helpers.clj
+++ src/puppetlabs/trapperkeeper/services/webserver/normalized_uri_helpers.clj
@@ -1,7 +1,4 @@
 (ns puppetlabs.trapperkeeper.services.webserver.normalized-uri-helpers
-  (:require [schema.core :as schema]
-            [ring.util.servlet :as servlet]
-            [clojure.string :as str])
   (:import (javax.servlet.http HttpServletRequest HttpServletResponse)
            (org.eclipse.jetty.util URIUtil)
            (org.eclipse.jetty.server Request)
@@ -10,7 +7,10 @@
             HttpServletRequestWithAlternateRequestUri)
            (javax.servlet Filter DispatcherType)
            (java.util EnumSet)
-           (org.eclipse.jetty.servlet FilterHolder ServletContextHandler)))
+           (org.eclipse.jetty.servlet FilterHolder ServletContextHandler))
+  (:require [schema.core :as schema]
+            [ring.util.servlet :as servlet]
+            [clojure.string :as str]))

 (schema/defn ^:always-validate normalize-uri-path :- schema/Str
   "Return a 'normalized' version of the uri path represented on the incoming


ensure tests are within deftest

ensure tests are within deftest

--- ssclj/jar/test/com/sixsq/slipstream/ssclj/resources/common/schema_test.clj
+++ ssclj/jar/test/com/sixsq/slipstream/ssclj/resources/common/schema_test.clj
@@ -7,8 +7,9 @@

 (def non-nil? (complement nil?))

-(is (= (set/union core-actions prefixed-actions impl-prefixed-actions) (set (keys action-uri))))
-(is (= (set (map name core-actions)) (set (vals (select-keys action-uri core-actions)))))
+(deftest check-actions
+  (is (= (set/union core-actions prefixed-actions impl-prefixed-actions) (set (keys action-uri))))
+  (is (= (set (map name core-actions)) (set (vals (select-keys action-uri core-actions))))))

 (deftest check-PosInt
   (are [expect-fn arg] (expect-fn (s/check PosInt arg))
@@ -138,8 +139,9 @@
                          non-nil? (assoc acl :owner "")
                          non-nil? (assoc acl :bad "BAD"))))

-(is (nil? (s/check AclAttr {:acl valid-acl})))
-(is (s/check AclAttr {}))
+(deftest check-acl-attr
+  (is (nil? (s/check AclAttr {:acl valid-acl})))
+  (is (s/check AclAttr {})))

 (deftest check-CommonAttrs
   (let [date "2012-01-01T01:23:45.678Z"


remove expectations

remove expectations

--- ssclj/jar/test/com/sixsq/slipstream/ssclj/resources/common/authz_test.clj
+++ ssclj/jar/test/com/sixsq/slipstream/ssclj/resources/common/authz_test.clj
@@ -1,108 +1,109 @@
 (ns com.sixsq.slipstream.ssclj.resources.common.authz-test
   (:require
+    [clojure.test :refer [deftest are is]]
     [com.sixsq.slipstream.ssclj.resources.common.authz :as authz :refer :all]
-    [schema.core :as s]
-    [expectations :refer :all]))
+    [schema.core :as s]))

-(expect nil? (current-authentication {}))
-(expect nil? (current-authentication {:identity {:authentications {}}}))
-(expect nil? (current-authentication {:identity {:authentications {"user" {:identity "user"}}}}))
-(expect nil? (current-authentication {:identity {:current         "other"
-                                                 :authentications {"user" {:identity "user"}}}}))
-(expect "user" (:identity (current-authentication {:identity {:current         "user"
-                                                              :authentications {"user" {:identity "user"}}}})))
+(deftest check-current-authentication
+  (are [expect arg] (= expect (:identity (current-authentication arg)))
+                    nil {}
+                    nil {:identity {:authentications {}}}
+                    nil {:identity {:authentications {"user" {:identity "user"}}}}
+                    nil {:identity {:current         "other"
+                                    :authentications {"user" {:identity "user"}}}}
+                    "user" {:identity {:current         "user"
+                                       :authentications {"user" {:identity "user"}}}}))

+(deftest check-extract-right

-;; Role ADMIN can do anything
-(expect ::authz/all (extract-right {:identity "anyone" :roles ["R1", "ADMIN"]}
-                                   {:type "USER" :principal "USER1" :right "ALL"}))
+  (is (= ::authz/all (extract-right {:identity "anyone" :roles ["R1", "ADMIN"]}
+                                    {:type "USER" :principal "USER1" :right "ALL"})))

-(let [id-map {:identity "USER1" :roles ["R1" "R3"]}]
+  (is (= ::authz/view (extract-right nil {:type "ROLE" :principal "ANON" :right "VIEW"})))
+  (is (= ::authz/view (extract-right {} {:type "ROLE" :principal "ANON" :right "VIEW"})))

-  (expect ::authz/all (extract-right id-map {:type "USER" :principal "USER1" :right "ALL"}))
+  (let [id-map {:identity "USER1" :roles ["R1" "R3"]}]

-  (expect nil? (extract-right id-map {:type "USER" :principal "USER1"}))
-  (expect nil? (extract-right id-map {:type "ROLE" :principal "USER1" :right "ALL"}))
-  (expect ::authz/view (extract-right id-map {:type "ROLE" :principal "R1" :right "VIEW"}))
-  (expect nil? (extract-right id-map {:type "USER" :principal "R1" :right "VIEW"}))
-  (expect nil? (extract-right id-map {:type "ROLE" :principal "R2" :right "MODIFY"}))
-  (expect ::authz/modify (extract-right id-map {:type "ROLE" :principal "R3" :right "MODIFY"}))
-  (expect nil? (extract-right id-map {:type "ROLE" :principal "R3"}))
+    (are [expect arg] (= expect (extract-right id-map arg))
+                      ::authz/all {:type "USER" :principal "USER1" :right "ALL"}
+                      nil {:type "USER" :principal "USER1"}
+                      nil {:type "ROLE" :principal "USER1" :right "ALL"}
+                      ::authz/view {:type "ROLE" :principal "R1" :right "VIEW"}
+                      nil {:type "USER" :principal "R1" :right "VIEW"}
+                      nil {:type "ROLE" :principal "R2" :right "MODIFY"}
+                      ::authz/modify {:type "ROLE" :principal "R3" :right "MODIFY"}
+                      nil {:type "ROLE" :principal "R3"}
+                      nil {:type "ROLE" :principal "ANON"}
+                      ::authz/view {:type "ROLE" :principal "ANON" :right "VIEW"}
+                      nil nil
+                      nil {}))

-  (expect nil? (extract-right id-map {:type "ROLE" :principal "ANON"}))
-  (expect ::authz/view (extract-right id-map {:type "ROLE" :principal "ANON" :right "VIEW"}))
-  (expect nil? (extract-right id-map nil))
-  (expect nil? (extract-right id-map {})))
+  (let [acl {:owner {:principal "USER1"
+                     :type      "USER"}
+             :rules [{:principal "ROLE1"
+                      :type      "ROLE"
+                      :right     "VIEW"}
+                     {:principal "USER2"
+                      :type      "USER"
+                      :right     "MODIFY"}]}]

-;;
-;; anonymous access does *not* requires authentication
-;;
-(expect ::authz/view (extract-right nil {:type "ROLE" :principal "ANON" :right "VIEW"}))
-(expect ::authz/view (extract-right {} {:type "ROLE" :principal "ANON" :right "VIEW"}))
+    (are [expect arg] (= expect (extract-rights arg acl))
+                      #{} nil
+                      #{} {:identity nil}
+                      #{::authz/all} {:identity "USER1"}
+                      #{::authz/all ::authz/view} {:identity "USER1" :roles ["ROLE1"]}
+                      #{} {:identity "USER_UNKNOWN" :roles ["ROLE_UNKNOWN"]}
+                      #{::authz/view} {:identity "USER_UNKNOWN" :roles ["ROLE1"]}
+                      #{::authz/view ::authz/modify} {:identity "USER2" :roles ["ROLE1"]})))

-(let [acl {:owner {:principal "USER1"
-                   :type      "USER"}
-           :rules [{:principal "ROLE1"
-                    :type      "ROLE"
-                    :right     "VIEW"}
-                   {:principal "USER2"
-                    :type      "USER"
-                    :right     "MODIFY"}]}]
+(deftest check-hierarchy
+  (are [parent child] (isa? parent child)
+                      ::authz/all ::authz/view
+                      ::authz/modify ::authz/view
+                      ::authz/modify ::authz/view)
+  (are [parent child] (not (isa? parent child))
+                      ::authz/view ::authz/all
+                      ::authz/view ::authz/modify
+                      ::authz/modify ::authz/all))

-  (expect #{} (extract-rights nil acl))
+(deftest check-can-do?
+  (let [acl {:owner {:principal "USER1"
+                     :type      "USER"}
+             :rules [{:principal "ROLE1"
+                      :type      "ROLE"
+                      :right     "VIEW"}
+                     {:principal "USER2"
+                      :type      "USER"
+                      :right     "MODIFY"}]}
+        resource {:acl         acl
+                  :resource-id "Resource/uuid"}]

-  (expect #{} (extract-rights {:identity nil} acl))
-  (expect #{::authz/all} (extract-rights {:identity "USER1"} acl))
-  (expect #{::authz/all ::authz/view} (extract-rights {:identity "USER1" :roles ["ROLE1"]} acl))
-  (expect #{} (extract-rights {:identity "USER_UNKNOWN" :roles ["ROLE_UNKNOWN"]} acl))
-  (expect #{::authz/view} (extract-rights {:identity "USER_UNKNOWN" :roles ["ROLE1"]} acl))
-  (expect #{::authz/view ::authz/modify} (extract-rights {:identity "USER2" :roles ["ROLE1"]} acl)))
+    (let [request {:identity {:current         "USER1"
+                              :authentications {"USER1" {:identity "USER1"}}}}]

-(expect (isa? ::authz/all ::authz/view))
-(expect (isa? ::authz/modify ::authz/view))
-(expect (isa? ::authz/view ::authz/view))
+      (is (= resource (can-do? resource request ::authz/all)))
+      (is (= resource (can-do? resource request ::authz/modify)))
+      (is (= resource (can-do? resource request ::authz/view)))

-(expect false (isa? ::authz/view ::authz/all))
-(expect false (isa? ::authz/view ::authz/modify))
-(expect false (isa? ::authz/modify ::authz/all))
+      (let [request {:identity {:current         "USER_UNKNOWN"
+                                :authentications {"USER_UNKNOWN" {:identity "USER_UNKNOWN"
+                                                                  :roles    ["ROLE1"]}}}}]

-(let [acl      {:owner {:principal "USER1"
-                        :type      "USER"}
-                :rules [{:principal "ROLE1"
-                         :type      "ROLE"
-                         :right     "VIEW"}
-                        {:principal "USER2"
-                         :type      "USER"
-                         :right     "MODIFY"}]}
-      resource {:acl         acl
-                :resource-id "Resource/uuid"}]
+        (is (thrown? Exception (can-do? resource request ::authz/all)))
+        (is (thrown? Exception (can-do? resource request ::authz/modify)))
+        (is (= resource (can-do? resource request ::authz/view))))

-  (let [request {:identity {:current         "USER1"
-                            :authentications {"USER1" {:identity "USER1"}}}}]
+      (let [request {:identity {:current         "USER2"
+                                :authentications {"USER2" {:identity "USER2"}}}}]

-    (expect resource (can-do? resource request ::authz/all))
-    (expect resource (can-do? resource request ::authz/modify))
-    (expect resource (can-do? resource request ::authz/view)))
+        (is (thrown? Exception (can-do? resource request ::authz/all)))
+        (is (= resource (can-do? resource request ::authz/modify)))
+        (is (= resource (can-do? resource request ::authz/view))))

-  (let [request {:identity {:current         "USER_UNKNOWN"
-                            :authentications {"USER_UNKNOWN" {:identity "USER_UNKNOWN"
-                                                              :roles    ["ROLE1"]}}}}]
+      (let [request {:identity {:current         "USER2"
+                                :authentications {"USER2" {:identity "USER2"
+                                                           :roles    ["ROLE1"]}}}}]

-    (expect Exception (can-do? resource request ::authz/all))
-    (expect Exception (can-do? resource request ::authz/modify))
-    (expect resource (can-do? resource request ::authz/view)))
-
-  (let [request {:identity {:current         "USER2"
-                            :authentications {"USER2" {:identity "USER2"}}}}]
-
-    (expect Exception (can-do? resource request ::authz/all))
-    (expect resource (can-do? resource request ::authz/modify))
-    (expect resource (can-do? resource request ::authz/view)))
-
-  (let [request {:identity {:current         "USER2"
-                            :authentications {"USER2" {:identity "USER2"
-                                                       :roles    ["ROLE1"]}}}}]
-
-    (expect Exception (can-do? resource request ::authz/all))
-    (expect resource (can-do? resource request ::authz/modify))
-    (expect resource (can-do? resource request ::authz/view))))
+        (is (thrown? Exception (can-do? resource request ::authz/all)))
+        (is (= resource (can-do? resource request ::authz/modify)))
+        (is (= resource (can-do? resource request ::authz/view)))))))


CMR-6024: Refactor the code to make it more difficult to have  cut and paste error. (#819)

--- indexer-app/src/cmr/indexer/services/index_service.clj
+++ indexer-app/src/cmr/indexer/services/index_service.clj
@@ -255,12 +255,12 @@

 (defn- get-elastic-version-with-associations
   "Returns the elastic version of the concept and its associations"
-  [context concept tag-associations variable-associations service-associations]
+  [context concept associations]
   (es/get-elastic-version
    (-> concept
-       (assoc :tag-associations tag-associations)
-       (assoc :variable-associations variable-associations)
-       (assoc :service-associations service-associations))))
+       (assoc :tag-associations (:tag-associations associations))
+       (assoc :variable-associations (:variable-associations associations))
+       (assoc :service-associations (:service-associations associations)))))

 (defmulti get-elastic-version
   "Returns the elastic version of the concept"
@@ -277,19 +277,22 @@
         variable-associations (meta-db/get-associations-for-collection
                                context concept :variable-association)
         service-associations (meta-db/get-associations-for-collection
-                              context concept :service-association)]
+                              context concept :service-association)
+        associations {:tag-associations tag-associations
+                      :variable-associations variable-associations
+                      :service-associations service-associations}]
     (get-elastic-version-with-associations
-     context concept tag-associations variable-associations service-associations)))
+     context concept associations)))

 (defmethod get-elastic-version :variable
   [context concept]
   (let [variable-associations (meta-db/get-associations-for-variable context concept)]
-    (get-elastic-version-with-associations context concept nil variable-associations nil)))
+    (get-elastic-version-with-associations context concept {:variable-associations variable-associations})))

 (defmethod get-elastic-version :service
   [context concept]
   (let [service-associations (meta-db/get-associations-for-service context concept)]
-    (get-elastic-version-with-associations context concept nil nil service-associations)))
+    (get-elastic-version-with-associations context concept {:service-associations service-associations})))

 (defmulti get-tag-associations
   "Returns the tag associations of the concept"
@@ -359,9 +362,11 @@
           (let [tag-associations (get-tag-associations context concept)
                 variable-associations (get-variable-associations context concept)
                 service-associations (get-service-associations context concept)
+                associations {:tag-associations tag-associations
+                              :variable-associations variable-associations
+                              :service-associations service-associations}
                 elastic-version (get-elastic-version-with-associations
-                                 context concept tag-associations variable-associations
-                                 service-associations)
+                                 context concept associations)
                 tag-associations (es/parse-non-tombstone-associations
                                   context tag-associations)
                 variable-associations (es/parse-non-tombstone-associations


Comments.

Comments.

git-svn-id: 03a8048b5ee8463be5048a3801110fb50f378627@12187 d0ab736e-dc22-4aeb-8dc9-08def0aa14fd

--- acqEngine/src/org/micromanager/acq_engine.clj
+++ acqEngine/src/org/micromanager/acq_engine.clj
@@ -738,7 +738,7 @@

 (defn run-acquisition [settings out-queue cleanup? position-list autofocus-device]
     (try
-      (def acq-settings settings)
+      (def acq-settings settings) ; for debugging
       (log "Starting MD Acquisition: " settings)
       (when gui
         (doto gui
@@ -747,7 +747,7 @@
       (prepare-state state (when (:use-position-list settings) position-list) autofocus-device)
       (def last-state state) ; for debugging
       (let [acq-seq (generate-acq-sequence settings @attached-runnables)]
-        (def acq-sequence acq-seq)
+        (def acq-sequence acq-seq) ; for debugging
         (execute (mapcat #(make-event-fns % out-queue) acq-seq)))
       (catch Throwable t
              (def acq-error t)
@@ -878,9 +878,9 @@

 (defn run [this settings cleanup? position-list autofocus-device]
   (def last-acq this)
-  (def last-state (.state this))
+  (def last-state (.state this)) ; for debugging
     (reset! (.state this) {:stop false :pause false :finished false})
-    (let [out-queue (LinkedBlockingQueue. 10)
+    (let [out-queue (LinkedBlockingQueue. 10) ; Q: Why 10?
           acq-thread (Thread. #(binding [state (.state this)]
                                  (run-acquisition settings out-queue cleanup? position-list autofocus-device))
                               "AcquisitionEngine2010 Thread (Clojure)")]
@@ -890,7 +890,7 @@
                :finished false
                :acq-thread acq-thread
                :summary-metadata (make-summary-metadata settings)})
-      (def outq out-queue)
+      (def outq out-queue) ; for debugging
       (when-not (:stop @(.state this))
         (.start acq-thread)
         out-queue)))


Make sure state gets a clean slate at start of acquisition -- ensures everything is set once at beginning.

git-svn-id: 03a8048b5ee8463be5048a3801110fb50f378627@8679 d0ab736e-dc22-4aeb-8dc9-08def0aa14fd

--- acqEngine/src/org/micromanager/acq_engine.clj
+++ acqEngine/src/org/micromanager/acq_engine.clj
@@ -459,32 +459,32 @@
         z (get-z-stage-position default-z-drive)
         xy (get-xy-stage-position default-xy-stage)
         exposure (core getExposure)]
-    (swap! (.state this) assoc
-      :pause false
-      :stop false
-      :finished false
-      :last-wake-time (jvm-time-ms)
-      :last-stage-positions (into {} [[default-z-drive z]
-                                [default-xy-stage xy]])
-      :last-position nil
-      :reference-z z
-      :start-time (jvm-time-ms)
-      :init-auto-shutter (core getAutoShutter)
-      :init-exposure exposure
-      :exposure {(core getCameraDevice) exposure}
-      :default-z-drive default-z-drive
-      :default-xy-stage default-xy-stage
-      :init-z-position z
-      :init-system-state (get-system-config-cached)
-      :init-continuous-focus (core isContinuousFocusEnabled)
-      :init-width (core getImageWidth)
-      :init-height (core getImageHeight)
-      :init-shutter-state (when-not (empty? (core getShutterDevice)) (core getShutterOpen))
-      :binning (core getProperty (core getCameraDevice) "Binning")
-      :bit-depth (core getImageBitDepth)
-      :pixel-size-um (core getPixelSizeUm)
-      :source (core getCameraDevice)
-      :pixel-type (get-pixel-type)
+    (reset! (.state this)
+            {
+             :pause false
+             :stop false
+             :finished false
+             :last-wake-time (jvm-time-ms)
+             :last-stage-positions (into {} [[default-z-drive z]
+                                             [default-xy-stage xy]])
+             :reference-z z
+             :start-time (jvm-time-ms)
+             :init-auto-shutter (core getAutoShutter)
+             :init-exposure exposure
+             :exposure {(core getCameraDevice) exposure}
+             :default-z-drive default-z-drive
+             :default-xy-stage default-xy-stage
+             :init-z-position z
+             :init-system-state (get-system-config-cached)
+             :init-continuous-focus (core isContinuousFocusEnabled)
+             :init-width (core getImageWidth)
+             :init-height (core getImageHeight)
+             :binning (core getProperty (core getCameraDevice) "Binning")
+             :bit-depth (core getImageBitDepth)
+             :pixel-size-um (core getPixelSizeUm)
+             :source (core getCameraDevice)
+             :pixel-type (get-pixel-type)
+            }
       )))

 (defn cleanup []


revert change in 10606

revert change in 10606

git-svn-id: 03a8048b5ee8463be5048a3801110fb50f378627@10615 d0ab736e-dc22-4aeb-8dc9-08def0aa14fd

--- acqEngine/src/org/micromanager/acq_engine.clj
+++ acqEngine/src/org/micromanager/acq_engine.clj
@@ -739,13 +739,13 @@
         super-channels (all-super-channels simple-channels
                                            (get-camera-channel-names))
         ch-names (vec (map :name super-channels))]
-     (mm/to-json {
+     (JSONObject. {
       "BitDepth" (core getImageBitDepth)
       "Channels" (max 1 (count super-channels))
-      "ChNames" ch-names
-      "ChColors" (channel-colors simple-channels super-channels ch-names)
-      "ChContrastMax" (repeat (count super-channels) 65536)
-      "ChContrastMin" (repeat (count super-channels) 0)
+      "ChNames" (JSONArray. ch-names)
+      "ChColors" (JSONArray. (channel-colors simple-channels super-channels ch-names))
+      "ChContrastMax" (JSONArray. (repeat (count super-channels) 65536))
+      "ChContrastMin" (JSONArray. (repeat (count super-channels) 0))
       "Comment" (:comment settings)
       "ComputerName" (.. InetAddress getLocalHost getHostName)
       "Depth" (core getBytesPerPixel)
@@ -755,7 +755,7 @@
       "GridRow" 0
       "Height" (core getImageHeight)
       "Interval_ms" (:interval-ms settings)
-      "CustomIntervals_ms" (or (:custom-intervals-ms settings) [])
+      "CustomIntervals_ms" (JSONArray. (or (:custom-intervals-ms settings) []))
       "IJType" (get-IJ-type depth)
       "KeepShutterOpenChannels" (:keep-shutter-open-channels settings)
       "KeepShutterOpenSlices" (:keep-shutter-open-slices settings)
@@ -766,7 +766,7 @@
       "PixelType" (get-pixel-type)
       "Positions" (max 1 (count (:positions settings)))
       "Prefix" (if (:save settings) (:prefix settings) "")
-      "ROI" (get-camera-roi)
+      "ROI" (JSONArray. (get-camera-roi))
       "Slices" (max 1 (count (:slices settings)))
       "SlicesFirst" (:slices-first settings)
       "Source" "Micro-Manager"


listen to core callbacks for Z stage and XY stage

git-svn-id: 03a8048b5ee8463be5048a3801110fb50f378627@14065 d0ab736e-dc22-4aeb-8dc9-08def0aa14fd

--- acqEngine/src/org/micromanager/acq_engine.clj
+++ acqEngine/src/org/micromanager/acq_engine.clj
@@ -33,7 +33,7 @@
   		   [org.micromanager.acquisition MMAcquisition]
            [org.micromanager.api SequenceSettings]
            [org.micromanager.api PositionList]
-           [org.micromanager.utils ReportingUtils]
+           [org.micromanager.utils ReportingUtils MMListenerAdapter]
            [mmcorej TaggedImage Configuration Metadata]
            (java.util.concurrent Executors TimeUnit)
            [java.util.prefs Preferences]
@@ -658,6 +658,27 @@
            :pixel-type (get-pixel-type)
            )))

+(defn subscribe-state-to-core-callbacks
+  "Subscribes the state to core callbacks."
+  [state]
+  (when gui
+    (let [mm-listener
+          (proxy [MMListenerAdapter] []
+            (stagePositionChangedAlert [z-stage z]
+              (swap! state assoc-in [:last-stage-positions z-stage] z))
+            (xyStagePositionChanged [xy-stage x y]
+              (swap! state assoc-in [:last-stage-positions xy-stage] [x y])))]
+      (.addMMListener gui mm-listener)
+      (alter-meta! state update-in [:mm-listeners] conj mm-listener))))
+
+(defn unsubscribe-state-from-core-callbacks
+  "Unsubscribes the state from any subscribed core callbacks."
+  [state]
+  (when gui
+    (let [listeners (get-in (meta state) [:mm-listeners])]
+      (doseq [listener listeners] (.removeMMListener gui listener)))
+    (alter-meta! state assoc-in [:mm-listeners] nil)))
+
 (defn cleanup []
   (try
     (attempt-all
@@ -676,7 +697,8 @@
       (when (and (@state :init-continuous-focus)
                  (not (core isContinuousFocusEnabled)))
         (enable-continuous-focus true))
-      (when gui (.enableRoiButtons gui true)))
+      (when gui (.enableRoiButtons gui true))
+      (unsubscribe-state-from-core-callbacks state))
     (catch Throwable t
            (ReportingUtils/showError t "Acquisition cleanup failed."))))

@@ -739,6 +761,7 @@
           (.enableRoiButtons false)))
       (prepare-state state (when (:use-position-list settings) position-list) autofocus-device)
       (def last-state state) ; for debugging
+      (subscribe-state-to-core-callbacks state)
       (let [acq-seq (generate-acq-sequence settings @attached-runnables)]
         (def acq-sequence acq-seq) ; for debugging
         (execute (mapcat #(make-event-fns % out-queue) acq-seq)))


Always add a device to pending list when it is used.

git-svn-id: 03a8048b5ee8463be5048a3801110fb50f378627@7475 d0ab736e-dc22-4aeb-8dc9-08def0aa14fd

--- acqEngine/src/org/micromanager/acq_engine.clj
+++ acqEngine/src/org/micromanager/acq_engine.clj
@@ -87,7 +87,9 @@
             (do (ReportingUtils/logError e#) false))))

 (defmacro device-best-effort [dev & body]
-  `(let [attempt# #(do (wait-for-device ~dev) ~@body)]
+  `(let [attempt# #(do (wait-for-device ~dev)
+                       (add-to-pending ~dev)
+                       ~@body)]
     (when-not
       (or
         (successful? (attempt#)) ; first attempt
@@ -122,20 +124,17 @@
     ;(log (@state :last-positions) "," stage-dev)
     (when (not= z (get-in @state [:last-positions stage-dev]))
       (device-best-effort stage-dev (set-z-stage-position stage-dev z))
-      (swap! state assoc-in [:last-positions stage-dev] z)
-      (add-to-pending stage-dev)))
+      (swap! state assoc-in [:last-positions stage-dev] z)))
   ([stage-dev x y]
     ;(log (@state :last-positions) "," stage-dev)
     (when (and x y
                (not= [x y] (get-in @state [:last-positions stage-dev])))
       (device-best-effort stage-dev (core setXYPosition stage-dev x y))
-      (swap! state assoc-in [:last-positions stage-dev] [x y])
-      (add-to-pending stage-dev))))
+      (swap! state assoc-in [:last-positions stage-dev] [x y]))))

 (defn set-property
   ([prop] (let [[d p v] prop]
-            (device-best-effort d (core setProperty d p v))
-            (add-to-pending d))))
+            (device-best-effort d (core setProperty d p v)))))

 (defn run-autofocus []
   (.. gui getAutofocusManager getDevice fullFocus)
@@ -147,15 +146,13 @@
     (let [shutter (core getShutterDevice)]
       (when open-before
         (device-best-effort shutter
-          (core setShutterOpen true)
-          (wait-for-device (core getShutterDevice))))
-      (device-best-effort (core getCameraDevice)
-        (core snapImage))
+          (core setShutterOpen true)))
+      (wait-for-pending-devices)
+      (device-best-effort (core getCameraDevice) (core snapImage))
       (swap! state assoc :last-image-time (elapsed-time @state))
       (when close-after
         (device-best-effort shutter
-          (core setShutterOpen false))
-          (wait-for-device (core getShutterDevice))))))
+          (core setShutterOpen false))))))

 (defn arm-property-sequences [trigger-sequence]
   (doseq [[[d p] s] trigger-sequence]


some useful debugging code

some useful debugging code

git-svn-id: 03a8048b5ee8463be5048a3801110fb50f378627@11172 d0ab736e-dc22-4aeb-8dc9-08def0aa14fd

--- acqEngine/src/org/micromanager/acq_engine.clj
+++ acqEngine/src/org/micromanager/acq_engine.clj
@@ -62,7 +62,7 @@

 ;; globals

-(def ^:dynamic state (atom {:stop false}))
+(def ^:dynamic state nil)

 (def attached-runnables (atom (vec nil)))

@@ -393,7 +393,7 @@
                            (if (instance? Throwable item)
                              (throw item)
                              item))))]
-    (future (dotimes [i n]
+    (future (dotimes [_ n]
               (try (.put queue (function))
                    (catch Throwable t
                           (.put queue t)
@@ -427,6 +427,7 @@
    burst-events))

 (defn burst-cleanup []
+  (println "burst-cleanup")
   (when (core isBufferOverflowed)
     (throw-exception "Circular buffer overflowed."))
   (core stopSequenceAcquisition)
@@ -469,14 +470,15 @@
     (annotate-image image event @state time-stamp)))

 (defn produce-burst-images
-  "Pops images from circular buffer and sends them to output queue."
+  "Pops images from circular buffer, tags them, and sends them to output queue."
   [burst-events camera-channel-names timeout-ms out-queue]
   (let [total (* (count burst-events)
                  (count camera-channel-names))
         camera-index-tag (str (. mmc getCameraDevice) "-CameraChannelIndex")
         image-number-offset (if (first-trigger-missing?) -1 0)
         image-queue (pop-burst-images total timeout-ms)]
-    (doseq [_ (range total) :while (not (@state :stop))]
+    (doseq [i (range total) :while (not (@state :stop))]
+      ;(println i)
       (.put out-queue
             (-> (.take image-queue)
                 (tag-burst-image burst-events camera-channel-names camera-index-tag
@@ -850,6 +852,7 @@

 (defn run [this settings cleanup?]
   (def last-acq this)
+  (def last-state (.state this))
     (reset! (.state this) {:stop false :pause false :finished false})
     (let [out-queue (LinkedBlockingQueue. 10)
           acq-thread (Thread. #(binding [state (.state this)]


Refs vs atoms.

Refs vs atoms.

--- test/com/nomistech/clojure_the_language/c_400_state_and_concurrency/s_030_refs.clj
+++ test/com/nomistech/clojure_the_language/c_400_state_and_concurrency/s_030_refs.clj
@@ -39,11 +39,31 @@
 ;;;; `ensure`

 ;;;; ___________________________________________________________________________
-;;;; TODO:
+;;;; Single big atoms vs multiple small refs
+
+;;;; Our bank account example could be done with an atom:
+
+(def bank-accounts-atom
+  (atom {:account-1 100
+         :account-2 200}))
+
+(fact
+  (let [amount 20]
+    (swap! bank-accounts-atom (fn [m]
+                                (-> m
+                                    (update :account-1 + amount)
+                                    (update :account-2 - amount)))))
+  => {:account-1 120
+      :account-2 180})
+
+;;;; How to choose between atoms and refs?
 ;;;;
-;;;; - Look at your notes
+;;;; - Me:
+;;;;   - Atoms are simpler and faster -- if they are good enough, use them
 ;;;;
-;;;; - Refs
-;;;;   - and STM
-;;;;
-;;;; - Single big atoms vs multiple small refs
+;;;; - From /Seven Concurrency Models in Seven Weeks/
+;;;;   - Style & personal preference -- whatever seems clearest
+;;;;   - Performance
+;;;;     - testing of the alternatives with a stopwatch and load-test suite
+;;;;   -  Atoms suffice for most problems
+;;;;   -  Use the simplest approach that works


(maint) Update metrics test mocks for new scheduler

The tk-scheduler returns an opaque value when scheduling a job, that
value can then be used to stop said job.

In our metrics tests we mock out scheduling so we can control the
sampling of metrics within our tests. The garbage values that our mock
creates are saved by the service and then used to try and stop any
scheduled job on test shutdown.

Invalid values before were silently ignored, however now the scheduler
throws an error when attempting to stop an invalid job. But since this
occurs during test teardown it does not cause a test error.

This patch mocks out the scheduler stop-job protocol as well so it will
ignore the garbage ids our mock scheduling creates.

--- test/integration/puppetlabs/services/jruby/jruby_metrics_service_test.clj
+++ test/integration/puppetlabs/services/jruby/jruby_metrics_service_test.clj
@@ -262,7 +262,8 @@
         ;; when the sampling occurs.  Otherwise these tests would be very racy.
         sampling-scheduled?# (atom false)
         mock-schedule-metrics-sampler# (fn [_# _# _#] (reset! sampling-scheduled?# true))]
-    (with-redefs [puppetlabs.services.jruby.jruby-metrics-core/schedule-metrics-sampler! mock-schedule-metrics-sampler#]
+    (with-redefs [puppetlabs.services.jruby.jruby-metrics-core/schedule-metrics-sampler! mock-schedule-metrics-sampler#
+                  puppetlabs.trapperkeeper.services.protocols.scheduler/stop-job (constantly true)]
       (bootstrap/with-app-with-config
         app#
         (jruby-testutils/add-mock-jruby-pool-manager-service


remove checkmarks in workspace method config viewer

--- src/cljs/org/broadinstitute/firecloud_ui/page/workspace/method_configs/method_config_editor.cljs
+++ src/cljs/org/broadinstitute/firecloud_ui/page/workspace/method_configs/method_config_editor.cljs
@@ -119,9 +119,7 @@
     (icons/font-icon {:style {:paddingLeft "0.5em" :padding "1em 0.7em"
                               :color (:exception-red style/colors)}}
       :x)
-    (icons/font-icon {:style {:paddingLeft "0.5em" :padding "1em 0.7em"
-                              :color (:success-green style/colors)}}
-      :status-done)))
+    ))

 (defn- input-output-list [config value-type invalid-values editing?]
   (create-section


CMR-2051: Add newline for readability

CMR-2051: Add newline for readability

--- search-app/src/cmr/search/services/query_walkers/related_item_resolver.clj
+++ search-app/src/cmr/search/services/query_walkers/related_item_resolver.clj
@@ -28,6 +28,7 @@

   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   cmr.search.models.query.NegatedCondition
+
   (resolve-related-item-conditions
     [condition context]
     (update-in condition [:condition] #(resolve-related-item-conditions % context)))


Notebooks tab: handle clusters in Stopped/Stopping/Starting statuses (#1276)

--- src/cljs/main/broadfcui/page/workspace/notebooks/notebooks.cljs
+++ src/cljs/main/broadfcui/page/workspace/notebooks/notebooks.cljs
@@ -61,9 +61,10 @@
 (defn icon-for-cluster-status [status]
   (case status
     ("Deleted" "Error") (moncommon/render-failure-icon)
-    ("Creating" "Updating" "Deleting") spinner-icon
+    ("Creating" "Updating" "Deleting" "Stopping" "Starting") spinner-icon
     "Running" (moncommon/render-success-icon)
-    "Unknown" (moncommon/render-unknown-icon)))
+    "Stopped" nil  ;todo: add icon for Stopped status
+    (moncommon/render-unknown-icon)))

 (defn create-inline-form-label [text]
   [:span {:style {:marginBottom "0.16667em" :fontSize "88%"}} text])
@@ -444,7 +445,7 @@
                         (when-not (= (:clusters @state) filtered-clusters)
                           (swap! state assoc :server-response {:clusters filtered-clusters}))
                         ; If there are pending clusters, schedule another 'list clusters' call 10 seconds from now.
-                        (when (contains-statuses filtered-clusters ["Creating" "Updating" "Deleting"])
+                        (when (contains-statuses filtered-clusters ["Creating" "Updating" "Deleting" "Stopping" "Starting"])
                           (js/setTimeout #(this :-get-clusters-list) 10000))
                         ; If there are running clusters, call the /setCookie endpoint immediately.
                         (when (contains-statuses filtered-clusters ["Running"])


Use the same ordering in view and main sitemap.

Related #68

--- frontend/src/uxbox/view/ui/viewer/sitemap.cljs
+++ frontend/src/uxbox/view/ui/viewer/sitemap.cljs
@@ -8,9 +8,9 @@
 (ns uxbox.view.ui.viewer.sitemap
   (:require [sablono.core :refer-macros (html)]
             [lentes.core :as l]
-            [uxbox.util.i18n :refer (tr)]
+            [uxbox.util.i18n :refer [tr]]
             [uxbox.util.mixins :as mx :include-macros true]
-            [uxbox.util.data :refer (parse-int)]
+            [uxbox.util.data :refer [parse-int]]
             [potok.core :as ptk]
             [uxbox.view.store :as st]
             [uxbox.builtins.icons :as i]
@@ -37,7 +37,8 @@
   {:mixins [mx/static mx/reactive]}
   []
   (let [project-name (mx/react project-name-ref)
-        pages (mx/react pages-ref)
+        pages (->> (mx/react pages-ref)
+                   (sort-by #(get-in % [:metadata :order])))
         selected (mx/react selected-ref)
         on-click #(st/emit! (dv/select-page %))]
     [:div.view-sitemap


Doc typo fix

Doc typo fix

--- flatguicore/src/flatgui/paint.clj
+++ flatguicore/src/flatgui/paint.clj
@@ -52,8 +52,8 @@

 (defn flatten-vector
   "Suppose a vector that does not contain vectors among
-   its elements, it the tree leaf. This functions unrolls
-   tree-like structure or vectors into single vector that
+   its elements, it the tree leaf. This function unrolls
+   tree-like structure of vectors into single vector that
    contains only leafs. It is supposed that each vector
    may contain either vectors only, or non-vector elements
    only."


Temp values are floats, not ints!

Temp values are floats, not ints!

--- app/pyrexia/src/pyrexia/core.cljs
+++ app/pyrexia/src/pyrexia/core.cljs
@@ -76,9 +76,9 @@
     (.log js/console "nodes" (pr-str nodes))
     (swap! c/app-state assoc node-key nodes)
     (swap! c/app-state assoc :nodes (merge (:old-nodes @c/app-state) (:new-nodes @c/app-state)))
-    (swap! c/app-state assoc :minValue (apply min-skip-null (map #(-> % :temp js/parseInt) (vals (:nodes @c/app-state)))))
+    (swap! c/app-state assoc :minValue (apply min-skip-null (map #(-> % :temp js/parseFloat) (vals (:nodes @c/app-state)))))
     (.log js/console "minValue" (:minValue @c/app-state))
-    (swap! c/app-state assoc :maxValue (apply max (map #(-> % :temp js/parseInt) (vals (:nodes @c/app-state)))))
+    (swap! c/app-state assoc :maxValue (apply max (map #(-> % :temp js/parseFloat) (vals (:nodes @c/app-state)))))
     (.log js/console "maxValue" (:maxValue @c/app-state))
     (map/draw-map map/canvas-dom (:map @c/app-state))))


Move to "shell" namespce

Move to "shell" namespce

Former-commit-id: 6a48c31de9f8bd83aaea91523a43e6bbe55e207a

--- planck-cljs/src/planck/shell.cljs
+++ planck-cljs/src/planck/shell.cljs
@@ -1,4 +1,4 @@
-(ns planck.sh)
+(ns planck.shell)

 (def ^:dynamic *sh-dir* nil)
 (def ^:dynamic *sh-env* nil)


new keys in core analysis caches

new keys in core analysis caches

--- planck-cljs/src/planck/repl.cljs
+++ planck-cljs/src/planck/repl.cljs
@@ -158,7 +158,7 @@

 (defn- load-core-analysis-cache
   [eager ns-sym file-prefix]
-  (let [keys        [:use-macros :excludes :name :imports :requires :uses :defs :require-macros :cljs.analyzer/constants :doc]
+  (let [keys        [:rename-macros :renames :use-macros :excludes :name :imports :requires :uses :defs :require-macros :cljs.analyzer/constants :doc]
         load-single (fn [key]
                       (transit-json->cljs (first (js/PLANCK_LOAD (str file-prefix (munge key) ".json")))))
         load-all    (fn []
@@ -171,7 +171,9 @@
       (if eager
         (load-all)
         (lazy-map
-          {:use-macros              (load :use-macros)
+          {:rename-macros           (load :rename-macros)
+           :renames                 (load :renames)
+           :use-macros              (load :use-macros)
            :excludes                (load :excludes)
            :name                    (load :name)
            :imports                 (load :imports)


Add consume-request-stream (#904)

Add consume-request-stream (#904)

--- scheduler/src/cook/components.clj
+++ scheduler/src/cook/components.clj
@@ -38,8 +38,11 @@
             [ring.middleware.stacktrace :refer (wrap-stacktrace)]
             [ring.util.mime-type]
             [ring.util.response :refer (response)])
-  (:import java.security.Principal
+  (:import clojure.core.async.impl.channels.ManyToManyChannel
+           java.io.IOException
+           java.security.Principal
            javax.security.auth.Subject
+           javax.servlet.ServletInputStream
            org.apache.curator.framework.CuratorFrameworkFactory
            org.apache.curator.framework.state.ConnectionStateListener
            org.apache.curator.retry.BoundedExponentialBackoffRetry
@@ -215,6 +218,18 @@
         (h req)
         (auth-fn req)))))

+(defn- consume-request-stream [handler]
+  (fn [{:keys [body] :as request}]
+    (let [resp (handler request)]
+      (if (and (instance? ServletInputStream body)
+               (not (.isFinished ^ServletInputStream body))
+               (not (instance? ManyToManyChannel resp)))
+        (try
+          (slurp body)
+          (catch IOException e
+            (log/error e "Unable to consume request stream"))))
+      resp)))
+
 (def scheduler-server
   (graph/eager-compile
     {:route full-routes
@@ -239,7 +254,8 @@
                                                                wrap-params
                                                                (cors/cors-middleware cors-origins)
                                                                (health-check-middleware mesos-leadership-atom leader-reports-unhealthy)
-                                                               instrument))
+                                                               instrument
+                                                               consume-request-stream))
                                            :join? false
                                            :configurator configure-jet-logging
                                            :max-threads 200


Review feedback

Review feedback

--- scheduler/src/cook/mesos/util.clj
+++ scheduler/src/cook/mesos/util.clj
@@ -712,13 +712,13 @@
    This is a simple loop that nukes any uncommitted jobs older than a few days. It runs every 24 hours. There will be a minor
    performance hiccough lasting around 1 minute per 1000 jobs or so as this runs and flushes."
   [conn mesos-leadership-atom]
-  (let [age (tc/to-date (-> -3 t/days t/from-now))
-        start-time (-> 12 t/hours t/from-now)
+  (let [start-time (-> 12 t/hours t/from-now)
         frequency (-> 1 t/days)
         schedule (tp/periodic-seq start-time frequency)
-        chime-fn (fn [time]
+        chime-fn (fn [_]
                    (when @mesos-leadership-atom
-                     (clear-uncommitted-jobs conn age false)))]
+                     (let [age (-> -7 t/days t/from-now tc/to-date)]
+                       (clear-uncommitted-jobs conn age false))))]
     (log/info "Launching clear-uncommitted-jobs-on-schedule")
     (chime/chime-at schedule chime-fn)))