clara

http://www.clara-rules.org/
bartuka 2020-01-08T14:58:50.070Z

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

ethanc 2020-01-08T16:17:30.070800Z

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

bartuka 2020-01-08T16:37:53.071Z

ok, thanks!

2020-01-08T16:40:31.072Z

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

2020-01-08T16:40:47.072500Z

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

bartuka 2020-01-08T16:42:01.072800Z

exactly, just to avoid typing too much

2020-01-08T16:51:05.075900Z

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

2020-01-08T16:51:43.076900Z

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

bartuka 2020-01-08T16:52:01.077600Z

uhmmm... interesting...

2020-01-08T16:52:13.078100Z

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.

2020-01-08T16:52:33.078600Z

With ns-unmap I believe.

bartuka 2020-01-08T16:53:31.079600Z

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

bartuka 2020-01-08T16:54:01.080400Z

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

bartuka 2020-01-08T16:55:11.081100Z

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

2020-01-08T17:32:38.082900Z

@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.

bartuka 2020-01-10T11:25:32.095Z

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
                                      'clara.rules.compiler/testing->exclude
                                      :blacklist ['clara.rules.compiler/testing->exclude]))

bartuka 2020-01-10T11:38:11.095200Z

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?

bartuka 2020-01-10T13:06:55.095500Z

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[<http://java.io|java.io>.File 0x1085a882 "src/test/common/clara/test_common.cljc"]}