Fork me on GitHub

is it possible to remove a rule from a session before firing it? I say that because I have a namespace with 10 rules and I want to run 9 of them. I would prefer to insert all the namespace and remove the single one


@iagwanderson, Currently there is no way to add/remove rules from the rulebase after the session has been created


@iagwanderson as I think you already know you can pass a collection of rules to make a session too.


However it’s more of a “white list”. And you seem to want a “black list”


exactly, just to avoid typing too much


You can list rule names in a vector in a var as well with :production-seq metadata. But still doesn’t help you. You can do dynamic stuff to make session to if you use the clara.rules.compiler/mk-session* which is a fn instead of macro


Doing that you could do some manual dynamic stuff with clj ns-publics where you removed the rules you didn’t want.


uhmmm... interesting...


Or depending on what you’re doing. You could comment out your rule you don’t want and reload ensuring the ns has the old var removed. Hah.


With ns-unmap I believe.


hah.. this option is not possible here 😕 but I will try the dynamic one later. This is more a convenience than a requirement right now


do you think this functionality would be welcome to clara.core? I can try to implement it as a side project here


I'm making a real investment in this library in my project, so I wish to learn the internals better some time 😃


@iagwanderson it seems reasonable to think there could be support for ignoring certain rules. mk-session supports options so it could be added there perhaps. Or maybe rules could just be marked with metadata when wanting something like this.


I was thinking in this API:

(defrecord Values [id])

  (defrule testing->include
    [?value <- Values [v] (= ?id (:id v))]
    (println "INCLUDING!!! " ?value))

  (defrule testing->exclude
    [?value <- Values [v] (= ?id (:id v))]
    (println "EXCLUDING!!! " ?value))

  (def session-without (rl/mk-session 'clara.rules.compiler/testing->include
                                      :blacklist ['clara.rules.compiler/testing->exclude]))


I already have a working solution to this problem. I am touching only the clara.rules.compiler/mk-session function. There are many tests namespaces in the project. I was thinking to add a new one with tests to this specific functionality, what you suggests?


Weird, when I add a new test file to the common folder I get this error from lein test command.

clojure.lang.ExceptionInfo: failed compiling file:src/test/common/clara/test_common.cljc {:file #object[.File 0x1085a882 "src/test/common/clara/test_common.cljc"]}