Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ jobs:
- name: Test Xapipe
run: make test

lint:
uses: yetanalytics/workflow-linter/.github/workflows/[email protected]
with:
lint-directories: 'src/bench src/build src/cli src/lib src/test'

nvd_scan:
uses: yetanalytics/actions/.github/workflows/[email protected]
with:
Expand Down
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,10 @@ failures/
/logs/
.DS_Store
/dev-resources/bench/*.json

# VSCode
.calva/
.clj-kondo/
.cljs_node_repl/
.lsp/
.vscode/
20 changes: 9 additions & 11 deletions src/bench/com/yetanalytics/xapipe/bench.clj
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
[clojure.java.io :as io]
[com.yetanalytics.xapipe.util.time :as tu]
[java-time :as t]
[java-time.seqs :as tseq])
(:import [java.time Instant]))
[java-time.seqs :as tseq]))

(defn- stamp-seq
"Create a lazy sequence of timestamps"
Expand Down Expand Up @@ -238,15 +237,14 @@
(flush)
r)))
_ (do (print "\n\n") (flush))
]
(let [first-run (first runs)]
(merge (dissoc first-run
:s-per-sec
:total-ms)
{:label label
:runs num-runs
:total-ms (maths/mean (map :total-ms runs))
:s-per-sec (maths/mean (map :s-per-sec runs))}))))
first-run (first runs)]
(merge (dissoc first-run
:s-per-sec
:total-ms)
{:label label
:runs num-runs
:total-ms (maths/mean (map :total-ms runs))
:s-per-sec (maths/mean (map :s-per-sec runs))})))
[;; Default tuning args (including calculated)
{:label "defaults"
:num-runs 10
Expand Down
16 changes: 15 additions & 1 deletion src/bench/com/yetanalytics/xapipe/bench/maths.clj
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
(ns com.yetanalytics.xapipe.bench.maths
(:require [clojure.spec.alpha :as s]
[clojure.spec.gen.alpha :as sgen]
[clojure.set :as cset]))

;; Origninally Cribbed from Avery and Jean
;; https://github.com/clojure-cookbook/clojure-cookbook/blob/master/01_primitive-data/1-20_simple-statistics.asciidoc

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Mean
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defn mean ^Double [coll]
(let [[sum count] (reduce (fn [[s c] x]
[(+ s x) (inc c)])
Expand All @@ -19,6 +22,10 @@
:args (s/cat :coll (s/coll-of number?))
:ret double?)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Median
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defn median ^Double [coll]
(let [sorted (sort coll)
cnt (count sorted)]
Expand All @@ -35,6 +42,10 @@
:args (s/cat :coll (s/coll-of number?))
:ret (s/nilable double?))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Mode
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defn mode [coll]
(if-let [coll (not-empty coll)]
(let [freqs (frequencies coll)
Expand Down Expand Up @@ -64,6 +75,9 @@
(empty? ret)
:else (println coll ret))))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Standard Deviation
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defn stddev ^Double [coll & {:keys [complete-population?]
:or {complete-population? false}}]
Expand Down
7 changes: 3 additions & 4 deletions src/cli/com/yetanalytics/xapipe/cli.clj
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
[com.yetanalytics.xapipe.store.impl.file :as file-store]
[com.yetanalytics.xapipe.store.impl.memory :as mem-store]
[com.yetanalytics.xapipe.store.impl.noop :as noop-store]
[com.yetanalytics.xapipe.store.impl.redis :as redis-store]
[xapi-schema.spec.resources :as xsr])
[com.yetanalytics.xapipe.store.impl.redis :as redis-store])
(:import [java.net URL]))

;; xAPI partial GET params
Expand Down Expand Up @@ -81,8 +80,8 @@
(.getProtocol parsed)
(.getAuthority parsed))
:xapi-prefix (.getPath parsed)})
(catch Exception ex
(throw (ex-info (format "Could not parse LRS URL %s" url))))))
(catch Exception _
(throw (ex-info (format "Could not parse LRS URL %s" url) {})))))

(s/fdef force-stop-job!
:args (s/cat :stop-fn fn?
Expand Down
3 changes: 1 addition & 2 deletions src/cli/com/yetanalytics/xapipe/cli/options.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@
"clojure.tools.cli options for xapipe CLI"
(:require [cheshire.core :as json]
[clojure.spec.alpha :as s]
[clojure.java.io :as io]
[clojure.string :as cs]
[clojure.tools.cli :as cli]
[com.yetanalytics.xapipe :as xapipe]
[com.yetanalytics.xapipe.job.json :as job-json]
[com.yetanalytics.xapipe.filter.path :as fpath]))

(defn option-spec->spec-def
[[short-command long-command desc
[[short-command long-command _description
& {:keys [id
default
parse-fn
Expand Down
3 changes: 2 additions & 1 deletion src/cli/com/yetanalytics/xapipe/main.clj
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ Delete a Job:
(not= ?job-id-arg
(:id ?from-json)))
(throw (ex-info (format "--job-id %s does not match JSON job id %s"
?job-id-arg (:id ?from-json))))))
?job-id-arg (:id ?from-json))
{}))))
?job-id (or ?job-id-arg (:id ?from-json))
?from-storage (and ?job-id
(store/read-job
Expand Down
10 changes: 5 additions & 5 deletions src/cli/com/yetanalytics/xapipe/metrics/impl/prometheus.clj
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@
collectors)]
(reify
metrics/Reporter
(-gauge [this k v]
(-gauge [_ k v]
(pro/set registry k v))
(-counter [this k delta]
(-counter [_ k delta]
(pro/inc registry k delta))
(-histogram [this k v]
(-histogram [_ k v]
(pro/observe registry k v))
(-summary [this k v]
(-summary [_ k v]
(pro/observe registry k v))
(-flush! [this]
(-flush! [_]
(pro-exp/push! registry)))))
1 change: 0 additions & 1 deletion src/lib/com/yetanalytics/xapipe.clj
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
(ns com.yetanalytics.xapipe
(:require [clojure.core.async :as a]
[clojure.java.io :as io]
[clojure.spec.alpha :as s]
[clojure.tools.logging :as log]
[com.yetanalytics.xapipe.client :as client]
Expand Down
1 change: 0 additions & 1 deletion src/lib/com/yetanalytics/xapipe/client.clj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
[com.yetanalytics.xapipe.metrics :as metrics]
[com.yetanalytics.xapipe.util :as u]
[xapi-schema.spec :as xs]
[xapi-schema.spec.resources :as xsr]
[com.yetanalytics.xapipe.util.time :as t]
[com.yetanalytics.xapipe.spec.common :as cspec])
(:import [org.apache.http.impl.client CloseableHttpClient]
Expand Down
3 changes: 1 addition & 2 deletions src/lib/com/yetanalytics/xapipe/client/multipart_mixed.clj
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
[clojure.spec.alpha :as s]
[clojure.spec.gen.alpha :as sgen]
[clojure.string :as cs]
[xapi-schema.spec :as xs]
[xapi-schema.spec.resources :as xsr])
[xapi-schema.spec :as xs])
(:import
[java.io
Writer
Expand Down
5 changes: 0 additions & 5 deletions src/lib/com/yetanalytics/xapipe/filter.clj
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
(ns com.yetanalytics.xapipe.filter
"Apply profile-based filtering to statement streams."
(:require [clojure.spec.alpha :as s]
[clojure.spec.gen.alpha :as sgen]
[xapi-schema.spec :as xs]
[cheshire.core :as json]
[com.yetanalytics.persephone :as per]
[com.yetanalytics.persephone.pattern.fsm :as fsm]
[com.yetanalytics.persephone.pattern.fsm-spec :as fsm-spec]
[com.yetanalytics.persephone.template :as per-template]
[com.yetanalytics.persephone.utils.json :as per-json]
[com.yetanalytics.pan.objects.pattern :as pat]
[com.yetanalytics.pan.objects.profile :as prof]
[com.yetanalytics.pan.objects.template :as template]
Expand Down
4 changes: 1 addition & 3 deletions src/lib/com/yetanalytics/xapipe/filter/concept.clj
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
(ns com.yetanalytics.xapipe.filter.concept
"Functions to apply concept-based filtering to statement streams."
(:require [com.yetanalytics.persephone.template :as pt]
[com.yetanalytics.persephone :as p]
[com.yetanalytics.pan.objects.concepts.verb :as v]
(:require [com.yetanalytics.pan.objects.concepts.verb :as v]
[com.yetanalytics.pan.objects.concepts.activity-type :as at]
[com.yetanalytics.pan.objects.template :as t]
[com.yetanalytics.pan.objects.concepts.attachment-usage-type :as aut]
Expand Down
4 changes: 1 addition & 3 deletions src/lib/com/yetanalytics/xapipe/job.clj
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
[clojure.spec.gen.alpha :as sgen]
[com.yetanalytics.xapipe.job.config :as config]
[com.yetanalytics.xapipe.job.state :as state]
[com.yetanalytics.xapipe.job.state.errors :as errors]
[com.yetanalytics.xapipe.util.time :as t]
[xapi-schema.spec :as xs]))
[com.yetanalytics.xapipe.util.time :as t]))

(def current-version 0)

Expand Down
3 changes: 1 addition & 2 deletions src/lib/com/yetanalytics/xapipe/job/json.clj
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
[clojure.spec.gen.alpha :as sgen]
[cognitect.transit :as transit]
[com.yetanalytics.xapipe.job :as job]
[com.yetanalytics.xapipe.job.config :as config]
[xapi-schema.spec :as xs])
[com.yetanalytics.xapipe.job.config :as config])
(:import [java.io ByteArrayInputStream ByteArrayOutputStream File]))

(s/fdef write-transit-str
Expand Down
4 changes: 1 addition & 3 deletions src/lib/com/yetanalytics/xapipe/job/state.clj
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
(ns com.yetanalytics.xapipe.job.state
(:require [clojure.spec.alpha :as s]
[clojure.spec.gen.alpha :as sgen]
[com.yetanalytics.xapipe.filter :as filt]
[com.yetanalytics.xapipe.job.state.errors :as errors]
[com.yetanalytics.xapipe.util.time :as t]
[xapi-schema.spec :as xs]))
[com.yetanalytics.xapipe.util.time :as t]))

;; Error vectors are stored at 3 levels for the source,
;; target, and entire job.
Expand Down
3 changes: 1 addition & 2 deletions src/lib/com/yetanalytics/xapipe/job/state/errors.clj
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
(ns com.yetanalytics.xapipe.job.state.errors
(:require [clojure.spec.alpha :as s]
[xapi-schema.spec :as xs]))
(:require [clojure.spec.alpha :as s]))

(s/def ::message string?)
(s/def ::type #{:job :source :target})
Expand Down
1 change: 0 additions & 1 deletion src/lib/com/yetanalytics/xapipe/xapi.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
(:require [clojure.spec.alpha :as s]
[clojure.spec.gen.alpha :as sgen]
[clojure.tools.logging :as log]
[com.yetanalytics.xapipe.client :as client]
[com.yetanalytics.xapipe.client.multipart-mixed :as multipart]
[xapi-schema.spec :as xs]))

Expand Down