singnet / das

1 stars 0 forks source link

Issue loading a local DAS #63

Closed andre-senna closed 1 month ago

andre-senna commented 1 month ago

Hi! I performed the following steps to load small local DAS:

1.Started dbs with:

$ das-cli db start

  1. Loaded the metta file:

$ das-cli metta load /home/saulo/snet/hyperon/github/das-pk/shared_hsa_dmel2metta/data/output/test.metta

  1. Tried to run the script:

from hyperon_das import DistributedAtomSpace

host = '127.0.0.1' port = '8888' das = DistributedAtomSpace(query_engine='local', host=host, port=port)

print(f"Connected to DAS at {host}:{port}") print("(nodes, links) =", das.count_atoms())

  1. tried this way:

$ python3.10 bio2.py Connected to DAS at 127.0.0.1:8888 (nodes, links) = (0, 0)

Why there are no atoms? The MeTTa code in the test.metta is below Thanks!

(allele FBal0100372) (allele_symbol (allele FBal0100372) Myc[P0]) (gene_id (allele FBal0100372) FBgn0262656) (taxon_id (allele FBal0100372) 7227) (allele FBal0304771) (allele_symbol (allele FBal0304771) Clk[SV40.Tag:V5]) (gene_id (allele FBal0304771) FBgn0023076) (taxon_id (allele FBal0304771) 7227)

marcocapozzoli commented 1 month ago

You're facing this issue for 2 reasons

  1. You haven't started a local Faas (or if you did, it didn't work very well). You can do it like this:

das-cli faas start

You'll see this:

image

Did you see that the function is running on port 8080 and version (1.12.11) ?

So, when you try to connect the function and receive an error about version mismatch

image

you can fix this with this command:

das-cli faas update-version

For more details run: das-cli faas update-version --help

  1. You are using the Api in the wrong way. You should do this:

das = DistributedAtomSpace(query_engine='remote', host=host, port=port)

with query_engine='remote' not query_engine='local'

The way you instantiated a DAS, you made a local Das with backend in RAM.

It's the same this:

das = DistributedAtomSpace()

The correct concept is this

Local DAS is a DAS that has a backend in RAM or RedisMongo

# Ram
das = DistributedAtomSpace()

# RedisMongo
das = DistributedAtomSpace(
    atomdb='redis_mongo',
    mongo_hostname='...',
    mongo_port=...,
    mongo_username=...,
    mongo_password=...,
    redis_hostname=...,
    redis_port=...
)

And Remote Das is a Das that connects to a server via OpenFaas (this is your case)

das = DistributedAtomSpace(query_engine='remote', host=host, port=port)