Skip to content

Commit

Permalink
Merge pull request #55 from singnet/feature/query-engine-issue-52
Browse files Browse the repository at this point in the history
[query-engine#52] Enhancement / Change constructor RedisMongoDB
  • Loading branch information
marcocapozzoli authored Dec 12, 2023
2 parents 3e850c5 + f65625b commit 2d42090
Show file tree
Hide file tree
Showing 17 changed files with 719 additions and 1,274 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ test-unit:
@py.test -sx ./tests/unit --cov=./hyperon_das_atomdb/ --cov-report=term-missing --cov-fail-under=70

isort:
@isort ./hyperon_das_atomdb ./tests --multi-line=3 --trailing-comma --force-grid-wrap=0 --use-parentheses --line-width=79
@isort ./hyperon_das_atomdb ./tests --multi-line=3 --trailing-comma --force-grid-wrap=0 --use-parentheses --line-width=100

black:
@black ./hyperon_das_atomdb ./tests --line-length 79 -t py37 --skip-string-normalization
@black ./hyperon_das_atomdb ./tests --line-length 100 -t py37 --skip-string-normalization

flake8:
@flake8 --show-source ./hyperon_das_atomdb ./tests
Expand Down
49 changes: 26 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,52 +21,55 @@ We use the [Poetry](https://python-poetry.org/) package to manage project depend

**2. poetry shell** (activate virtual environment)

### Prepare environment
## Environment Variables

**1 - Redis and MongoDB**
You must have Redis and MongoDB running in your environment

**2.1 - Environments Variables**
You must have the following variables set in your environment with their respective values:

```
DAS_MONGODB_HOSTNAME=172.17.0.2
DAS_MONGODB_PORT=27017
DAS_MONGODB_USERNAME=mongo
DAS_MONGODB_PASSWORD=mongo
DAS_MONGODB_TLS_CA_FILE=global-bundle.pem [optional]
DAS_REDIS_HOSTNAME=127.0.0.1
DAS_REDIS_PORT=6379
DAS_USE_REDIS_CLUSTER=false [default: true]
DAS_USE_REDIS_SSL=false [default: true]
DAS_USE_CACHED_NODES=false [default: true]
DAS_USE_CACHED_LINK_TYPES=false [default: true]
DAS_USE_CACHED_NODE_TYPES=false [default: true]
```

**2.2 or you can export necessary environment using the enviroment file**
source environment

## Usage

#### Use adapters
**1 - Redis and MongoDB**
- You must have Redis and MongoDB running in your environment
- To initialize the databases you must pass the parameters with the necessary values. Otherwise, default values will be used. See below which parameters it is possible to pass and their respective default values:

```python
from hyperon_das_atomdb.adapters import RedisMongoDB

redis_mongo_db = RedisMongoDB(
mongo_hostname='localhost',
mongo_port=27017,
mongo_username='mongo',
mongo_password='mongo',
mongo_tls_ca_file=None,
redis_hostname='localhost',
redis_port=6379,
redis_username=None,
redis_password=None,
redis_cluster=True,
redis_ssl=True,
)
```

**2 - In Memory DB**
```python
from hyperon_das_atomdb.adapters import RedisMongoDB, InMemoryDB, ServerDB
from hyperon_das_atomdb.adapters import InMemoryDB

redis_mongo_db = RedisMongoDB()
in_memory_db = InMemoryDB()
server_db = ServerDB(host='0.0.0.0')
```

## Tests

You can ran the command below to execute the unittests

```bash
make test-coverage
make test-unit
```

## Documentation References

[Repositories documentation](https://docs.google.com/document/d/1njmP_oXw_0FLwoXY5ttGBMFGV2n60-ugAltWIuoQO10/)
[Repositories documentation](https://docs.google.com/document/d/1njmP_oXw_0FLwoXY5ttGBMFGV2n60-ugAltWIuoQO10/)
11 changes: 9 additions & 2 deletions hyperon_das_atomdb/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
from .database import UNORDERED_LINK_TYPES, WILDCARD, AtomDB
from .exceptions import NodeDoesNotExistException
from .exceptions import AtomDoesNotExist, LinkDoesNotExist, NodeDoesNotExist

__all__ = ['AtomDB', 'WILDCARD', 'UNORDERED_LINK_TYPES', 'NodeDoesNotExistException']
__all__ = [
'AtomDB',
'WILDCARD',
'UNORDERED_LINK_TYPES',
'NodeDoesNotExist',
'LinkDoesNotExist',
'AtomDoesNotExist',
]
3 changes: 1 addition & 2 deletions hyperon_das_atomdb/adapters/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from .ram_only import InMemoryDB
from .redis_mongo_db import RedisMongoDB
from .server_db import ServerDB

__all__ = ['RedisMongoDB', 'InMemoryDB', 'ServerDB']
__all__ = ['RedisMongoDB', 'InMemoryDB']
Loading

0 comments on commit 2d42090

Please sign in to comment.