Skip to content

Fix exception in explain-activation #346

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

dgoeke
Copy link

@dgoeke dgoeke commented Oct 5, 2017

Previously, when iterating over a list of matches, each match
was assumed to be a vector of [fact condition] but was actually
a map of {:fact ... :condition ...}. Destructuring the map into
a vector threw an UnsupportedOperationException.

@dgoeke dgoeke force-pushed the dg/fix-explain-activations branch from d01e761 to bbabe3e Compare October 5, 2017 19:42
@WilliamParker
Copy link
Collaborator

The changes basically look correct to me; looks like I broke this in #276. Thanks for submitting a PR for this.

  • There aren't any tests of explain-activations, even just that it returns without failing, so whether as part of this PR or not we should add something. A test could be as basic as validating the explanations for something like
(defrule cold-temp
     [?t <- Temperature (< 0 temperature)
     =>
    (insert (->LousyWeather))

have "< 0 temperature" in the string somewhere using a regex. Unfortunately testing against strings is messy (which is why we tested against the underlying inspection API instead) but even a very simple test could help prevent errors like this in the future. Clojure's with-out-str would allow such a test to capture the output.

  • Adding a 0.17.0 entry to the changelog implies to me that we've released 0.17.0. Usually we've just added the changelog entries when we actually cut a release, but I can see some advantages to adding changelog entries as we go along for visibility to the community. Perhaps we should have an "In master, not released" entry at the top whose content we transfer when a release is cut. Thoughts, anyone?
  • @rbrush: You set up the initial contributors page; is there a standard template for Cerner-sponsored open source projects that you copied that from? Should we have some sort of additional entries besides the "Cerner Corporation" heading? @dgoeke : To be clear, contributions from the larger community are most welcome and something we encourage but (at least as far as I know) you've never worked for Cerner and the "Cerner Corporation" heading with bullet points underneath it seems to imply otherwise to me.

FYI I'll be otherwise occupied next week so I may not reply to anything here until the week after that. I can help with the testing on this then if desired.

@dgoeke
Copy link
Author

dgoeke commented Oct 6, 2017

RE: Changelog/contributors -- I was trying to follow the CONTRIBUTING.md guidelines and existing patterns there. I'm happy to remove either or both; my only interest here is having the function not crash.

@dgoeke
Copy link
Author

dgoeke commented Oct 6, 2017

The logic around ensuring the data underlying explanations is correct is already tested elsewhere, so I've added a simple test that the function doesn't crash. This may need to be expanded, but it's a start and will ensure this specific issue doesn't regress.

@WilliamParker
Copy link
Collaborator

@dgoeke please squash your commits together; we prefer to have each commit in the history reflect a distinct logical change to Clara rather than a step in development. Otherwise I'm OK with merging this. I'll leave it open for now in case anyone else wants to look at this, but I'll plan to merge this in the week after next when I'm back and don't object if someone else merges it before then.

@rbrush
Copy link
Contributor

rbrush commented Oct 6, 2017

Looks good to me, modulo the squash that Will mentioned. Thanks for fixing and contributing this to the project!

Previously, when iterating over a list of matches, each match
was assumed to be a vector of `[fact condition]` but was actually
a map of `{:fact ... :condition ...}`. Destructuring the map into
a vector threw an UnsupportedOperationException.
@dgoeke dgoeke force-pushed the dg/fix-explain-activations branch from 92da8d9 to a77515c Compare October 10, 2017 19:42
@dgoeke
Copy link
Author

dgoeke commented Oct 10, 2017

Updated with a squashed commit. I'm accustomed to just using the github "squash and merge" feature on PRs.

@WilliamParker
Copy link
Collaborator

Merged. I logged #350 for future improvements to the tests of explain-activations. Thanks for the PR @dgoeke.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants