This project uses grpc for executing pattern matching searches on a remote AtomSpace.
It also allows users to create multiple atomspaces and access them separately. Users can use a JSON config file to specify the id and the directory containing the atomese code to load. An example config looks like the following:
[
{
"id": "asp1",
"pathDir": "/path/to/atomese/code/"
},
{
"id": "asp2",
"pathDir": "/path/to/another/atomese/code"
}
]
You can use the above JSON to start the server:
$ atom_server --config /path/to/setting.json
By default the server runs at localhost:50051
. But you can that using the --host
and --port
arguments.
- Create a file named
config.json
inside the root directory that contains where the atomese data to be loaded is contained. A sample file looks like the following.
{
"id": "prod-atom",
"pathDir": "/data"
}
- Build the docker image by running
docker build -t atom_server .
- Start the server. By default the server starts on port 8005. If you want to use another port change the
--network host
option to-p <port-you-want-to-use>:8005
docker run --network host -v <path/to/atomese/files>:/data atom_server
This project depends on the following libraries:
- AtomSpace
- Boost
- On Debian you can use
apt-get install libboost-dev
- On Debian you can use
- Protobuff
- gRPC C++
-
See also here - https://grpc.io/docs/languages/cpp/quickstart/
-
Note: While building gRPC from the source, make sure to have the following cmake options. For more info check out this issue comment from the library maintainers.
cmake -DgRPC_INSTALL=ON -DgRPC_BUILD_TESTS=OFF -DgRPC_PROTOBUF_PROVIDER=package -DgRPC_ZLIB_PROVIDER=package -DgRPC_CARES_PROVIDER=package -DgRPC_SSL_PROVIDER=package -DCMAKE_BUILD_TYPE=Release ..
-
- nlohmann_json
-
Since nlohmann json is a header only library just copy json.hpp to
/usr/local/include/nlohmann
directory. Create the nlohmann sub directory if it doesn't exist. Run the following command:$ mkdir -p /usr/local/include/nlohmann && \ wget -O /usr/local/include/nlohmann/json.hpp https://github.com/nlohmann/json/releases/download/v3.9.1/json.hpp
-
- agi-bio - this is OPTIONAL and will be required if you are working with bio related atomspace
Guile is also must be installed to use the scheme bindings
$ cd atomspace_server
$ mkdir build && cd build
$ cmake ..
$ make
$ make install
Once you have started the atom_server
, run Guile REPL and execute the following commands:
A. To execute a pattern matching query
scheme@(guile-user)> (use-modules (opencog grpc))
scheme@(guile-user)> (exec-pattern "prod-atom" (Get (Member (Gene "IGF1") (Variable "$pway"))))
In the above example, prod-atom
is the id of the atomspace you want the pattern to be searched in.
B. Check if a node exists
scheme@(guile-user)> (check-node "prod-atom" 'Concept "A")
In the above example, we are checking if (Concept A)
exists in remote atomspace prod-atom
C. Find Nodes with similar name
scheme@(guile-user)> (find-similar-node "prod-atom" 'Concept "ca")
The above query will return nodes that have ca
in their name, such as (Concept "car")
, (Concept "cat")
..etc
. The result is limited to return at most 10 atoms.