Preloading atomspace with initial data

49 views
Skip to first unread message

Eyob

unread,
Feb 16, 2018, 8:55:13 AM2/16/18
to opencog
Is it possible to have initial group of atoms to exist by default in the atomspace?

This seems to be a critical requirement in the following setting.

I have a python code that uses something like

from opencog.scheme_wrapper import load_scm, scheme_eval_h

atomspace = AtomSpace()

load_scm(atomspace,"{}/output2.scm".format(os.getcwd()))

Bascially the problem is it takes forever to load atoms in the file output2.scm from within python while using "load_scm", while it takes few seconds to do it in guile.

So, if initial atoms that are in output2.scm could have been loaded initially somehow by default, then doing  "atomspace=Atomspace( )" would load the initial set of atoms the app needs automatically,
which would help avoid using load_scm with output2.scm.

Thanks.

Michael Duncan

unread,
Feb 16, 2018, 9:42:33 AM2/16/18
to opencog
it's a hack but you could put (load "output2.scm") in your ~/.guile file or some other guile config file so it would automatically load when guile is invoked.  or the guile -l flag will run an arbitrary scheme file...

Linas Vepstas

unread,
Feb 16, 2018, 1:09:56 PM2/16/18
to opencog
I don't understand the question. What do you mean "takes forever"?
Are you compiling the file? By default, when you load an scm file,
the guile compiler runs. This can take a very long time, if the file
is large. It is also a complete waste of time, if the file contains
only atoms and nothing else. It would be best to just disable
compilation -- i.e. use primitive-load instead of load

https://www.gnu.org/software/guile/manual/html_node/Loading.html

viz do not use load_scm(), it is probably mis-handling the compilation step.

The other alternative is to dump your atoms into an sql db and use
that, however, this is a bit more complex if you are not regularly
working with big data.

--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 post to this group, send email to ope...@googlegroups.com.
> Visit this group at https://groups.google.com/group/opencog.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/opencog/021a499b-efbd-47c9-8c88-422cca23fab4%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.



--
cassette tapes - analog TV - film cameras - you
Message has been deleted

Eyob

unread,
Feb 16, 2018, 4:30:35 PM2/16/18
to opencog
Linas: Yes primitive-load might be the life saver here. I will try it out. Thanks :)

Mike: Since I am running code from python, the things I put in .guile won't be accessed by the python code.

Eyob

unread,
Feb 21, 2018, 3:35:38 AM2/21/18
to opencog
Yeah, primitive-load worked as tested by one of our team members. Loads in secs. Thanks!!!
Reply all
Reply to author
Forward
0 new messages