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'),
```
You can look at examples at:
https://github.com/opencog/atomspace/blob/master/examples/python/ground/ground.py
Best regards,
Vitaly
On Tuesday, January 21, 2020 at 1:37:54 AM UTC+3, Alexander Gabriel wrote:
>
> 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 :)
>
> Am Montag, 20. Januar 2020 22:28:49 UTC schrieb linas:
>>
>> 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.)
>>
>> On Mon, Jan 20, 2020 at 4:18 PM Alexander Gabriel <[email protected]> wrote:
>>
>>> 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.
>>>
>>>
>>> Am Montag, 20. Januar 2020 22:07:04 UTC schrieb linas:
>>>>
>>>> It goes here:
>>>>
>>>>
>>>> https://github.com/opencog/atomspace/blob/873431bdae3b3f44ed26c47993fee8b2979d7cf9/opencog/atoms/execution/ExecutionOutputLink.cc#L202-L211
>>>>
>>>> and then into here
>>>>
>>>>
>>>> https://github.com/opencog/atomspace/blob/873431bdae3b3f44ed26c47993fee8b2979d7cf9/opencog/cython/PythonEval.cc#L995
>>>>
>>>> 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
>>>>
>>>> On Mon, Jan 20, 2020 at 3:03 PM Alexander Gabriel <[email protected]>
>>>> wrote:
>>>>
>>>>> 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
>>>>>
>>>>> --
>>>>> 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 [email protected].
>>>>> To view this discussion on the web visit
>>>>> https://groups.google.com/d/msgid/opencog/8078db0b-aee3-4d57-8319-50e76ad60003%40googlegroups.com
>>>>>
>>>>> <https://groups.google.com/d/msgid/opencog/8078db0b-aee3-4d57-8319-50e76ad60003%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>> .
>>>>>
>>>>
>>>>
>>>> --
>>>> cassette tapes - analog TV - film cameras - you
>>>>
>>> --
>>> 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 [email protected].
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/opencog/dd68bda3-746f-4206-a740-ba39f0f4058c%40googlegroups.com
>>>
>>> <https://groups.google.com/d/msgid/opencog/dd68bda3-746f-4206-a740-ba39f0f4058c%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>
>>
>> --
>> cassette tapes - analog TV - film cameras - you
>>
>
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/opencog/ef15537d-9b32-48a0-9f64-ff06f616a565%40googlegroups.com.