Close unclosed test sessions

Close unclosed test sessions

--- test/uruk/core_test.clj
+++ test/uruk/core_test.clj
@@ -35,19 +35,19 @@
   (testing "Creating sessions with a variety of parameters"
     (testing "...with just URI"
       (is (thrown? IllegalStateException
-                   (let [session (create-session {:uri "xdbc://localhost:8383/"})]
+                   (with-open [session (create-session {:uri "xdbc://localhost:8383/"})]
                      (.submitRequest session (.newAdhocQuery session "\"Hello world\""))))))

     (testing "...with URI and content-base"
       (is (thrown? IllegalStateException
-                   (let [session (create-session {:uri "xdbc://localhost:8383/"
-                                                  :content-base "TutorialDB"})]
+                   (with-open [session (create-session {:uri "xdbc://localhost:8383/"
+                                                        :content-base "TutorialDB"})]
                      (.submitRequest session (.newAdhocQuery session "\"Hello world\""))))))

     (testing "...with URI, user, password"
       (is (= "Hello world"
-             (let [session (create-session {:uri "xdbc://localhost:8383/"
-                                            :user "rest-admin" :password "x"})]
+             (with-open [session (create-session {:uri "xdbc://localhost:8383/"
+                                                  :user "rest-admin" :password "x"})]
                (-> session
                    (.submitRequest (.newAdhocQuery session
                                                    "\"Hello world\""))
@@ -55,7 +55,7 @@

     (testing "...with URI, user, password, content-base"
       (is (= "Hello world"
-             (let [session (create-session db)]
+             (with-open [session (create-session db)]
                (-> session
                    (.submitRequest (.newAdhocQuery session
                                                    "\"Hello world\""))
@@ -119,42 +119,40 @@
 (deftest default-session-config
   (testing "A session with no explicitly-set configuration must have default configuration"
     (testing "basic session creation with full database specified"
-      (is-default-session-config? (session->map (create-session db))))
+      (with-open [sess (create-session db)]
+        (is-default-session-config? (session->map sess))))
     (testing "session creation with URI content source"
-      (is-default-session-config? (session->map
-                                   (create-session
-                                    db (make-uri-content-source "xdbc://localhost:8383/")
-                                    {}))))
+      (with-open [sess (create-session
+                        db (make-uri-content-source "xdbc://localhost:8383/") {})]
+        (is-default-session-config? (session->map sess))))
     (testing "session creation with URI content source using options"
-      (is-default-session-config? (session->map
-                                   (create-session
-                                    db (make-uri-content-source
-                                        "xdbc://localhost:8383/"
-                                        {:preemptive-auth false
-                                         :default-logger (Logger/getLogger "foobar")})))))
+      (with-open [sess (create-session
+                        db (make-uri-content-source
+                            "xdbc://localhost:8383/"
+                            {:preemptive-auth false
+                             :default-logger (Logger/getLogger "foobar")}))]
+        (is-default-session-config? (session->map sess))))
     (testing "session creation with hosted content source"
-      (is-default-session-config? (session->map
-                                   (create-session
-                                    db (make-hosted-content-source "localhost" 8383)
-                                    {}))))
+      (with-open [sess (create-session
+                        db (make-hosted-content-source "localhost" 8383) {})]
+        (is-default-session-config? (session->map sess))))
     (testing "session creation with hosted content source using options"
-      (is-default-session-config? (session->map
-                                   (create-session
-                                    db (make-hosted-content-source "localhost" 8383
-                                                                   {:content-base "TutorialDB"})
-                                    {}))))
+      (with-open [sess (create-session
+                        db (make-hosted-content-source "localhost" 8383
+                                                       {:content-base "TutorialDB"})
+                        {})]
+        (is-default-session-config? (session->map sess))))
     ;; TODO once we want to delve into extreme complexity of ConnectionProvider
     ;; (testing "session creation with connectionProvider content source"
-    ;;   (is-default-session-config? (session->map
-    ;;                                 (create-session
-    ;;                                  db (make-cp-content-source ...)
-    ;;                                  {}))))
+    ;;   (with-open [sess (create-session
+    ;;                     db (make-cp-content-source ...)
+    ;;                     {})]
+    ;;     (is-default-session-config? (session->map sess))))
     ;; TODO once we want to delve into extreme complexity of ConnectionProvider
     ;; (testing "session creation with connectionProvider content source with options"
-    ;;   (is-default-session-config? (session->map
-    ;;                                 (create-session
-    ;;                                  db (make-cp-content-source ...)
-    ;;                                  {}))))
+    ;;   (with-open [sess (create-session
+    ;;                     db (make-cp-content-source ...) {})])
+    ;;   (is-default-session-config? (session->map sess)))
     ))

 ;; (deftest accept-only-valid-session-options
@@ -186,52 +184,46 @@
                 :transaction-timeout 56
                 :transaction-mode :query}]
       (testing "with standard database map"
-        (as-expected-session-config? (session->map
-                                      (create-session db opts))
-                                     opts))
+        (with-open [sess (create-session db opts)]
+          (as-expected-session-config? (session->map sess) opts)))
       (testing "with uri content source"
-        (as-expected-session-config? (session->map
-                                      (create-session db
-                                                      (make-uri-content-source "xdbc://localhost:8383/")
-                                                      opts))
-                                     opts))
+        (with-open [sess (create-session
+                          db (make-uri-content-source "xdbc://localhost:8383/")
+                          opts)]
+          (as-expected-session-config? (session->map sess) opts)))
       (testing "with uri content source using options"
-        (as-expected-session-config? (session->map
-                                      (create-session
-                                       db (make-uri-content-source "xdbc://localhost:8383/"
-                                                                   {:preemptive-auth false})
-                                       opts))
-                                     opts))
+        (with-open [sess (create-session
+                          db (make-uri-content-source "xdbc://localhost:8383/"
+                                                      {:preemptive-auth false})
+                          opts)]
+          (as-expected-session-config? (session->map sess) opts)))
+
       (testing "with hosted content source"
-        (as-expected-session-config? (session->map
-                                      (create-session
-                                       db (make-hosted-content-source "localhost" 8383)
-                                       opts))
-                                     opts))
+        (with-open [sess (create-session
+                          db (make-hosted-content-source "localhost" 8383)
+                          opts)]
+          (as-expected-session-config? (session->map sess) opts)))
       (testing "with hosted content source using content base"
-        (as-expected-session-config? (session->map
-                                      (create-session
-                                       db (make-hosted-content-source "localhost" 8383
-                                                                      {:content-base "TutorialDB"})
-                                       opts))
-                                     opts))
+        (with-open [sess (create-session
+                          db (make-hosted-content-source "localhost" 8383
+                                                         {:content-base "TutorialDB"})
+                          opts)]
+          (as-expected-session-config? (session->map sess) opts)))
       (testing "with hosted content source using user, password, content-base"
-        (as-expected-session-config? (session->map
-                                      (create-session
-                                       db (make-hosted-content-source "localhost" 8383
-                                                                      {:user "rest-admin"
-                                                                       :password "x"
-                                                                       :content-base "TutorialDB"})
-                                       opts))
-                                     opts))
+        (with-open [sess (create-session
+                          db (make-hosted-content-source "localhost" 8383
+                                                         {:user "rest-admin"
+                                                          :password "x"
+                                                          :content-base "TutorialDB"})
+                          opts)]
+          (as-expected-session-config? (session->map sess) opts)))
       (testing "with hosted content source using user and password"
-        (as-expected-session-config? (session->map
-                                      (create-session
-                                       db (make-hosted-content-source "localhost" 8383
-                                                                      {:user "rest-admin"
-                                                                       :password "x"})
-                                       opts))
-                                     opts))
+        (with-open [sess (create-session
+                          db (make-hosted-content-source "localhost" 8383
+                                                         {:user "rest-admin"
+                                                          :password "x"})
+                          opts)]
+          (as-expected-session-config? (session->map sess) opts)))
       ;; TODO once we want to delve into extreme complexity of ConnectionProvider
       ;; (as-expected-session-config? (session->map
       ;;                                (create-session
@@ -321,11 +313,6 @@
 ;; TODO test `as-is?`
 ;; TODO test (all?) variable types
 ;; TODO test default xs_string map structure
-
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;;; TODO Type conversion
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -486,70 +473,72 @@
     ))

-
-
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;;; Type tests
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

-;; (def session
-;;   (create-session {:uri "xdbc://localhost:8383/"
-;;                    :user "rest-admin" :password "x"
-;;                    :content-base "TutorialDB"}))
-
-(deftest types
-  (with-open [session (create-session {:uri "xdbc://localhost:8383/"
-                                       :user "rest-admin" :password "x"
-                                       :content-base "TutorialDB"})]
-    (testing "Types roundtrip through XQuery with expected conversions"
-      (testing "...JSON interface types"
-        (testing "......array-node type"
+(deftest type-conversion
+  (testing "Types roundtrip through XQuery with expected conversions"
+    (testing "...JSON interface types"
+      (testing "......array-node type"
+        (with-open [session (create-session db)]
           (is (= "array-node()"
                  (result->type (execute-xquery session "array-node {1,2,3}"
-                                               {:types :raw}))))
+                                               {:types :raw})))))
+
+        (with-open [session (create-session db)]
           (is (= [1 2 3]
                  (execute-xquery session "array-node {1,2,3}"
-                                 {:shape :single!}))))
-
-        (testing "......boolean-node type"
+                                 {:shape :single!})))))
+
+      (testing "......boolean-node type"
+        (with-open [session (create-session db)]
           (is (= "boolean-node()"
                  (result->type (execute-xquery session "boolean-node{false()}"
-                                               {:types :raw}))))
+                                               {:types :raw})))))
+        (with-open [session (create-session db)]
           (is (false? (execute-xquery session "boolean-node{false()}"
-                                      {:shape :single!}))))
-
-        ;; TODO produce and test JsonItem
-
-        (testing "......null-node type"
+                                      {:shape :single!})))))
+
+      ;; TODO produce and test JsonItem
+
+      (testing "......null-node type"
+        (with-open [session (create-session db)]
           (is (= "null-node()"
                  (result->type (execute-xquery session "null-node {}"
-                                               {:types :raw}))))
+                                               {:types :raw})))))
+        (with-open [session (create-session db)]
           (is (nil? (execute-xquery session "null-node {}"
-                                    {:shape :single!}))))
-
-        (testing "......number-node type"
+                                     {:shape :single!})))))
+
+      (testing "......number-node type"
+        (with-open [session (create-session db)]
           (is (= "number-node()"
                  (result->type (execute-xquery session "number-node {1}"
-                                               {:types :raw}))))
-          (is (= 1 (execute-xquery session "number-node {1}"
-                                   {:shape :single!}))))
-
-        (testing "......object-node type"
+                                               {:types :raw})))))
+          (with-open [session (create-session db)]
+            (is (= 1 (execute-xquery session "number-node {1}"
+                                    {:shape :single!})))))
+
+      (testing "......object-node type"
+        (with-open [session (create-session db)]
           (is (= "object-node()"
                  (result->type (execute-xquery session "xquery version \"1.0-ml\";
                                       let $object := json:object()
                                       let $_ := map:put($object,\"a\",111)
-                                      return xdmp:to-json($object)" {:types :raw}))))
-          (is (= {"a" 111}
-                 (execute-xquery session "xquery version \"1.0-ml\";
+                                      return xdmp:to-json($object)" {:types :raw})))))
+        (with-open [session (create-session db)]
+            (is (= {"a" 111}
+                  (execute-xquery session "xquery version \"1.0-ml\";
                                       let $object := json:object()
                                       let $_ := map:put($object,\"a\",111)
                                       return xdmp:to-json($object)"
-                                 {:shape :single!})))))
-
-
-      (testing "...JSON types"
-        (testing "......JSON array type"
+                                  {:shape :single!}))))))
+
+
+    (testing "...JSON types"
+      (testing "......JSON array type"
+        (with-open [session (create-session db)]
           (is (= "json:array"
                  (result->type (execute-xquery session "xquery version \"1.0-ml\";
                             json:array(
@@ -563,7 +552,8 @@
                              <json:value xsi:type=\"xs:string\">two</json:value>
                              </json:array>
                              </json:array>
-                            )" {:types :raw}))))
+                            )" {:types :raw})))))
+        (with-open [session (create-session db)]
           (is (= ["hello" "world" ["one" "two"]]
                  (execute-xquery session
                                  "xquery version \"1.0-ml\";
@@ -578,65 +568,82 @@
                              <json:value xsi:type=\"xs:string\">two</json:value>
                              </json:array>
                              </json:array>
-                            )" {:shape :single!}))))
-
-        (testing "......JSON object type"
+                            )" {:shape :single!})))))
+
+      (testing "......JSON object type"
+        (with-open [session (create-session db)]
           (is (= "json:object"
                  (result->type (execute-xquery session "json:object()"
-                                               {:types :raw}))))
+                                               {:types :raw})))))
+        (with-open [session (create-session db)]
           (is (= {}
                  (execute-xquery session "json:object()"
-                                 {:shape :single!}))))))
-
-    (testing "...CTS types"
-      (testing "......CTS box type"
+                                 {:shape :single!})))))))
+
+  (testing "...CTS types"
+    (testing "......CTS box type"
+      (with-open [session (create-session db)]
         (is (= "cts:box"
                (result->type (execute-xquery session "cts:box(45, -122, 78, 30)"
-                                             {:types :raw}))))
-        (is (= "[45, -122, 78, 30]"
-               (execute-xquery session "cts:box(45, -122, 78, 30)"
-                               {:shape :single!}))))
-
-      (testing "......CTS circle type"
+                                             {:types :raw})))))
+      (with-open [session (create-session db)]
+          (is (= "[45, -122, 78, 30]"
+                (execute-xquery session "cts:box(45, -122, 78, 30)"
+                                {:shape :single!})))))
+
+    (testing "......CTS circle type"
+      (with-open [session (create-session db)]
         (is (= "cts:circle"
                (result->type (execute-xquery session "cts:circle(20, cts:point(37.655983, -122.425525))"
-                                             {:types :raw}))))
-        (is (= "@20 37.655983,-122.42552"
-               (execute-xquery session "cts:circle(20, cts:point(37.655983, -122.425525))"
-                               {:shape :single!}))))
-
-      (testing "......CTS point type"
+                                             {:types :raw})))))
+
+        (with-open [session (create-session db)]
+          (is (= "@20 37.655983,-122.42552"
+                 (execute-xquery session "cts:circle(20, cts:point(37.655983, -122.425525))"
+                                 {:shape :single!})))))
+
+    (testing "......CTS point type"
+      (with-open [session (create-session db)]
         (is (= "cts:point"
                (result->type (execute-xquery session "cts:point(37.655983, -122.425525)"
-                                             {:types :raw}))))
+                                             {:types :raw})))))
+
+      (with-open [session (create-session db)]
         (is (= "37.655983,-122.42552"
                (execute-xquery session "cts:point(37.655983, -122.425525)"
-                               {:shape :single!}))))
-
-      (testing "......CTS polygon type"
+                               {:shape :single!})))))
+
+    (testing "......CTS polygon type"
+      (with-open [session (create-session db)]
         (is (= "cts:polygon"
-               (result->type (execute-xquery session "(: this polygon approximates the 94041 zip code :)
-                                                    let $points := (cts:point(0.373899653086420E+02, -0.122078578406509E+03),
-                                                      cts:point(0.373765400000000E+02, -0.122063772000000E+03),
-                                                      cts:point(0.373781400000000E+02, -0.122067972000000E+03),
-                                                      cts:point(0.373825650000000E+02, -0.122068365000000E+03),
-                                                      cts:point(0.373797400000000E+02, -0.122072172000000E+03),
-                                                      cts:point(0.373899400000000E+02, -0.122092573000000E+03),
-                                                      cts:point(0.373941400000000E+02, -0.122095573000000E+03),
-                                                      cts:point(0.373966400000000E+02, -0.122094173000000E+03),
-                                                      cts:point(0.373958400000000E+02, -0.122092373000000E+03),
-                                                      cts:point(0.374004400000000E+02, -0.122091273000000E+03),
-                                                      cts:point(0.374004400000000E+02, -0.122091273000000E+03),
-                                                      cts:point(0.373873400000000E+02, -0.122057872000000E+03),
-                                                      cts:point(0.373873400000000E+02, -0.122057872000000E+03),
-                                                      cts:point(0.373854400000000E+02, -0.122052672000000E+03),
-                                                      cts:point(0.373833400000000E+02, -0.122053372000000E+03),
-                                                      cts:point(0.373819400000000E+02, -0.122057572000000E+03),
-                                                      cts:point(0.373775400000000E+02, -0.122060872000000E+03),
-                                                      cts:point(0.373765400000000E+02, -0.122063772000000E+03) )
+               (result->type
+                (execute-xquery
+                 session
+                 "(: this polygon approximates the 94041 zip code :)
+                  let $points := (cts:point(0.373899653086420E+02, -0.122078578406509E+03),
+                                  cts:point(0.373765400000000E+02, -0.122063772000000E+03),
+                                  cts:point(0.373781400000000E+02, -0.122067972000000E+03),
+                                  cts:point(0.373825650000000E+02, -0.122068365000000E+03),
+                                  cts:point(0.373797400000000E+02, -0.122072172000000E+03),
+                                  cts:point(0.373899400000000E+02, -0.122092573000000E+03),
+                                  cts:point(0.373941400000000E+02, -0.122095573000000E+03),
+                                  cts:point(0.373966400000000E+02, -0.122094173000000E+03),
+                                  cts:point(0.373958400000000E+02, -0.122092373000000E+03),
+                                  cts:point(0.374004400000000E+02, -0.122091273000000E+03),
+                                  cts:point(0.374004400000000E+02, -0.122091273000000E+03),
+                                  cts:point(0.373873400000000E+02, -0.122057872000000E+03),
+                                  cts:point(0.373873400000000E+02, -0.122057872000000E+03),
+                                  cts:point(0.373854400000000E+02, -0.122052672000000E+03),
+                                  cts:point(0.373833400000000E+02, -0.122053372000000E+03),
+                                  cts:point(0.373819400000000E+02, -0.122057572000000E+03),
+                                  cts:point(0.373775400000000E+02, -0.122060872000000E+03),
+                                  cts:point(0.373765400000000E+02, -0.122063772000000E+03) )
                                                     return
                                                     cts:polygon($points)"
-                                             {:types :raw}))))
+                 {:types :raw})))))
+
+
+      (with-open [session (create-session db)]
         (is (= "37.389965,-122.07858 37.37654,-122.06377 37.37814,-122.06797 37.382565,-122.06837 37.37974,-122.07217 37.38994,-122.09257 37.39414,-122.09557 37.39664,-122.09417 37.39584,-122.09237 37.40044,-122.09127 37.40044,-122.09127 37.38734,-122.05787 37.38734,-122.05787 37.38544,-122.05267 37.38334,-122.05337 37.38194,-122.05757 37.37754,-122.06087 37.37654,-122.06377 37.389965,-122.07858"
                (execute-xquery session "(: this polygon approximates the 94041 zip code :)
                                       let $points := (cts:point(0.373899653086420E+02, -0.122078578406509E+03),
@@ -659,33 +666,38 @@
                                         cts:point(0.373765400000000E+02, -0.122063772000000E+03) )
                                       return
                                       cts:polygon($points)"
-                               {:shape :single!})))))
-
-    (testing "...XDM types"    ;; TODO
-      ;; FIXME
-
-      ;; XDMBinary
-      (comment (execute-xquery session "xquery version \"1.0-ml\"; xdmp:document-load(\"/path/to/mlfavicon.png\");")
-               (execute-xquery session "xquery version \"1.0-ml\"; doc(\"/path/to/mlfavicon.png\");")))
-
-    (testing "...XS types"
-      (testing "......XSAnyURI"
+                               {:shape :single!}))))))
+
+  ;; (testing "...XDM types"    ;; TODO
+  ;;   ;; FIXME
+
+  ;;   ;; XDMBinary
+  ;;   (comment (execute-xquery session "xquery version \"1.0-ml\"; xdmp:document-load(\"/path/to/mlfavicon.png\");")
+  ;;            (execute-xquery session "xquery version \"1.0-ml\"; doc(\"/path/to/mlfavicon.png\");")))
+
+  (testing "...XS types"
+    (testing "......XSAnyURI"
+      (with-open [session (create-session db)]
         (is (= "xs:anyURI"
                (result->type (execute-xquery session "fn:resolve-uri(\"hello/goodbye.xml\", \"http://mycompany/default.xqy\")"
-                                             {:types :raw}))))
+                                             {:types :raw})))))
+
+      (with-open [session (create-session db)]
         (is (= "http://mycompany/hello/goodbye.xml"
                (execute-xquery session "fn:resolve-uri(\"hello/goodbye.xml\",
                                                  \"http://mycompany/default.xqy\")"
-                               {:shape :single!}))))
-
-      ;; TODO relevant?
-      ;; from https://docs.marklogic.com/xdmp:base64-encode
-      ;; xdmp:base64-encode("slings and arrows of outrageous fortune")
-      ;;     => c2xpbmdzIGFuZCBhcnJvd3Mgb2Ygb3V0cmFnZW91cyBmb3J0dW5l
-      (comment (testing "......XSBase64Binary" ;; FIXME
-                 (execute-xquery session "xs:base64Binary(\"bmhnY2p2\")" {:shape :single!})))
-
-      (testing "......XSBoolean"
+                               {:shape :single!})))))
+
+    ;; TODO relevant?
+    ;; from https://docs.marklogic.com/xdmp:base64-encode
+    ;; xdmp:base64-encode("slings and arrows of outrageous fortune")
+    ;;     => c2xpbmdzIGFuZCBhcnJvd3Mgb2Ygb3V0cmFnZW91cyBmb3J0dW5l
+    (comment (testing "......XSBase64Binary" ;; FIXME
+               (with-open [session (create-session db)]
+                 (execute-xquery session "xs:base64Binary(\"bmhnY2p2\")" {:shape :single!}))))
+
+    (testing "......XSBoolean"
+      (with-open [session (create-session db)]
         (is (= "xs:boolean"
                (result->type (execute-xquery session "fn:doc-available(\"derp\")"
                                              {:types :raw}))))
@@ -693,95 +705,107 @@
         (is (= "xs:boolean"
                (result->type (execute-xquery session "xdmp:exists(collection())"
                                              {:types :raw}))))
-        (is (true? (execute-xquery session "xdmp:exists(collection())" {:shape :single!}))))
-
-      (testing "......XSDate"
+        (is (true? (execute-xquery session "xdmp:exists(collection())" {:shape :single!})))))
+
+    (testing "......XSDate"
+      (with-open [session (create-session db)]
         (is (= "xs:date"
                (result->type (execute-xquery session "fn:adjust-date-to-timezone(xs:date(\"2002-03-07-07:00\"),())"
                                              {:types :raw}))))
         (is (= "2002-03-07"
                (execute-xquery session "fn:adjust-date-to-timezone(xs:date(\"2002-03-07-07:00\"),
-                                                             ())"
-                               {:shape :single!}))))
-
-      (testing "......XSDateTime"
+                                                           ())"
+                               {:shape :single!})))))
+
+    (testing "......XSDateTime"
+      (with-open [session (create-session db)]
         (is (= "xs:dateTime"
                (result->type (execute-xquery session "fn:adjust-dateTime-to-timezone(xs:dateTime(\"2002-03-07T10:00:00\"), ())"
                                              {:types :raw}))))
         (is (= "2002-03-07T10:00:00"
                (execute-xquery session "fn:adjust-dateTime-to-timezone(xs:dateTime(\"2002-03-07T10:00:00\"), ())"
-                               {:shape :single!}))))
-
-      (testing "......XSDayTimeDuration"
+                               {:shape :single!})))))
+
+    (testing "......XSDayTimeDuration"
+      (with-open [session (create-session db)]
         (is (= "xs:dayTimeDuration"
                (result->type (execute-xquery session "xquery version \"0.9-ml\"
-                                                    fn:subtract-dateTimes-yielding-dayTimeDuration(fn:adjust-dateTime-to-timezone(xs:dateTime(\"2002-03-07T10:00:00\"), ()), xs:dateTime(\"2000-01-11T12:01:00.000Z\"))" ;; this fn removed in version 1.0; only used to get correct response type
+                                                  fn:subtract-dateTimes-yielding-dayTimeDuration(fn:adjust-dateTime-to-timezone(xs:dateTime(\"2002-03-07T10:00:00\"), ()), xs:dateTime(\"2000-01-11T12:01:00.000Z\"))" ;; this fn removed in version 1.0; only used to get correct response type
                                              {:types :raw}))))
         (is (= "P785DT20H59M"
                (execute-xquery session "xquery version \"0.9-ml\"
-                                      fn:subtract-dateTimes-yielding-dayTimeDuration(fn:adjust-dateTime-to-timezone(xs:dateTime(\"2002-03-07T10:00:00\"),
-                                                                                ()),
-                                                                                xs:dateTime(\"2000-01-11T12:01:00.000Z\"))"
-                               {:shape :single!}))))
-
-      (testing "......XSDecimal"
+                                    fn:subtract-dateTimes-yielding-dayTimeDuration(fn:adjust-dateTime-to-timezone(xs:dateTime(\"2002-03-07T10:00:00\"),
+                                                                                ()),
+                                                                                xs:dateTime(\"2000-01-11T12:01:00.000Z\"))"
+                               {:shape :single!})))))
+
+    (testing "......XSDecimal"
+      (with-open [session (create-session db)]
         (is (= "xs:decimal" (result->type (execute-xquery session "fn:abs(-1.2)"
                                                           {:types :raw}))))
-        (is (= 1.2 (execute-xquery session "fn:abs(-1.2)" {:shape :single!}))))
-
-      (testing "......XSDouble"
+        (is (= 1.2 (execute-xquery session "fn:abs(-1.2)" {:shape :single!})))))
+
+    (testing "......XSDouble"
+      (with-open [session (create-session db)]
         (is (= "xs:double" (result->type (execute-xquery session "fn:number(-1.2)"
                                                          {:types :raw}))))
         (is (= -1.2 (execute-xquery session "fn:number(-1.2)" {:shape :single!})))
         (is (= "xs:double" (result->type (execute-xquery session "xs:double(-1.2)"
                                                          {:types :raw}))))
-        (is (= -1.2 (execute-xquery session "xs:double(-1.2)" {:shape :single!}))))
-
-      (testing "......XSDuration"
+        (is (= -1.2 (execute-xquery session "xs:double(-1.2)" {:shape :single!})))))
+
+    (testing "......XSDuration"
+      (with-open [session (create-session db)]
         (is (= "xs:duration"
                (result->type (execute-xquery session "xs:duration(\"P3DT10H\")"
                                              {:types :raw}))))
         (is (= "P3DT10H"
-               (execute-xquery session "xs:duration(\"P3DT10H\")" {:shape :single!}))))
-
-      (testing "......XSFloat"
+               (execute-xquery session "xs:duration(\"P3DT10H\")" {:shape :single!})))))
+
+    (testing "......XSFloat"
+      (with-open [session (create-session db)]
         (is (= "xs:float" (result->type (execute-xquery session "xs:float(\"1\")"
                                                         {:types :raw}))))
-        (is (= 1 (execute-xquery session "xs:float(\"1\")" {:shape :single!}))))
-
-      (testing "......Gregorians!"
-        (testing ".........XSGDay"
+        (is (= 1 (execute-xquery session "xs:float(\"1\")" {:shape :single!})))))
+
+    (testing "......Gregorians!"
+      (testing ".........XSGDay"
+        (with-open [session (create-session db)]
           (is (= "xs:gDay" (result->type (execute-xquery session "xs:gDay('---08')"
                                                          {:types :raw}))))
-          (is (= "---08" (execute-xquery session "xs:gDay('---08')" {:shape :single!}))))
-
-        (testing ".........XSGMonth"
+          (is (= "---08" (execute-xquery session "xs:gDay('---08')" {:shape :single!})))))
+
+      (testing ".........XSGMonth"
+        (with-open [session (create-session db)]
           (is (= "xs:gMonth"
                  (result->type (execute-xquery session "xs:gMonth('--08')" {:types :raw}))))
-          (is (= "--08" (execute-xquery session "xs:gMonth('--08')" {:shape :single!}))))
-
-        (testing ".........XSGMonthDay"
+          (is (= "--08" (execute-xquery session "xs:gMonth('--08')" {:shape :single!})))))
+
+      (testing ".........XSGMonthDay"
+        (with-open [session (create-session db)]
           (is (= "xs:gMonthDay"
                  (result->type (execute-xquery session "xs:gMonthDay('--08-20')"
                                                {:types :raw}))))
           (is (= "--08-20"
-                 (execute-xquery session "xs:gMonthDay('--08-20')" {:shape :single!}))))
-
-        (testing ".........XSGYear"
+                 (execute-xquery session "xs:gMonthDay('--08-20')" {:shape :single!})))))
+
+      (testing ".........XSGYear"
+        (with-open [session (create-session db)]
           (is (= "xs:gYear"
                  (result->type (execute-xquery session "xs:gYear('2016')"
                                                {:types :raw}))))
-          (is (= "2016" (execute-xquery session "xs:gYear('2016')" {:shape :single!}))))
-
-        (testing ".........XSGYearMonth"
+          (is (= "2016" (execute-xquery session "xs:gYear('2016')" {:shape :single!})))))
+
+      (testing ".........XSGYearMonth"
+        (with-open [session (create-session db)]
           (is (= "xs:gYearMonth"
                  (result->type (execute-xquery session "xs:gYearMonth('2016-02')"
                                                {:types :raw}))))
           (is (= "2016-02" (execute-xquery session "xs:gYearMonth('2016-02')"
-                                           {:shape :single!})))))
-      ;; end Gregorians
-
-      (testing ".........XSHexBinary"
+                                           {:shape :single!}))))))
+
+    (testing ".........XSHexBinary"
+      (with-open [session (create-session db)]
         (is (= "xs:hexBinary"
                (result->type (execute-xquery session "xs:hexBinary(\"74657374\")"
                                              {:types :raw}))))
@@ -805,58 +829,64 @@
                                              {:types :raw}))))
         (is  (= "BEEF"
                 (execute-xquery session "data(xdmp:subbinary(binary { xs:hexBinary(\"DEADBEEF\") }, 3, 2))"
-                                {:shape :single!}))))
-
-      (testing ".........XSInteger"
+                                {:shape :single!})))))
+
+    (testing ".........XSInteger"
+      (with-open [session (create-session db)]
         (is (= "xs:integer" (result->type (execute-xquery session "xdmp:databases()"
                                                           {:types :raw}))))
-        (is (every? integer? (execute-xquery session "xdmp:databases()"))))
-
-      (testing ".........XSQName"
+        (is (every? integer? (execute-xquery session "xdmp:databases()")))))
+
+    (testing ".........XSQName"
+      (with-open [session (create-session db)]
         (is (= "xs:QName"
                (result->type (execute-xquery session "fn:QName(\"http://www.example.com/example\", \"person\")"
                                              {:types :raw}))))
         (is (= "person"
                (execute-xquery session "fn:QName(\"http://www.example.com/example\", \"person\")"
-                               {:shape :single!}))))
-
-      (testing ".........XSString"
+                               {:shape :single!})))))
+
+    (testing ".........XSString"
+      (with-open [session (create-session db)]
         (is (= "xs:string"
                (result->type (execute-xquery session "\"hello world\""
                                              {:types :raw}))))
         (is (= "hello world"
-               (execute-xquery session "\"hello world\"" {:shape :single!}))))
-
-      (testing ".........XSTime"
+               (execute-xquery session "\"hello world\"" {:shape :single!})))))
+
+    (testing ".........XSTime"
+      (with-open [session (create-session db)]
         (is (= "xs:time"
                (result->type (execute-xquery session "fn:adjust-time-to-timezone(xs:time(\"10:00:00\"))"
                                              {:types :raw}))))
         (is (= "10:00:00+02:00"
                (execute-xquery session "fn:adjust-time-to-timezone(xs:time(\"10:00:00\"))"
-                               {:shape :single!}))))
-
-      (testing ".........XSUntypedAtomic"
+                               {:shape :single!})))))
+
+    (testing ".........XSUntypedAtomic"
+      (with-open [session (create-session db)]
         (is (= "xs:untypedAtomic"
                (result->type
                 (execute-xquery session "let $x as xs:untypedAtomic*
-                           := (xs:untypedAtomic(\"cherry\"),
-                               xs:untypedAtomic(\"1\"),
-                               xs:untypedAtomic(\"1\"))
-                         return fn:distinct-values ($x)"
+                         := (xs:untypedAtomic(\"cherry\"),
+                             xs:untypedAtomic(\"1\"),
+                             xs:untypedAtomic(\"1\"))
+                       return fn:distinct-values ($x)"
                                 {:types :raw}))))
         (is (= '("cherry" "1")
                (execute-xquery session "let $x as xs:untypedAtomic*
-                           := (xs:untypedAtomic(\"cherry\"),
-                               xs:untypedAtomic(\"1\"),
-                               xs:untypedAtomic(\"1\"))
-                         return fn:distinct-values ($x)"))))
-
-      (testing ".........XSYearMonthDuration"
+                         := (xs:untypedAtomic(\"cherry\"),
+                             xs:untypedAtomic(\"1\"),
+                             xs:untypedAtomic(\"1\"))
+                       return fn:distinct-values ($x)")))))
+
+    (testing ".........XSYearMonthDuration"
+      (with-open [session (create-session db)]
         (is (= "xs:yearMonthDuration"
                (result->type (execute-xquery session "xquery version \"0.9-ml\"
-                         fn:subtract-dateTimes-yielding-yearMonthDuration(fn:current-dateTime(), xs:dateTime(\"2000-01-11T12:01:00.000Z\"))"
+                       fn:subtract-dateTimes-yielding-yearMonthDuration(fn:current-dateTime(), xs:dateTime(\"2000-01-11T12:01:00.000Z\"))"
                                              {:types :raw}))))
         (is (= "P16Y6M"
                (execute-xquery session "xquery version \"0.9-ml\"
-                         fn:subtract-dateTimes-yielding-yearMonthDuration(fn:current-dateTime(), xs:dateTime(\"2000-01-11T12:01:00.000Z\"))"
+                       fn:subtract-dateTimes-yielding-yearMonthDuration(fn:current-dateTime(), xs:dateTime(\"2000-01-11T12:01:00.000Z\"))"
                                {:shape :single!})))))))


fix config file path in server.clj

fix config file path in server.clj

--- src/misaki/server.clj
+++ src/misaki/server.clj
@@ -72,7 +72,7 @@

   (watcher
     [*template-dir*
-     (str *public-dir* "_config.clj")]
+     (str *base-dir* *config-file*)]
     (rate 50)
     (change-first? false) ; do not compile each templates at first
     (file-filter ignore-dotfiles)


Clean up window title code

Clean up window title code

--- src/nightmod/core.clj
+++ src/nightmod/core.clj
@@ -47,10 +47,10 @@
 (defn create-window
   "Creates the main window."
   [canvas]
-  (doto (s/frame :title (str "Nightmod "
-                             (if-let [p (nc-utils/get-project "nightmod.core")]
-                               (nth p 2)
-                               "beta"))
+  (doto (s/frame :title (str "Nightmod " (or (some-> "nightmod.core"
+                                                     nc-utils/get-project
+                                                     (nth 2))
+                                             "beta"))
                  :width u/window-width
                  :height u/window-height
                  :on-close :nothing)


missing imports

missing imports

--- src/notifier/core.clj
+++ src/notifier/core.clj
@@ -8,7 +8,8 @@
             [clojure.edn :as edn]
             [net.cgrand.enlive-html :as html]
             [org.httpkit.client :as http])
-  (:import java.net.URL
+  (:import [java.io FileReader PushbackReader]
+           java.net.URL
            java.text.DecimalFormat
            java.util.Base64
            javax.crypto.Mac


Fix error handling in rescan loop.

Fix error handling in rescan loop.

--- src/org/scode/sob.clj
+++ src/org/scode/sob.clj
@@ -19,9 +19,10 @@
      (dosync
       (alter repos repos/scan))
      (catch Throwable e
-       (let [trace (java.io.StringWriter.)]
-         (.printStackTrace e trace)
-         (logging/error "repository rescan failed:\n" trace))))
+       (let [trace (java.io.StringWriter.)
+             trace-printer (java.io.PrintWriter. trace)]
+         (.printStackTrace e trace-printer)
+         (logging/error (str "repository rescan failed:\n" trace)))))
     (recur)))

 (defn start-continuous-rescan


bump version to 1.58.2-SNAPSHOT

bump version to 1.58.2-SNAPSHOT

--- scheduler/project.clj
+++ scheduler/project.clj
@@ -13,7 +13,7 @@
 ;; See the License for the specific language governing permissions and
 ;; limitations under the License.
 ;;
-(defproject cook "1.58.1"
+(defproject cook "1.58.2-SNAPSHOT"
   :description "This launches jobs on a Mesos cluster with fair sharing and preemption"
   :license {:name "Apache License, Version 2.0"}
   :dependencies [[org.clojure/clojure "1.10.3"]


Bumps version to 1.55.1-SNAPSHOT

Bumps version to 1.55.1-SNAPSHOT

--- scheduler/project.clj
+++ scheduler/project.clj
@@ -13,7 +13,7 @@
 ;; See the License for the specific language governing permissions and
 ;; limitations under the License.
 ;;
-(defproject cook "1.55.0"
+(defproject cook "1.55.1-SNAPSHOT"
   :description "This launches jobs on a Mesos cluster with fair sharing and preemption"
   :license {:name "Apache License, Version 2.0"}
   :dependencies [[org.clojure/clojure "1.8.0"]


Version bump to 1.59.7-SNAPSHOT

Version bump to 1.59.7-SNAPSHOT

--- scheduler/project.clj
+++ scheduler/project.clj
@@ -13,7 +13,7 @@
 ;; See the License for the specific language governing permissions and
 ;; limitations under the License.
 ;;
-(defproject cook "1.59.6"
+(defproject cook "1.59.7-SNAPSHOT"
   :description "This launches jobs on a Mesos cluster with fair sharing and preemption"
   :license {:name "Apache License, Version 2.0"}
   :dependencies [[org.clojure/clojure "1.10.3"]


CMR-2889 Fixes call to acl->provider-id

CMR-2889 Fixes call to acl->provider-id

--- access-control-app/src/cmr/access_control/services/acl_service.clj
+++ access-control-app/src/cmr/access_control/services/acl_service.clj
@@ -98,7 +98,7 @@
 (defn validate-provider-exists
   "Validates that the acl provider exists."
   [context fieldpath acl]
-  (let [provider-id (index/acl->provider-id acl)]
+  (let [provider-id (acls/acl->provider-id acl)]
     (when (and provider-id (not (some #{provider-id} (map :provider-id (mdb/get-providers context)))))
           {fieldpath [(msg/provider-does-not-exist provider-id)]})))

@@ -417,4 +417,3 @@
   (let [sids (get-sids context username-or-type)
         acls (get-echo-style-acls context)]
     (hash-map target (provider-permissions-granted-by-acls provider-id target sids acls))))
-


(maint) Fix failing integration metrics test

Adds FIXME comments to describe some undesirable behavior we are seeing
the metrics because they are JVM global and persisting between tests.

Something between the commits `118756370f` and `4c0b8e038f` has caused
the tests in puppetlabs.puppetdb.integration.masterless to start calling
`["puppetdb" "facts" "find"]` (only on the `main` branch? this hasn't
failed on 6.x). It is likely caused by changes to how the environment is
loaded in PUP-11328, but it's unclear why it is not failing when testing
PuppetDB against puppetlabs/puppet `6.x`.

```
*   118756370f Josh Cooper 3 weeks ago Merge pull request #8803 from joshcooper/6x_main_merge_oct26
|\
| * e5fcef44cb Josh Cooper 3 weeks ago Merge remote-tracking branch 'upstream/6.x' into 6x_main_merge_oct26
|/|
| *   bb1017f923 Josh Cooper 3 weeks ago Merge pull request #8802 from GabrielNagy/PUP-11328/node-request-fallback
| |\
| | * 867691b617 Josh Cooper 3 weeks ago (PUP-11328) Get the environment's name without loading the environment
| | * 9d3e630a67 Gabriel Nagy 3 weeks ago (PUP-11328) Fallback to node request in configurer
| |/
| * aaae1177c9 Jenkins CI 3 weeks ago (packaging) Updating the puppet.pot file
| *   88905a5505 Gabriel Nagy 3 weeks ago Merge pull request #8784 from luchihoratiu/PUP-11204
| |\
| | * 430ffa30cc Luchian Nemes 4 weeks ago (PUP-11204) Allow `puppet lookup --facts` to receive any filename  (HEAD -> main)
* | | 4c0b8e038f Jenkins CI 3 weeks ago (maint) Merge up 45def53 to main
```

--- test/puppetlabs/puppetdb/integration/puppetserver_metrics.clj
+++ test/puppetlabs/puppetdb/integration/puppetserver_metrics.clj
@@ -37,7 +37,11 @@
                        ["puppetdb" "command" "store_report"]
                        ["puppetdb" "query"]
                        ["puppetdb" "resource" "search"]}
-                     (set (map :metric-id metrics)))))))))
+                     (disj (set (map :metric-id metrics))
+                           ;; ["puppetdb" "facts" "find"] will only be in the set when
+                           ;; puppetlabs.puppetdb.integration.masterless is run first and
+                           ;; the integration tests are running against puppet#main after 118756370f
+                           ["puppetdb" "facts" "find"]))))))))

     (testing "PuppetDB metrics are updated for compressed commands"
       ;; the terminus is configured to send gzipped commands without a
@@ -66,6 +70,8 @@
             metrics-resp (svc-utils/get-ssl new-fact-metrics-url)]
         (is (= 200 (:status metrics-resp)))
         ;; assert that the new-fact-time metric has been updated and no values are 0.0
+        ;; FIXME: OneMinutRate, FiveMinuteRate, FifteenMinuteRate will all be 0.0 unless
+        ;;        puppetlabs.puppetdb.integration.masterless is run first
         (is (->> metrics-resp
                  :body
                  :value


(fix) handle exception

(fix) handle exception

--- src/papaline/core.clj
+++ src/papaline/core.clj
@@ -220,7 +220,11 @@
                               timeout-val))))
   (stop! [this]))

-(defn- run-task2 [^RealizedStage current-stage ctx error-handler]
+(defn- stage-name-aware-error-handler [stage-name user-error-handler]
+  (fn [ctx args e]
+    (process-exception ctx args e stage-name user-error-handler)))
+
+(defn- ^CompletableFuture run-stage [^RealizedStage current-stage ctx]
   (let [task (.stage-fn current-stage)
         args (:args ctx)
         args (if (or (nil? args) ;; empty arguments
@@ -228,16 +232,20 @@
                args [args])]
     (try
       (let [next-args (apply task args)]
-        [(if (instance? CompletableFuture next-args)
-           next-args
-           (CompletableFuture/completedFuture next-args))
-         ctx])
+        (if (instance? CompletableFuture next-args)
+          next-args
+          (CompletableFuture/completedFuture next-args)))
       (catch Exception e
-        (let [new-ctx (process-exception ctx args e (:name current-stage) error-handler)]
-          [(CompletableFuture/completedFuture (:args new-ctx))
-           new-ctx])))))
-
-(defrecord+ AsyncDedicatedThreadPoolPipeline [executor stages error-handler]
+        (let [f (CompletableFuture.)]
+          (.completeExceptionally f e)
+          f)))))
+
+(defn- get-next-ctx [ctx next-args ex error-handler]
+  (if (some? ex)
+    (error-handler ctx (:args ctx) ex)
+    (assoc ctx :args next-args)))
+
+(defrecord+ AsyncDedicatedThreadPoolPipeline [executor stages user-error-handler]
   clojure.lang.IFn
   (invoke [this ctx]
           (let [pre-hook  *pre-execution-hook*
@@ -247,21 +255,21 @@
                              (.toArray ^clojure.lang.ArraySeq (:args ctx))
                              (into-array []))]
             (letfn [(clos [stgs ctx]
-                      (if-let [^RealizedStage s (first stgs)]
-                        (let [[^CompletableFuture next-args-future new-ctx] (run-task2 s ctx error-handler)
+                      (if-let [^RealizedStage current-stage (first stgs)]
+                        (let [current-stage-name (:name current-stage)
+                              error-handler (stage-name-aware-error-handler current-stage-name user-error-handler)
                               processor (Thread/currentThread)]
-                          (.handle ^CompletableFuture next-args-future
+                          (.handle (run-stage current-stage ctx)
                                    (reify BiFunction
                                      (apply [_ next-args ex]
                                        (if (= processor (Thread/currentThread))
-                                         (process-result (assoc new-ctx :args next-args) stgs)
+                                         (-> (get-next-ctx ctx next-args ex error-handler)
+                                             (process-result stgs))
                                          (.submit ^ExecutorService executor
                                                   (wrap-with-arguments-aware-callable
                                                     (fn []
-                                                      (let [ctx (if (some? ex)
-                                                                  (process-exception new-ctx (:args new-ctx) ex (:name s) error-handler)
-                                                                  (assoc new-ctx :args next-args))]
-                                                        (process-result ctx stgs)))
+                                                      (-> (get-next-ctx ctx next-args ex error-handler)
+                                                          (process-result stgs)))
                                                     args-array)))))))
                         (do
                           (when post-hook (post-hook ctx))
@@ -272,9 +280,9 @@
                         (if (or (:abort ctx) use-fork-or-join?)
                           (do
                             (when post-hook (post-hook ctx))
-                            (when (and error-handler use-fork-or-join?)
+                            (when (and user-error-handler use-fork-or-join?)
                               (try
-                                (error-handler (UnsupportedOperationException. "Fork or Join is not supported in AsyncDedicatedThreadPoolPipeline"))
+                                (user-error-handler (UnsupportedOperationException. "Fork or Join is not supported in AsyncDedicatedThreadPoolPipeline"))
                                 (catch Exception _)))
                             (.complete result ctx))
                           (clos (rest stgs) ctx))))]


Change ; to ;; in line comments

Change ; to ;; in line comments

--- cortex/src/cortex/optimise.cljc
+++ cortex/src/cortex/optimise.cljc
@@ -152,38 +152,38 @@
 ;; Mikera optimiser
 ;; TODO: complete conversion of algorithm

-;(def ^:const MIKERA-DEFAULT-LEARN-RATE 0.01)
-;(def ^:const MIKERA-DEFAULT-DECAY 0.95)
-;
-;(defn mikera-optimiser
-;  "Constructs a new mikera optimiser of the given size (parameter length)"
-;  ([size]
-;    (sgd-optimiser size nil))
-;  ([size {:keys [learn-rate decay] :as options}]
-;    (MikeraOptimiser. (new-mutable-vector size)
-;                      (new-mutable-vector size)
-;                      (new-mutable-vector size)
-;                      (new-mutable-vector size)
-;                      nil
-;                      options)))
-;
-;(defrecord MikeraOptimiser [parameters
-;                            mean-x
-;                            mean-g2
-;                            dx]
-;  cp/PGradientOptimiser
-;    (compute-parameters [this gradient parameters]
-;      (let [learn-rate (double (or (:learn-rate this) MIKERA-DEFAULT-LEARN-RATE))
-;            decay (double (or (:decay this) MIKERA-DEFAULT-DECAY))]
-;
-;        (m/assign! dx parameters)
-;        (m/sub! dx mean-x)
-;
-;        ;; accumulate the latest gradient
-;        (m/add-scaled! dx gradient (* -1.0 learn-rate))
-;
-;        ;; return the updated adadelta record. Mutable gradients have been updated
-;        (assoc this :parameters (m/add parameters dx)))))
+;;(def ^:const MIKERA-DEFAULT-LEARN-RATE 0.01)
+;;(def ^:const MIKERA-DEFAULT-DECAY 0.95)
+;;
+;;(defn mikera-optimiser
+;;  "Constructs a new mikera optimiser of the given size (parameter length)"
+;;  ([size]
+;;    (sgd-optimiser size nil))
+;;  ([size {:keys [learn-rate decay] :as options}]
+;;    (MikeraOptimiser. (new-mutable-vector size)
+;;                      (new-mutable-vector size)
+;;                      (new-mutable-vector size)
+;;                      (new-mutable-vector size)
+;;                      nil
+;;                      options)))
+;;
+;;(defrecord MikeraOptimiser [parameters
+;;                            mean-x
+;;                            mean-g2
+;;                            dx]
+;;  cp/PGradientOptimiser
+;;    (compute-parameters [this gradient parameters]
+;;      (let [learn-rate (double (or (:learn-rate this) MIKERA-DEFAULT-LEARN-RATE))
+;;            decay (double (or (:decay this) MIKERA-DEFAULT-DECAY))]
+;;
+;;        (m/assign! dx parameters)
+;;        (m/sub! dx mean-x)
+;;
+;;        ;; accumulate the latest gradient
+;;        (m/add-scaled! dx gradient (* -1.0 learn-rate))
+;;
+;;        ;; return the updated adadelta record. Mutable gradients have been updated
+;;        (assoc this :parameters (m/add parameters dx)))))

 ;; ==============================================
 ;; SGD optimiser with momentum


Adjust math macros to avoid possible issues

--- src/play_clj/math.clj
+++ src/play_clj/math.clj
@@ -38,7 +38,8 @@

 (defmacro bezier
   [points & options]
-  `(u/calls! ^Bezier (bezier* ~points) ~@options))
+  `(let [^Bezier object# (bezier* ~points)]
+     (u/calls! object# ~@options)))

 (defmacro bezier!
   [object k & options]
@@ -52,7 +53,8 @@

 (defmacro bresenham2
   [& options]
-  `(u/calls! ^Bresenham2 (bresenham2*) ~@options))
+  `(let [^Bresenham2 object# (bresenham2*)]
+     (u/calls! object# ~@options)))

 (defmacro bresenham2!
   [object k & options]
@@ -68,7 +70,8 @@

 (defmacro b-spline
   [points degree cont? & options]
-  `(u/calls! ^BSpline (b-spline* ~points ~degree ~cont?) ~@options))
+  `(let [^BSpline object# (b-spline* ~points ~degree ~cont?)]
+     (u/calls! object# ~@options)))

 (defmacro b-spline!
   [object k & options]
@@ -84,7 +87,8 @@

 (defmacro catmull-rom-spline
   [points cont? & options]
-  `(u/calls! ^CatmullRomSpline (catmull-rom-spline* ~points ~cont?) ~@options))
+  `(let [^CatmullRomSpline object# (catmull-rom-spline* ~points ~cont?)]
+     (u/calls! object# ~@options)))

 (defmacro catmull-rom-spline!
   [object k & options]
@@ -100,7 +104,8 @@

 (defmacro circle
   [x y radius & options]
-  `(u/calls! ^Circle (circle* ~x ~y ~radius) ~@options))
+  `(let [^Circle object# (circle* ~x ~y ~radius)]
+     (u/calls! object# ~@options)))

 (defmacro circle!
   [object k & options]
@@ -114,7 +119,8 @@

 (defmacro convex-hull
   [& options]
-  `(u/calls! ^ConvexHull (convex-hull*) ~@options))
+  `(let [^ConvexHull object# (convex-hull*)]
+     (u/calls! object# ~@options)))

 (defmacro convex-hull!
   [object k & options]
@@ -128,7 +134,8 @@

 (defmacro delaunay-triangulator
   [& options]
-  `(u/calls! ^DelaunayTriangulator (delaunay-triangulator*) ~@options))
+  `(let [^DelaunayTriangulator object# (delaunay-triangulator*)]
+     (u/calls! object# ~@options)))

 (defmacro delaunay-triangulator!
   [object k & options]
@@ -142,7 +149,8 @@

 (defmacro ear-clipping-triangulator
   [& options]
-  `(u/calls! ^EarClippingTriangulator (ear-clipping-triangulator*) ~@options))
+  `(let [^EarClippingTriangulator object# (ear-clipping-triangulator*)]
+     (u/calls! object# ~@options)))

 (defmacro ear-clipping-triangulator!
   [object k & options]
@@ -158,7 +166,8 @@

 (defmacro ellipse
   [x y width height & options]
-  `(u/calls! ^Ellipse (ellipse* ~x ~y ~width ~height) ~@options))
+  `(let [^Ellipse object# (ellipse* ~x ~y ~width ~height)]
+     (u/calls! object# ~@options)))

 (defmacro ellipse!
   [object k & options]
@@ -172,7 +181,8 @@

 (defmacro float-counter
   [window-size & options]
-  `(u/calls! ^FloatCounter (float-counter* ~window-size) ~@options))
+  `(let [^FloatCounter object# (float-counter* ~window-size)]
+     (u/calls! object# ~@options)))

 (defmacro float-counter!
   [object k & options]
@@ -186,7 +196,8 @@

 (defmacro frustum
   [& options]
-  `(u/calls! ^Frustum (frustum*) ~@options))
+  `(let [^Frustum object# (frustum*)]
+     (u/calls! object# ~@options)))

 (defmacro frustum!
   [object k & options]
@@ -200,7 +211,8 @@

 (defmacro grid-point-2
   [x y & options]
-  `(u/calls! ^GridPoint2 (grid-point-2* ~x ~y) ~@options))
+  `(let [^GridPoint2 object# (grid-point-2* ~x ~y)]
+     (u/calls! object# ~@options)))

 (defmacro grid-point-2!
   [object k & options]
@@ -214,7 +226,8 @@

 (defmacro grid-point-3
   [x y z & options]
-  `(u/calls! ^GridPoint3 (grid-point-3* ~x ~y ~z) ~@options))
+  `(let [^GridPoint3 object# (grid-point-3* ~x ~y ~z)]
+     (u/calls! object# ~@options)))

 (defmacro grid-point-3!
   [object k & options]
@@ -230,7 +243,8 @@

 (defmacro matrix-3
   [values & options]
-  `(u/calls! ^Matrix3 (matrix-3* ~values) ~@options))
+  `(let [^Matrix3 object# (matrix-3* ~values)]
+     (u/calls! object# ~@options)))

 (defmacro matrix-3!
   [object k & options]
@@ -246,7 +260,8 @@

 (defmacro matrix-4
   [values & options]
-  `(u/calls! ^Matrix4 (matrix-4* ~values) ~@options))
+  `(let [^Matrix4 object# (matrix-4* ~values)]
+     (u/calls! object# ~@options)))

 (defmacro matrix-4!
   [object k & options]
@@ -260,7 +275,8 @@

 (defmacro plane
   [normal d & options]
-  `(u/calls! ^Plane (plane* ~normal ~d) ~@options))
+  `(let [^Plane object# (plane* ~normal ~d)]
+     (u/calls! object# ~@options)))

 (defmacro plane!
   [object k & options]
@@ -276,7 +292,8 @@

 (defmacro polygon
   [vertices & options]
-  `(u/calls! ^Polygon (polygon* ~vertices) ~@options))
+  `(let [^Polygon object# (polygon* ~vertices)]
+     (u/calls! object# ~@options)))

 (defmacro polygon!
   [object k & options]
@@ -292,7 +309,8 @@

 (defmacro polyline
   [vertices & options]
-  `(u/calls! ^Polyline (polyline* ~vertices) ~@options))
+  `(let [^Polyline object# (polyline* ~vertices)]
+     (u/calls! object# ~@options)))

 (defmacro polyline!
   [object k & options]
@@ -308,7 +326,8 @@

 (defmacro quaternion
   [w x y z & options]
-  `(u/calls! ^Quaternion (quaternion* ~w ~x ~y ~z) ~@options))
+  `(let [^Quaternion object# (quaternion* ~w ~x ~y ~z)]
+     (u/calls! object# ~@options)))

 (defmacro quaternion!
   [object k & options]
@@ -324,7 +343,8 @@

 (defmacro rectangle
   [x y width height & options]
-  `(u/calls! ^Rectangle (rectangle* ~x ~y ~width ~height) ~@options))
+  `(let [^Rectangle object# (rectangle* ~x ~y ~width ~height)]
+     (u/calls! object# ~@options)))

 (defmacro rectangle!
   [object k & options]
@@ -340,7 +360,8 @@

 (defmacro vector-2
   [x y & options]
-  `(u/calls! ^Vector2 (vector-2* ~x ~y) ~@options))
+  `(let [^Vector2 object# (vector-2* ~x ~y)]
+     (u/calls! object# ~@options)))

 (defmacro vector-2!
   [object k & options]
@@ -356,7 +377,8 @@

 (defmacro vector-3
   [x y z & options]
-  `(u/calls! ^Vector3 (vector-3* ~x ~y ~z) ~@options))
+  `(let [^Vector3 object# (vector-3* ~x ~y ~z)]
+     (u/calls! object# ~@options)))

 (defmacro vector-3!
   [object k & options]
@@ -370,7 +392,8 @@

 (defmacro windowed-mean
   [window-size & options]
-  `(u/calls! ^WindowedMean (windowed-mean* ~window-size) ~@options))
+  `(let [^WindowedMean object# (windowed-mean* ~window-size)]
+     (u/calls! object# ~@options)))

 (defmacro windowed-mean!
   [object k & options]


Stop failed scroll touchmove from chucking touchstart

--- src/playmary/one.cljs
+++ src/playmary/one.cljs
@@ -250,7 +250,7 @@
           {{x2 :x y2 :y} :position} t]
       (assoc touches touch-id
              (-> t (assoc :x-distance (- x1 x2)) (assoc :y-distance (- y1 y2)))))
-    (dissoc touches touch-id)))
+    touches))

 (defmethod handle-touch "touchend"
   [{touch-id :touch-id :as t} touches out-c]


This does not create template, but applies template to content.

--- src/porwigle/core.clj
+++ src/porwigle/core.clj
@@ -105,7 +105,7 @@
                         ([dateformat] (.format (java.text.SimpleDateFormat. dateformat) (:created page)))))))

 (defn
-  create-template
+  apply-template
   [{id_template :id_template content :content} render-attrs]
   (if (nil? id_template)
     ; Page does not have a template, so content itself is template
@@ -119,7 +119,7 @@
   eval-page
   [page]
   (let [render-attrs (render-attrs-of-page page)]
-    (clostache/render (create-template page render-attrs) render-attrs)))
+    (clostache/render (apply-template page render-attrs) render-attrs)))


Add new random cell if effective step was taken

--- src/pot/core/act.cljs
+++ src/pot/core/act.cljs
@@ -9,10 +9,17 @@
    :up    (comp transpose-board process-board transpose-board)
    :down  (comp transpose-board mirrorv-board process-board mirrorv-board transpose-board)})

+(defn move-and-add
+  [move add board]
+  (let [moved (move board)]
+    (if (not= moved board)
+      (add moved)
+      board)))
+
 (defn move-handler
   [state {:keys [direction]}]
   (let [handler (direction direction-handler-map)]
-    (swap! state update-in [:board] (comp add-random-cell handler))))
+    (swap! state update-in [:board] (partial move-and-add handler add-random-cell))))

 (defn game-over-handler
   [state {:keys [game-over]}]


use syntax sugar for lambda #16

use syntax sugar for lambda #16

--- src/pronouns/util.clj
+++ src/pronouns/util.clj
@@ -48,7 +48,7 @@
   ([pronouns-table sections] (minimum-unambiguous-path pronouns-table sections 1))
   ([pronouns-table sections number-of-sections]
     (let [sections-subset (take number-of-sections sections)
-          results (filter (fn [pronouns] (= (take number-of-sections pronouns) sections-subset)) pronouns-table)]
+          results (filter #(= (take number-of-sections %) sections-subset) pronouns-table)]
       (case (count results)
         0 nil
         1 (clojure.string/join "/" sections-subset)


ProcessBuilder used instead of Runtime/exec

--- src/etaoin/proc.clj
+++ src/etaoin/proc.clj
@@ -4,27 +4,18 @@
            java.lang.IllegalThreadStateException
            java.io.IOException))

-(defmacro exec [& args]
-  `(.exec (Runtime/getRuntime) ~@args))
-
 (defn java-params [params]
   (->> params
        (map str)
        (into-array String)))

-(defn java-env [env]
-  (->> env
-       (map (fn [[k v]]
-              (format "%s=%s" (name k) v)))
-       (into-array String)))
+(defn run [args]
+  (let [pb (java.lang.ProcessBuilder. (java-params args))]
+    (.redirectOutput pb (java.io.File/createTempFile "driver.out" ".log"))
+    (.redirectError pb (java.io.File/createTempFile "driver.err" ".log"))
+    (.start pb)))

-(defn run
-  ([params]
-   (exec (java-params params)))
-  ([params env]
-   (exec (java-params params) (java-env env)))
-  ([params env dir]
-   (exec (java-params params) (java-env env) (io/file dir))))
+;; todo store those streams

 (defn alive? [proc]
   (-> proc .isAlive))
@@ -37,6 +28,8 @@
 (defn kill [proc]
   (-> proc .destroy))

+;; todo refactor those
+
 (defn read-out [proc]
   (try
     (-> proc .getInputStream slurp)


replaced command printing

replaced command printing

--- src/goodbot/bot.clj
+++ src/goodbot/bot.clj
@@ -19,7 +19,7 @@
   (fn [irc message]
     (try
       (when-let [[command updated-message] (extract-command message)]
-
+        (println "COMMAND: " command (str [(:text message)]))
         (if-let [handler (select-handler plugins command)]
           (when-let [responses (handler irc updated-message)]
             (respond-with irc updated-message responses))


Fix the compare function on test code

Fix the compare function on test code

--- test/cljam/io/bigwig_test.clj
+++ test/cljam/io/bigwig_test.clj
@@ -270,8 +270,8 @@
     (with-open [r (bigwig/reader test-bigwig-non-leaf-blocks-file)]
       (is (and (same-bigwig-headers? (.headers r)
                                      (:headers test-non-leaf-blocks-fields))
-               (same-bedgraph? (bigwig/read-tracks r)
-                               (:tracks test-non-leaf-blocks-fields)))))))
+               (same-wig? (bigwig/read-tracks r)
+                          (:tracks test-non-leaf-blocks-fields)))))))

 (deftest source-type-test
   (testing "reader"


Consistent test descriptions

Consistent test descriptions

--- test/desdemona/query_test.clj
+++ test/desdemona/query_test.clj
@@ -6,17 +6,17 @@
 (deftest infix-parser-tests
   (is (= [:expr [:ipv4-address "10" "0" "0" "1"]]
          (#'q/infix-parser "10.0.0.1"))
-      "infix parses ipv4 addresses")
+      "ipv4 addresses")
   (is (= [:expr [:fn-call
                  [:identifier "ip"]
                  [:identifier "x"]]]
          (#'q/infix-parser "ip(x)"))
-      "infix parses simple fn calls")
+      "simple fn calls")
   (is (= [:expr [:eq
                  [:identifier "a"]
                  [:identifier "b"]]]
          (#'q/infix-parser "a = b"))
-      "parse simple equality between identifiers"))
+      "equality between identifiers")

 (deftest infix->dsl-tests
   (is (= '(= (:ip x) "10.0.0.1")


switch over to added-atoms-local

switch over to added-atoms-local

--- src/atom_finder/questions/atom_committers.clj
+++ src/atom_finder/questions/atom_committers.clj
@@ -145,13 +145,13 @@
       (->> rev-commit
            :srcs
            (filter #(and (:atoms-before %) (:atoms-after %)))
-           (pmap #(with-timeout 200 (added-atoms %)))
+           (pmap #(with-timeout 200 (added-atoms-local %)))
            (remove empty?)
            (map prn)
            dorun
           (log-err (str "atom-committers " (->> rev-commit :srcs first :rev-str)) {})
           )))
-       (log-to "tmp/atom-committers_gcc_2018-01-04_XX-test-data.edn")
+       (log-to "tmp/atom-committers_gcc_2018-01-06_added-atoms-local.edn")
        time-mins
        ))


Wrap for with doall

Wrap for with doall

--- src/braid/client/gateway/user_auth/views.cljs
+++ src/braid/client/gateway/user_auth/views.cljs
@@ -5,15 +5,16 @@

 (defn auth-providers-view []
   [:span.auth-providers
-   (for [provider [:github :google :facebook]]
-     ^{:key provider}
-     [:button
-      {:type "button"
-       :class (name provider)
-       :on-click (fn [e]
-                   (.preventDefault e)
-                   (dispatch [:gateway.user-auth/remote-oauth provider]))}
-      (string/capitalize (name provider))])])
+   (doall
+     (for [provider [:github :google :facebook]]
+       ^{:key provider}
+       [:button
+        {:type "button"
+         :class (name provider)
+         :on-click (fn [e]
+                     (.preventDefault e)
+                     (dispatch [:gateway.user-auth/remote-oauth provider]))}
+        (string/capitalize (name provider))]))])

 (defn returning-email-field-view []
   (let [field-id :gateway.user-auth/email


Rename test.

Rename test.

--- test/dsbdp/test/data_processing_dsl_tests.clj
+++ test/dsbdp/test/data_processing_dsl_tests.clj
@@ -251,7 +251,7 @@
         proc-fn (create-mapped-proc-fn dsl-expression 4 7)]
     (is (= expected (proc-fn input-ba {})))))

-(deftest dsl-expression-to-function-vector-test-1
+(deftest dsl-expression-to-mapped-function-vector-test-1
   (let [input-ba (byte-array (map byte [0 1 2 3 4 5 6 7 8 9]))
         expected-0 {"a" 0, "b" 1, "c" 2, "d" 3}
         expected-1 {"e" 4, "f" 5, "g" 6}


Quote default expression as well.

Quote default expression as well.

--- test/dsbdp/test/data_processing_dsl_tests.clj
+++ test/dsbdp/test/data_processing_dsl_tests.clj
@@ -474,7 +474,7 @@
                                                                                ['flags '(int8 63)]
                                                                                ['seq-no '(int32 54)]
                                                                                ['ack-no '(int32 58)]]
-                                                          :default (str "Unsupported protocol: " __2_proto-id))]]]]]]}
+                                                          :default '(str "Unsupported protocol: " __2_proto-id))]]]]]]}
         data-processing-fn (create-proc-fn dsl-expression)
         result-udp (data-processing-fn pcap-byte-array-test-data)
         result-tcp (data-processing-fn pcap-tcp-byte-array-test-data)]


Define nnode.

Define nnode.

--- src/isla/parser.clj
+++ src/isla/parser.clj
@@ -3,7 +3,7 @@
   (:use [isla.lexer])
   (:require [clojure.string :as str]))

-(declare parse alternatives is-type pattern-sequence pattern
+(declare parse alternatives is-type pattern-sequence pattern nnode
          -root -block -expression -assignment -invocation
          -nl -integer -is -string -assignee -value -identifier)


tests work better when they're written correclty :sigh:

--- test/metabase/driver/query_processor_test.clj
+++ test/metabase/driver/query_processor_test.clj
@@ -670,7 +670,7 @@
           [1 22]
           [2 59]]
    :cols [(venue-col :price)
-          {:base_type :IntegerField, :special_type :id, :name "count", :id nil, :table_id nil, :description nil}]}
+          {:base_type :IntegerField, :special_type :number, :name "count", :id nil, :table_id nil, :description nil}]}
   {:source_table (id :venues)
    :aggregation  ["distinct" (id :venues :id)]
    :breakout     [(id :venues :price)]
@@ -681,10 +681,10 @@
 (qp-expect-with-datasets #{:generic-sql}
   {:columns [(format-name "price")
              "avg"]
-   :rows [[4 53]
+   :rows [[3 22]
+          [2 28]
           [1 32]
-          [2 28]
-          [3 22]]
+          [4 53]]
    :cols [(venue-col :price)
           {:base_type :IntegerField, :special_type :fk, :name "avg", :id nil, :table_id nil, :description nil}]}
   {:source_table (id :venues)


qfix time input

qfix time input


map secret name to global state

map secret name to global state

--- src/cljs/swarmpit/component/service/edit.cljs
+++ src/cljs/swarmpit/component/service/edit.cljs
@@ -63,7 +63,9 @@
                         (map #(select-keys % [:networkName]))
                         (into [])) networks/cursor)
   (state/set-value (:mounts service) mounts/cursor)
-  (state/set-value (:secrets service) secrets/cursor)
+  (state/set-value (->> (:secrets service)
+                        (map #(select-keys % [:secretName]))
+                        (into [])) secrets/cursor)
   (state/set-value (:variables service) variables/cursor)
   (state/set-value (:labels service) labels/cursor)
   (state/set-value (:deployment service) deployment/cursor))


CMR-513: Removed debug output.

CMR-513: Removed debug output.

--- src/cmr/metadata_db/data/oracle/sql_utils.clj
+++ src/cmr/metadata_db/data/oracle/sql_utils.clj
@@ -50,5 +50,4 @@
   and starting at a given index."
   [db stmt start-index batch-size]
   (let [stmt (find-batch-sql stmt start-index batch-size)]
-    (println (pr-str stmt))
     (j/query db stmt)))


Replace pointless record schema w/ map

Replace pointless record schema w/ map

--- src/com/frereth/server/connection_manager.clj
+++ src/com/frereth/server/connection_manager.clj
@@ -1,5 +1,8 @@
 (ns com.frereth.server.connection-manager
-  "Poorly chosen name. principal-wrangler seems like it would have been more appropriate"
+  "Poorly chosen name. principal-wrangler seems like it would have been more appropriate.
+
+This namespace is really a prototype version of managing users.
+Which really doesn't belong in here at all."
   (:require [com.stuartsierra.component :as component]
             [com.frereth.common.schema :as fr-skm]
             [ribol.core :refer (raise)]
@@ -8,18 +11,12 @@
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; Schema

-(s/defrecord User
-    [id :- s/Uuid
-     nick-name :- s/Str
-     socket]
-  ; Q: Is there a good reason this isn't a hashmap?
-  )
 (def user
   {:id s/Uuid
    :nick-name s/Str
    :socket s/Any})

-(def user-directory {:s/Uuid User})
+(def user-directory {:s/Uuid user})

 (s/defrecord Directory [control-socket
                         users :- fr-skm/atom-type]
@@ -33,7 +30,7 @@
          base {:id id
                :nick-name nick-name
                :socket socket}
-         initial-user #_(strict-map->User base) base
+         initial-user base
          users (or users (atom {}))]
      ;; This is strictly for the sake of getting started.
      ;; If there's already an admin in users, shouldn't add another


Work on speeding up index tests.

Work on speeding up index tests.

--- test/merkle_db/index_test.clj
+++ test/merkle_db/index_test.clj
@@ -162,6 +162,16 @@
            (index/read-all store root nil)))))

+(defmacro timer
+  [label & body]
+  `(let [start# (System/nanoTime)
+         result# (do ~@body)
+         elapsed# (/ (- (System/nanoTime) start#) 1e6)]
+     (printf "%s: %.2f ms\n" ~label elapsed#)
+     (flush)
+     result#))
+
+
 (deftest ^:generative index-updates
   (let [field-keys #{:a :b :c :d}]
     (checking "tree updates" 50
@@ -171,13 +181,27 @@
            (gen/large-integer* {:min 4, :max 32})
            (gen/large-integer* {:min 5, :max 500})
            (gen/bind
-             (gen/set mdgen/record-key {:min-elements 10})
-             (fn [all-keys]
-               (let [all-keys (sort all-keys)]
+             (gen/large-integer* {:min 10, :max 5000})
+             (fn [n]
+               (let [all-keys (map #(key/encode key/long-lexicoder %) (range n))]
                  (gen/tuple
                    (tcgen/subsequence all-keys)
-                   (tcgen/subsequence all-keys)
-                   (tcgen/subsequence all-keys))))))]
+                   (gen/fmap
+                     (fn [fracs]
+                       (->> (map list fracs all-keys)
+                            (filter #(< 0.85 (first %)))
+                            (map second)))
+                     (apply gen/tuple (repeat (count all-keys) (gen/double* {:min 0.0, :max 1.0}))))
+                   (gen/fmap
+                     (fn [fracs]
+                       (->> (map list fracs all-keys)
+                            (filter #(< 0.85 (first %)))
+                            (map second)))
+                     (apply gen/tuple (repeat (count all-keys) (gen/double* {:min 0.0, :max 1.0})))))))))]
+      (printf "\n===============\n")
+      (printf "%d records, %d updates, %d deletions\n"
+              (count rkeys) (count ukeys) (count dkeys))
+      (flush)
       (let [store (mdag/init-store :types graph/codec-types)
             params {::record/families families
                     ::index/fan-out fan-out
@@ -185,17 +209,21 @@
             records (map-indexed #(vector %2 {:a %1}) rkeys)
             updates (map-indexed #(vector %2 {:b %1}) ukeys)
             deletions (map vector dkeys (repeat ::patch/tombstone))
-            changes (into (sorted-map) (concat updates deletions))
-            root (index/from-records store params records)
-            root' (index/update-tree store params root (vec changes))
-            expected-data (-> (into (sorted-map) records)
-                              (merge changes)
-                              (patch/remove-tombstones))]
+            changes (patch/patch-seq deletions updates)
+            root (let [parts (timer "partition records"
+                               (part/partition-records store params records))]
+                   (timer "build tree"
+                     (index/build-tree store params parts)))
+            root' (timer "update tree"
+                    (index/update-tree store params root (vec changes)))
+            expected-data (patch/patch-seq changes records)]
         (is (= expected-data (index/read-all store root' nil)))
-        (tu/check-asserts
-          (validate/run!
-            store
-            (::node/id (meta root'))
-            validate/validate-data-tree
-            (assoc params ::record/count (count expected-data))))
-        ))))
+        (timer "check-asserts"
+          (tu/check-asserts
+            (validate/run!
+              store
+              (::node/id (meta root'))
+              validate/validate-data-tree
+              (assoc params ::record/count (count expected-data)))))
+        (printf "---------------\n")
+        (flush)))))


slight performance improvement for HTTP client

--- test/metabase/http_client.clj
+++ test/metabase/http_client.clj
@@ -143,8 +143,9 @@
   (cond (sequential? response) (map auto-deserialize-dates response)
         (map? response) (->> response
                              (map (fn [[k v]]
-                                    {k (if (contains? auto-deserialize-dates-keys k)
-                                         (deserialize-date v)
-                                         (auto-deserialize-dates v))}))
+                                    {k (cond
+                                         (contains? auto-deserialize-dates-keys k) (deserialize-date v)
+                                         (coll? v) (auto-deserialize-dates v)
+                                         :else v)}))
                              (into {}))
         :else response))


sha-1 as message id.

sha-1 as message id.


process all of a relationship stream

process all of a relationship stream

--- src/er_cassandra/model/alia/relationship.clj
+++ src/er_cassandra/model/alia/relationship.clj
@@ -58,8 +58,7 @@
         denorm-vals (->> (:denormalize denorm-rel)
                          (map (fn [[scol tcol]]
                                 [tcol (get source-record scol)]))
-                         (into {}))
-        ]
+                         (into {}))]
     (case denorm-op

       :upsert
@@ -115,8 +114,7 @@
   "given a Deferred keep only errors, otherwise returning Deferred<nil>"
   [dv]
   (-> dv
-      (d/chain (constantly nil))
-      (d/catch (fn [e] e))))
+      (d/chain (fn [v] (when (instance? Throwable v) v)))))

 (s/defn denormalize-rel
   "denormalizes a single relationship"
@@ -147,10 +145,11 @@
                                        denorm-op
                                        opts))
                              (st/buffer (or (:buffer-size opts) 25))
-                             (st/map only-error)
-                             (st/filter identity))]
+                             (st/map only-error))]

-           maybe-err (st/take! trerrs)]
+           ;; consumes the whole stream, returns the first error
+           ;; or nil if no errors
+           maybe-err (st/reduce (fn [v i] (or v i)) nil trerrs)]

       ;; if there are errors, return the first as an exemplar
       (if (nil? maybe-err)


Finish porting sawtooth to new oscillator design.

--- src/afterglow/effects/oscillators.clj
+++ src/afterglow/effects/oscillators.clj
@@ -158,51 +158,53 @@
   creates a sawtooth wave that ramps upward from `0` to `1` over the
   course of each beat.

+  Passing `true` with `:down?` creates an inverse sawtooth wave (one
+  that ramps downward from `1` to `0` over the course of the interval).
+
   Passing the value `:bar` or `:phrase` with the optional keyword
   argument `:interval` makes the wave cycle over a bar or phrase
   instead.
-
-  Passing `true` with `:down?` creates an inverse sawtooth wave (one
-  that ramps downward from `1` to `0` over the course of the interval).

   Supplying a value with `:interval-ratio` will run the oscillator at
   the specified fraction or multiple of the chosen interval (beat,
   bar, or phrase), and supplying a `:phase` will offset the oscillator
   from the underlying metronome phase by that amount. (See the
   [documentation](https://github.com/brunchboy/afterglow/blob/master/doc/oscillators.adoc#sawtooth-oscillators)
-  for an expanded explanation illustrated with graphs.)"
-  [& {:keys [interval down? interval-ratio phase] :or {interval :beat down? false interval-ratio 1 phase 0.0}}]
-  (let [interval (params/bind-keyword-param interval clojure.lang.Keyword :beat)
-        down? (params/bind-keyword-param down? Boolean false)
-        interval-ratio (params/bind-keyword-param interval-ratio Number 1)
-        phase (params/bind-keyword-param phase Number 0)]
-    (if (not-any? params/param? [interval down? interval-ratio phase])  ; Can optimize case with no dynamic parameters
-      (fixed-sawtooth interval down? interval-ratio phase)
-      (reify IOscillator
-        (evaluate [this show snapshot head]
-          (let [interval (params/resolve-param interval show snapshot head)
-                down? (params/resolve-param down? show snapshot head)
-                interval-ratio (params/resolve-param interval-ratio show snapshot head)
-                phase (params/resolve-param phase show snapshot head)
-                base-phase-fn (build-base-phase-fn interval interval-ratio)
-                adjusted-phase-fn (build-adjusted-phase-fn base-phase-fn phase)
-                upward-sawtooth (adjusted-phase-fn snapshot)]
-            (if down?
-              (- 1.0 upward-sawtooth)  ; Convert to a downward sawtooth wave
-              upward-sawtooth)))
-        (resolve-non-frame-dynamic-elements [this show snapshot head]
-          (if (not-any? params/frame-dynamic-param? [interval down? interval-ratio phase])
-            ;; Can now resolve and optimize
-            (let [interval (params/resolve-param interval show snapshot head)
-                  down? (params/resolve-param down? show snapshot head)
-                  interval-ratio (params/resolve-param interval-ratio show snapshot head)
-                  phase (params/resolve-param phase show snapshot head)]
-              (fixed-sawtooth interval down? interval-ratio phase))
-            ;; Can't optimize, there is at least one frame-dynamic parameter, so return self
-            this))))))
+  for an expanded explanation illustrated with graphs.)
+
+  Other than `:down`, which establishes the basic waveform, all
+  arguments can be [dynamic
+  parameters](https://github.com/brunchboy/afterglow/blob/master/doc/parameters.adoc#dynamic-parameters)."
+  [& {:keys [down? interval interval-ratio phase] :or {down? false interval :beat interval-ratio 1 phase 0.0}}]
+  (let [shape-fn (if down?
+                   (fn [phase] (- 1.0 phase))
+                   (fn [phase] phase))]
+    (build-oscillator shape-fn :interval interval :interval-ratio interval-ratio :phase phase)))

 (defn sawtooth-beat
-  "Returns an oscillator which generates a sawtooth wave relative to the phase
+  "In version 0.1.6 this was replaced with the [[sawtooth]] function,
+  and this stub was left for backwards compatibility, but is
+  deprecated and will be removed in a future release.
+
+  Returns an oscillator which generates a sawtooth wave relative to the
+  phase of the current bar. Passing `true` with `:down?` creates an
+  inverse sawtooth wave (ramps downward rather than upward), supplying
+  a value with `:bar-ratio` will run the oscillator at the specified
+  fraction or multiple of a bar, and supplying a `:phase` will offset
+  the oscillator from the underlying metronome phase by that
+  amount. (See the
+  [documentation](https://github.com/brunchboy/afterglow/blob/master/doc/oscillators.adoc#sawtooth-oscillators)
+  for an expanded explanation illustrated with graphs.)"
+  {:deprecated "0.1.6"}
+  [& {:keys [down? beat-ratio phase] :or {down? false beat-ratio 1 phase 0.0}}]
+  (sawtooth :down? down? :interval-ratio beat-ratio :phase phase))
+
+(defn sawtooth-bar
+  "In version 0.1.6 this was replaced with the [[sawtooth]] function,
+  and this stub was left for backwards compatibility, but is
+  deprecated and will be removed in a future release.
+
+  Returns an oscillator which generates a sawtooth wave relative to the phase
   of the current bar. Passing `true` with `:down?` creates an inverse sawtooth
   wave (ramps downward rather than upward), supplying a value with
   `:bar-ratio` will run the oscillator at the specified fraction or
@@ -211,24 +213,15 @@
   [documentation](https://github.com/brunchboy/afterglow/blob/master/doc/oscillators.adoc#sawtooth-oscillators)
   for an expanded explanation illustrated with graphs.)"
   {:deprecated "0.1.6"}
-  [& {:keys [down? beat-ratio phase] :or {down? false beat-ratio 1 phase 0.0}}]
-  (sawtooth :down? down? :interval-ratio beat-ratio :phase phase))
-
-(defn sawtooth-bar
-  "Returns an oscillator which generates a sawtooth wave relative to the phase
-  of the current bar. Passing `true` with `:down?` creates an inverse sawtooth
-  wave (ramps downward rather than upward), supplying a value with
-  `:bar-ratio` will run the oscillator at the specified fraction or
-  multiple of a bar, and supplying a `:phase` will offset the oscillator
-  from the underlying metronome phase by that amount. (See the
-  [documentation](https://github.com/brunchboy/afterglow/blob/master/doc/oscillators.adoc#sawtooth-oscillators)
-  for an expanded explanation illustrated with graphs.)"
-  {:deprecated "0.1.6"}
   [& {:keys [down? bar-ratio phase] :or {down? false bar-ratio 1 phase 0.0}}]
   (sawtooth :interval :bar :down? down? :interval-ratio bar-ratio :phase phase))

 (defn sawtooth-phrase
-  "Returns an oscillator which generates a sawtooth wave relative to the phase
+  "In version 0.1.6 this was replaced with the [[sawtooth]] function,
+  and this stub was left for backwards compatibility, but is
+  deprecated and will be removed in a future release.
+
+  Returns an oscillator which generates a sawtooth wave relative to the phase
   of the current phrase. Passing `true` with `:down?` creates an inverse sawtooth wave
   (ramps downward rather than upward), supplying a value with
   `:phrase-ratio` will run the oscillator at the specified fraction or


DB config function takes optional filename arg

--- src/swanson/utils.clj
+++ src/swanson/utils.clj
@@ -115,10 +115,13 @@
   (edn/read-string (slurp filename)))

 (defn db-config
-  "load db config"
-  []
-  (let [config-file-name (or (System/getenv "SWANSON_CONFIG") "dev-config.edn")
-        conf (load-config (io/resource config-file-name))]
+  "load db config; defaults to Dev config but will optionally
+  take key/val pair :config-file <file-name>
+  (e.g. 'test-config.edn')"
+  [& {:keys  [config-file]
+      :or  {config-file  "dev-config.edn"}}]
+  (let [file-path (or (System/getenv "SWANSON_CONFIG") config-file)
+        conf (load-config (io/resource file-path))]
     {:classname "org.postgresql.Driver"
      :subprotocol "postgresql"
      :subname (:subname conf)


use DestinationFactory where appropriate

--- dada-core/src/main/clojure/org/dada/core/jms/JMSServiceFactory.clj
+++ dada-core/src/main/clojure/org/dada/core/jms/JMSServiceFactory.clj
@@ -53,7 +53,7 @@
 	     #^Boolean true-async
 	     #^Long timeout
 	     #^Getter name-getter
-	     #^DestinationFactory destination-factory]
+	     #^JMSServiceFactory$DestinationFactory destination-factory]

   [ ;; super ctor args
    []
@@ -64,7 +64,7 @@
 	 server-fn (fn [target end-point]
 		       (println "SERVER INSTANCE" target)
 		       (.setMessageListener
-			(.createConsumer session (.createQueue session end-point))
+			(.createConsumer session (.createDestination destination-factory session end-point))
 			(proxy [MessageListener] [] (onMessage [message] (.execute executor-service (proxy [Runnable] [] (run [] (invoke target message session mapper producer))))))))

 	 client-fn (fn [#^String end-point]
@@ -72,7 +72,7 @@
 		       (Proxy/newProxyInstance
 			(.getContextClassLoader (Thread/currentThread))
 			(into-array Class [interface])
-			(SynchronousClient. session (.createQueue session end-point) interface timeout true-async)) ;; TODO: implement SynchronousClient here...
+			(SynchronousClient. session (.createDestination destination-factory session end-point) interface timeout true-async)) ;; TODO: implement SynchronousClient here...
 		       )

 	 decouple-fn (fn [#^Object target]
@@ -90,7 +90,7 @@

 (defn -client [#^org.dada.core.jms.JMSServiceFactory this #^String end-point]
   (let [[_ client-fn] (.state this)]
-    (client-fn)))
+    (client-fn end-point)))

 (defn -server [#^org.dada.core.jms.JMSServiceFactory this #^Object target #^String end-point]
   (let [[_ _ server-fn] (.state this)]


Refactor to use avaialable props instead of subscriptions

--- src/braid/client/ui/views/thread.cljs
+++ src/braid/client/ui/views/thread.cljs
@@ -48,19 +48,16 @@
          [add-tag-list-view thread close-list!])])))

 (defn thread-tags-view [thread]
-  (let [tags (subscribe [:tags-for-thread (thread :id)])
-        mentions (subscribe [:mentions-for-thread (thread :id)])]
-    (fn [thread]
-      [:div.tags
-       (doall
-         (for [user @mentions]
-           ^{:key (user :id)}
-           [user-pill-view (user :id)]))
-       (doall
-         (for [tag @tags]
-           ^{:key (tag :id)}
-           [tag-pill-view (tag :id)]))
-       [add-tag-button-view thread]])))
+  [:div.tags
+   (doall
+     (for [user-id (thread :mentioned-ids)]
+       ^{:key user-id}
+       [user-pill-view user-id]))
+   (doall
+     (for [tag-id (thread :tag-ids)]
+       ^{:key tag-id}
+       [tag-pill-view tag-id]))
+   [add-tag-button-view thread]])

 (defn messages-view [thread]
   ; Closing over thread-id, but the only time a thread's id changes is the new


c.t.namespace: give new location of deprecated fn

In docstring for deprecated
'clojure.tools.namespace/clojure-source-file?'

--- src/main/clojure/clojure/tools/namespace.clj
+++ src/main/clojure/clojure/tools/namespace.clj
@@ -22,7 +22,7 @@
 ;;; Finding namespaces in a directory tree

 (defn clojure-source-file?
-  "DEPRECATED; trivial to implement locally
+  "DEPRECATED; moved to clojure.tools.namespace.file

   Returns true if file is a normal file with a .clj or .cljc extension."
   {:deprecated "0.2.1"


actually hide the Join Beta UI button behind a FF (#2049)

--- src-cljs/frontend/components/pieces/page_header.cljs
+++ src-cljs/frontend/components/pieces/page_header.cljs
@@ -260,24 +260,24 @@
                                   :on-click #((om/get-shared owner :track-event) {:event-type :feedback-clicked
                                                                                :properties {:component "topbar"
                                                                                :treatment "top-bar-beta"}})}
-                      "Provide Beta UI Feedback")])])
-              (when-not om-next-page?
-                (button/link {:fixed? true
-                              :kind (if has-topbar?
-                                      :secondary
-                                      :primary)
-                              :size :small
-                              :href (if has-topbar?
-                                      "/dashboard"
-                                      (routes/new-org-path {:nav-point (:nav-point topbar-beta)
-                                                            :current-org (:org topbar-beta)}))
-                              :on-click #(do
-                                           (raise! owner [:preferences-updated {state/user-betas-key [toggle-topbar]}])
-                                           ((om/get-shared owner :track-event) {:event-type :topbar-toggled
-                                                                                :properties {:toggle-topbar-text toggle-topbar-text
-                                                                                :has-topbar has-topbar?
-                                                                                :toggled-topbar-on (boolean toggle-topbar)}}))}
-                  toggle-topbar-text))
+                                 "Provide Beta UI Feedback")])]
+                (when-not om-next-page?
+                  (button/link {:fixed? true
+                                :kind (if has-topbar?
+                                        :secondary
+                                        :primary)
+                                :size :small
+                                :href (if has-topbar?
+                                        "/dashboard"
+                                        (routes/new-org-path {:nav-point (:nav-point topbar-beta)
+                                                              :current-org (:org topbar-beta)}))
+                                :on-click #(do
+                                             (raise! owner [:preferences-updated {state/user-betas-key [toggle-topbar]}])
+                                             ((om/get-shared owner :track-event) {:event-type :topbar-toggled
+                                                                                :properties {:toggle-topbar-text toggle-topbar-text
+                                                                                :has-topbar has-topbar?
+                                                                                :toggled-topbar-on (boolean toggle-topbar)}}))}
+                               toggle-topbar-text)))
               actions]]))))))

 (dc/do


Change indentation

Change indentation

--- src/clj/rumahsewa141/routes/admin.clj
+++ src/clj/rumahsewa141/routes/admin.clj
@@ -70,8 +70,10 @@
 (defn- latest-transactions [params]
   (db/get-latest-transactions params))

-(defn admin-page [section get-content-fn
-                  {{username :username} :identity} & [subsection]]
+(defn admin-page [section
+                  get-content-fn
+                  {{username :username} :identity}
+                  & [subsection]]
   (layout/render "member.html" (merge {:username username
                                        :admin true
                                        :section section
@@ -92,9 +94,9 @@
   (GET "/admin/payment" req (admin-page "payment" all-users req))
   (GET "/admin/manage" req (admin-page "manage" (other-users req) req))
   (GET ["/admin/history/:page" :page #"[1-9][0-9]*"] [page :as req]
-       (admin-page "history" (history-view (Long/parseLong page)
-                                           transactions-count
-                                           latest-transactions) req))
+       (admin-page "history"
+                   (history-view (Long/parseLong page) transactions-count latest-transactions)
+                   req))
   (GET "/admin/settings/profile" req (settings-page "profile" req (user-info req)))
   (GET "/admin/settings/account" req (settings-page "account" req))
   (GET "/admin/settings/registration" req (settings-page "registration" req registration-allowed?))


fix(frontend): adapt page options sidebar to new react

--- frontend/src/uxbox/main/ui/workspace/sidebar/options/page.cljs
+++ frontend/src/uxbox/main/ui/workspace/sidebar/options/page.cljs
@@ -68,7 +68,7 @@
            {:type "text"
             :ref "name"
             :on-change on-name-change
-            :value (:name page)
+            :value (str (:name page))
             :placeholder "page name"}]]]

         [:span "Size"]
@@ -78,15 +78,16 @@
            {:type "number"
             :ref "width"
             :on-change #(on-size-change :width)
-            :value (:width metadata)
+            :value (str (:width metadata))
             :placeholder "width"}]]
          [:div.input-element.pixels
           [:input.input-text
            {:type "number"
             :ref "height"
             :on-change #(on-size-change :height)
-            :value (:height metadata)
+            :value (str (:height metadata))
             :placeholder "height"}]]]
+
         [:span "Background color"]
         [:div.row-flex.color-data
          [:span.color-th