Habush / atomspace-rpc

A gRPC server and client to execute pattern matching queries
GNU Affero General Public License v3.0
2 stars 1 forks source link
atomspace grpc opencog

atomspace-rpc

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.

Building and Installation.

A. Docker based Setup (Recommended)

  1. 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"
    }
  1. Build the docker image by running
  docker build -t atom_server .
  1. 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

B. Local Setup

1. Requirements:

This project depends on the following libraries:

Guile is also must be installed to use the scheme bindings

2. Building

$ cd atomspace_server
$ mkdir build && cd build
$ cmake ..
$ make 
$ make install

Usage

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.