I guess my reasoning rule can't find the defined python function

15 views
Skip to first unread message

Alexander Gabriel

unread,
Jan 20, 2020, 4:03:36 PM1/20/20
to opencog
Hiya,

with your help I got most of my reasoning running in a test setting, running it under my ROS node though, fails due to the python function (which calculates truth values) not being called.

Does anyone have a clue how the code searches for the function name when we call it like so:
        deduction_rule = BindLink(
            VariableList(
                TypedVariableLink(
                    VariableNode('$A'),
                    TypeNode('ConceptNode')),
                TypedVariableLink(
                    VariableNode('$B'),
                    TypeNode('ConceptNode')),
                TypedVariableLink(
                    VariableNode('$C'),
                    TypeNode('ConceptNode'))),
            AndLink(
                ImplicationLink(
                    VariableNode('$A'),
                    VariableNode('$B')),
                ImplicationLink(
                    VariableNode('$B'),
                    VariableNode('$C')),
                NotLink(
                    EqualLink(
                        VariableNode('$A'),
                        VariableNode('$C')))),
            ExecutionOutputLink(
                GroundedSchemaNode('py: deduction_formula'),
                ListLink(
                    ImplicationLink(
                        VariableNode('$A'),
                        VariableNode('$C')),
                    ImplicationLink(
                        VariableNode('$A'),
                        VariableNode('$B')),
                    ImplicationLink(
                        VariableNode('$B'),
                        VariableNode('$C')))))

I tried to define the deduction formula as the member of the same class in which this happens, as a standalone function at the toplevel of the file as well as an import from another module, none of which was successful.

Best,
Alex

Linas Vepstas

unread,
Jan 20, 2020, 5:07:04 PM1/20/20
to opencog
It goes here:


and then into here


and dives into cython code.   But really, all this should work quite well, its tested in assorted unit tests ... so the root cause is ... well I don't know where. Since you're having trouble with this, the fix might be better error detection, better error logging .. finding the problem should not require a dive into the bowels of teh code.   Triple-check your error logs ...

--linas

--
You received this message because you are subscribed to the Google Groups "opencog" group.
To unsubscribe from this group and stop receiving emails from it, send an email to opencog+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/opencog/8078db0b-aee3-4d57-8319-50e76ad60003%40googlegroups.com.


--
cassette tapes - analog TV - film cameras - you

Alexander Gabriel

unread,
Jan 20, 2020, 5:18:30 PM1/20/20
to opencog
Thanks!

what I found out is: the function needs to be defined in the python file that is actually run, not any of those that are imported, even if all the rest of the interaction happens in imported modules and files.
To unsubscribe from this group and stop receiving emails from it, send an email to ope...@googlegroups.com.

Linas Vepstas

unread,
Jan 20, 2020, 5:28:49 PM1/20/20
to opencog, Vitaly Bogdanov
Well, OK, I'm not sure if that's a bug or not, and at any rate, there should be some error message that would make this clear for the next person.  Anatoly, Vitaly, opinions?  Can you fix this so that this kind of user-error is easier to track down?

--linas

(I can't cc Anatoly, can't find his email.)

To unsubscribe from this group and stop receiving emails from it, send an email to opencog+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/opencog/dd68bda3-746f-4206-a740-ba39f0f4058c%40googlegroups.com.

Alexander Gabriel

unread,
Jan 20, 2020, 5:37:54 PM1/20/20
to opencog
There was an error in the log saying that the function couldn't be found 
[2020-01-20 17:45:13:345] [ERROR] Python function 'deduction_formula' not found in module '__main__'! (/home/rasberry/git/atomspace/opencog/cython/PythonEval.cc:1003)

that was a helpful hint

(I had stopped looking at it as most of the earlier problems didn't result in log entries)

Thanks again :)

Vitaly Bogdanov

unread,
Jan 20, 2020, 10:35:54 PM1/20/20
to opencog
The simplest way to workaround this is using something like this:
```
__main__.deduction_formula = deduction_formula
```
deduction_formula should be imported before.

The more accurate way is using name of the module as a prefix in GroundedSchemaNode name. To do this your function should be a member of the some Python module:
```
GroundedSchemaNode('py: mymodule.deduction_formula'),
```

Best regards,
Vitaly
Reply all
Reply to author
Forward
0 new messages