mimic.core
add!
(add! session states)
Adds states to a given session.
session
- the id of the session to append to. Note:
session
can be dropped within a with-session block. states
- a sequential list of states to add to the model.
end
(end session)
Ends a training session
session
- the id of the session to close.
fetch
(fetch model)
(fetch model start)
Fetches the state following the provided state.
model
- the key of the model to fetch against.
start
Optional- the starting point to match state against.
start
(start model-keys)
Begins a training session and returns a unique session id.
model-keys
- a list of the models to incorporate the new data.
store
dynamic
stream
(stream model)
(stream model overrides)
Builds a generated session stream. Allows for skewing results by passing in an optional list of states to select if encountered.
model
- the key of the model to fetch against.
overrides
Optional- a list of states to select if encountered.
with-session
macro
(with-session model-keys & forms)
Evaluates expressions one at a time within a session context. The session id is passed as the first as the first argument to each expression.
model-keys
- a list of the models to incorporate the new data.
forms
- a list of functions to call within the session. Each function has the session id passed into it as the first argument.
Example:
(require '[mimic.core :as mimic :refer [with-session add! stream]])
(with-session [:example]
(add! ['using' 'a' 'redis' 'store']))
(stream :example)) ;; => 'using a redis store'
with-store
macro
(with-store new-store & body)
Allows the customization of the backend to use for mimic storage. If with-store
isn’t used then mimic will default to using an in-memory storage backend.
new-store
- the mimic backend to use for storage.
body
- a list of expressions to be completed within the scope of the store.
Example:
(require '[mimic.core :as mimic :refer [with-session add! stream]])
;; see Carmine for the Redis backend options
(def store (redis/init {:pool {} :spec {:uri 'redis://localhost:6379'}}))
(defmacro mimic* [& body] `(mimic/with-store store ~@body))
(mimic* (with-session [:example]
(add! ['using' 'a' 'redis' 'store']))
(stream :example)) ;; => 'using a redis store'