Skip to content
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

[RuntimeError] Can't get the atomspace that guile is using. python3 bot #3656

Open
aivanouski opened this issue Aug 18, 2020 · 7 comments
Open
Labels

Comments

@aivanouski
Copy link

atomspace = scheme_eval_as('(cog-atomspace)')

RuntimeError: Python-Scheme Wrapper: Null atomspace for '(cog-atomspace)'

https://github.com/opencog/atomspace/blob/f8bb895982bc1fdc3f95bd17cf3b8d1deec3d9ab/opencog/cython/opencog/PyScheme.cc#L129

all Prerequisites from https://github.com/opencog/opencog installed

  1. Running the parse server.
  2. Running the opencog server.
@linas linas added the python label Aug 18, 2020
@linas
Copy link
Member

linas commented Aug 18, 2020

My first guess is that the python bindings are broken, again. Both @noskill and @vsbogd use python regularly, maybe they know ...

@noskill
Copy link
Contributor

noskill commented Aug 21, 2020

it works:

python_atomspace = AtomSpace()
scheme_eval(python_atomspace, "(use-modules (opencog) (opencog exec))")
atomspace = scheme_eval_as('(cog-atomspace)')

@aivanouski
Copy link
Author

it works:

python_atomspace = AtomSpace()
scheme_eval(python_atomspace, "(use-modules (opencog) (opencog exec))")
atomspace = scheme_eval_as('(cog-atomspace)')

Thank you! It works.
But happened new error:
In procedure module-lookup: Unbound variable: cog-extract-recursive

Ok, we got message Help
2020-08-21 15:04:33,944 - telegram.ext.dispatcher - ERROR - An error was raised while processing the update and an uncaught error was raised while handling the error with an error_handler
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/telegram/ext/dispatcher.py", line 340, in process_update
    handler.handle_update(update, self, check, context)
  File "/usr/local/lib/python3.6/dist-packages/telegram/ext/handler.py", line 122, in handle_update
    return self.callback(dispatcher.bot, update, **optional_args)
  File "../opencog/nlp/chatbot/telegram_bot.py", line 52, in echo
    reply = scheme_eval(atomspace, '(process-query "{}" "{}")'.format(update.message.from_user.first_name, update.message.text))
  File "scheme.pyx", line 44, in opencog.scheme.scheme_eval
RuntimeError: Python-Scheme Wrapper: Failed to execute '(process-query "Andrei" "Help")'

