Changed tutorial to run without a cogserver #16
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Although the tutorial is running without cogserver there are a couple of points to remark
(1) Although this tutorial is running using ECAN-based rules and ECAN-based GHOST API, ECAN dynamics itself are disabled. I could not figure out how to ensure the STI of rules so that GHOST can properly match the rules. Even when I run it using a cogserver (and starting all ECAN agents) OpenPSI could not properly match my rules.
This is a potential problem... or not. I don't know. My strong opinion is that this tutorial should not enter in details regarding ECAN and attention dynamics. I think it should focus in how to write rules and make them match in a proper/sensible way.
(2) To run the tutorial, 2 files in the Docker container need to be modified:
/usr/local/share/opencog/scm/opencog/openpsi/main.scm
line # 14: (cog-logger-set-level! opl "info")
line # 132: (usleep 10000000)
/usr/local/share/opencog/scm/opencog/ghost/matcher.scm
line # 283: (rule-selected (eval-and-select candidate-rules #t)))
I don't know what's the proper way to do that so I left it to someone else. I've see that the scm files in /usr/local/share/opencog/scm/opencog/ (in the Docker container) differ from the ones in the opencog repo (the repo used inside the same container).
The change in matcher.scm allows the tutorial to run without ECAN dynamics. The changes in main.scm are a hack to work around the problem I've reported regarding the crash of the Jupyter Notebook after some PSI cycles.
The usleep is the delay between two PSI cycles. The amount I suggested is equivalent to 10s. It's too much, I know, but with this delay the aforementioned crash happens only with a very low probability.
1s is enough to have a good user experience but the crash will probably happen in less then 1 minute after calling (ghost-run).
(3) I've tried to track the crash. It happens in ZMQ while Jupyter Notebook is trying to ACCEPT in the socket with the user interface. It seems like the socket suddenly become unavailable. The behavior is really odd because:
a) It is surely related to OpenPSI or GHOST. Changing the sleeping time also changes the probability of the crash. If sleeping time is set too high it never crashes.
b) unless the logger is misguiding my judgement (by not delivering debug messages timely), the PSI thread in charge of running GHOST is always sleeping when the crash happens.
c) The crash happens only in the Notebook. Never in a standalone guile session. Actually, the crash happens in the SCM file called when the Notebook is setup (i.e. in the SCM kernel: simple-zmq.scm).