Fork me on GitHub
#clara
<
2018-01-31
>
tcarls02:01:21

I'm seeing rules no longer firing after I reloaded the namespace that contains them in the REPL, even if I create an entirely new session with (mk-session :cache false). What am I missing?

dadair04:01:28

@tcarls might need a code example, numerous things could be happening, depending on the state of the namespace

tcarls16:01:55

@dadair, in hindsight, I'm pretty sure what's happening is caused by new defrecords being run, but trying to run rules against data from an atom that includes (expensive-to-calculate) cached previous instances of input data. Going to move the definitions into their own namespace; I expect that'll help.

mikerod16:01:53

@tcarls that is common

mikerod16:01:33

The potemkin lib had some extensions to defrecord and other related macros to avoid that sort of redefinition of classes to help with reloading workflows in the REPL

mikerod16:01:54

I think one workaround people do for Clara has been to do defrecord in a separate ns that you don’t plan to reload much

mikerod16:01:08

So the rules don’t get mismatched definitions of the “same class”

tcarls22:01:10

One thing that's surprising me in using Clara is how one needs to take explicit steps to avoid getting two equal records created if arriving at the same fact via two different rules.

mikerod22:01:38

@tcarls yeah, there are pro’s and con’s to that

mikerod22:01:53

There are definitely use-cases where “cardinality” matters

mikerod22:01:16

I’ve had quite a few of those before. So if you “removed the duplicates” you’d fail to meet the needs of someone who wanted to count things

mikerod22:01:23

For whatever purpose

mikerod22:01:01

In Drools (popular Java-based rules engine), they went with “logical inserts” never are duplicated, but “unconditional inserts” are duplicated if they are not identical?

mikerod22:01:15

It was nice, when you really just didn’t want duplicates, but difficult to work with when you did

mikerod22:01:34

In Clara, if you need some “single count” fact in the end, you can just use an aggregation sort of rule

mikerod22:01:37

I do think it could be interesting if Clara had an options where it made working memory “set-like” and duplicates didn’t show up. There are definitely costs to doing this though.

tcarls23:01:37

headscratch

tcarls23:01:10

{:lhs [{:type pdfsort.types.Warning, :constraints [], :fact-binding :?warning}], :params #{}, :name "pdfsort.core/get-warnings"} is invalid or not included in the rule base.
...seems to be happening consistently for me right now when invoking code from lein run, but not when invoking the same functions from Emacs/Cider.

dadair23:01:18

@tcarls where is the mk-session you’re using (e.g., same ns as the rule? other ns?), and what does the function call look like?

dadair23:01:42

and can you post a snippet of the rule?