Backtrace:
          11 (apply-smob/1 #<catch-closure 1c73220>)
          10 (apply-smob/1 #<catch-closure 1c73120>)
In ice-9/boot-9.scm:
   2312:4  9 (save-module-excursion #<procedure 1c77c20 at ice-9/eva…>)
In ice-9/eval-string.scm:
     38:6  8 (read-and-eval #<input: string 1d8e5b0> #:lang _)
In ice-9/boot-9.scm:
    841:4  7 (with-throw-handler _ _ _)
In opencog/nlp/chatbot/bot-api.scm:
    39:35  6 (_)
In opencog/nlp/chatbot/chat-utils.scm:
    182:8  5 (nlp-parse "Help")
In srfi/srfi-1.scm:
    640:9  4 (for-each #<procedure 7f0d43957868 at opencog/nlp/proc…> …)
In opencog/nlp/processing-utils.scm:
    57:18  3 (_ _)
In ice-9/boot-9.scm:
   751:25  2 (dispatch-exception 0 unbound-variable ("module-look…" …))
In opencog/nlp/chatbot/bot-api.scm:
    83:12  1 (_ . _)
In unknown file:
           0 (backtrace #<undefined>)

Sorry, I caught an exception
Backtrace:
          11 (apply-smob/1 #<catch-closure 1c73220>)
          10 (apply-smob/1 #<catch-closure 1c73120>)
In ice-9/boot-9.scm:
   2312:4  9 (save-module-excursion #<procedure 1c77c20 at ice-9/eva…>)
In ice-9/eval-string.scm:
     38:6  8 (read-and-eval #<input: string 1d8e5b0> #:lang _)
In ice-9/boot-9.scm:
    841:4  7 (with-throw-handler _ _ _)
In opencog/nlp/chatbot/bot-api.scm:
    39:35  6 (_)
In opencog/nlp/chatbot/chat-utils.scm:
    182:8  5 (nlp-parse "Help")
In srfi/srfi-1.scm:
    640:9  4 (for-each #<procedure 7f0d43957868 at opencog/nlp/proc…> …)
In opencog/nlp/processing-utils.scm:
    57:18  3 (_ _)
In ice-9/boot-9.scm:
   752:25  2 (dispatch-exception _ _ _)
   751:25  1 (dispatch-exception 1 unbound-variable ("module-look…" …))
In unknown file:
           0 (apply-smob/1 #<catch-closure 1c730e0> unbound-variable …)

ERROR: In procedure apply-smob/1:
In procedure module-lookup: Unbound variable: cog-extract-recursive
ABORT: unbound-variable
 (/home/ubuntu/home/atomspace/opencog/cython/opencog/PyScheme.cc:63)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/telegram/ext/dispatcher.py", line 353, in process_update
    self.dispatch_error(update, e)
  File "/usr/local/lib/python3.6/dist-packages/telegram/ext/dispatcher.py", line 524, in dispatch_error
    callback(self.bot, update, error)
TypeError: error() takes 2 positional arguments but 3 were given

@linas
Copy link
Member

linas commented Aug 22, 2020

Try cog-extract-recursive! with the exclamation mark at the end. I think it's needed. There is a backward-compatibility layer, without the exclamation mark, but perhaps it is not being loaded for some opaque reason. I will submit a pull request shortly.

Also, could someone please submit a pull req to patch up the telegram-bot?

linas added a commit to linas/opencog that referenced this issue Aug 22, 2020
There's a backwards-compat function that should have made it work,
but according to bug opencog#3656 it appears to fail. So fix by brute force.
@aivanouski
Copy link
Author

I have fixed it by adding next config in python script:
scheme_eval(atomspace, '(primitive-load "/home/ubuntu/home/atomspace/opencog/scm/opencog.scm")')

@aivanouski
Copy link
Author

After next dialog:

  • Tom eats apples.
  • Hello Andrei, you said: "Tom eats apples."
    You made a Declarative SpeechAct
  • What does Tome eat?

It catch exception, In unknown file:
3 (opencog-extension cached-sureal-match (#))


RuntimeError: Python-Scheme Wrapper: Failed to execute '(process-query "Andrei" "What does Tome eat?")'
Hello Andrei, you said: "What does Tome eat?"
You made an Interrogative SpeechAct

Backtrace:
          19 (apply-smob/1 #<catch-closure 17893c0>)
          18 (apply-smob/1 #<catch-closure 17892c0>)
In ice-9/boot-9.scm:
   2312:4 17 (save-module-excursion #<procedure 178d860 at ice-9/eva…>)
In ice-9/eval-string.scm:
     38:6 16 (read-and-eval #<input: string 1489d90> #:lang _)
In ice-9/boot-9.scm:
    841:4 15 (with-throw-handler _ _ _)
In opencog/nlp/chatbot/bot-api.scm:
    19:17 14 (wh_query_process _)
In opencog/nlp/fuzzy.scm:
   191:48 13 (get-fuzzy-answers _ #:do-microplanning _)
In srfi/srfi-1.scm:
   679:15 12 (append-map _ _ . _)
   592:17 11 (map1 (#))
In opencog/nlp/fuzzy.scm:
    74:27 10 (_ _)
In opencog/nlp/microplanning/main.scm:
   123:23  9 (microplanning-main # "declarative" #<<chunks-option> …> …)
    214:8  8 (make-sentence-chunks _ _ _)
In srfi/srfi-1.scm:
    640:9  7 (for-each #<procedure sub-helper (ut)> ("declarative"))
In opencog/nlp/microplanning/main.scm:
   158:32  6 (sub-helper "declarative")
   285:32  5 (make-sentence _ _ "declarative" #<<chunks-option> 1585…>)
   539:36  4 (check-chunk _ "declarative" _)
In unknown file:
           3 (opencog-extension cached-sureal-match (#))
In ice-9/boot-9.scm:
   751:25  2 (dispatch-exception 0 C++-EXCEPTION ("cached-sureal-…" …))
In opencog/nlp/chatbot/bot-api.scm:
    83:12  1 (_ . _)
In unknown file:
           0 (backtrace #<undefined>)

Sorry, I caught an exception
Backtrace:
          19 (apply-smob/1 #<catch-closure 17893c0>)
          18 (apply-smob/1 #<catch-closure 17892c0>)
In ice-9/boot-9.scm:
   2312:4 17 (save-module-excursion _)
In ice-9/eval-string.scm:
     38:6 16 (read-and-eval #<input: string 1489d90> #:lang _)
In ice-9/boot-9.scm:
    841:4 15 (with-throw-handler _ _ _)
In opencog/nlp/chatbot/bot-api.scm:
    19:17 14 (wh_query_process _)
In opencog/nlp/fuzzy.scm:
   191:48 13 (get-fuzzy-answers _ #:do-microplanning _)

Adding next config to script, doesn't help:

scheme_eval(atomspace, '(primitive-load "/home/ubuntu/home/opencog/opencog/nlp/sureal/surface-realization.scm")')

@linas
Copy link
Member

linas commented Aug 24, 2020

  1. you wrote "What does Tome eat?" - try again without the "e"
  2. the chatbot was very incomplete: if you look at bot-api.scm, it doesn't do much.
  3. the code that is crashing, somewhere in sureal, is also unmaintained.

Are you good at programming? You might try to find what it is in sureal that is throwing an exception ...

linas added a commit that referenced this issue Aug 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants