Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions .env-template
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
WEB_HOST=0.0.0.0
WEB_PORT=8080
# supported GRAPH_DB values are neo4j or memgraph
GRAPH_DB=neo4j
NEO4J_HOST=localhost
NEO4J_BOLT_PORT=7687
NEO4J_USERNAME=neo4j
NEO4J_QUERY_TIMEOUT=600
NEO4J_HTTP_PORT=7474
NEO4J_PASSWORD=neo4j_password
MEMGRAPH_HOST=localhost
MEMGRAPH_BOLT_PORT=7687
# authentication is disabled by default in memgraph database.
# Remove the two lines below for setting MEMGRAPH_USERNAME and
# MEMGRAPH_PASSWORD if the default memgraph database behavior
# without user authentication is configured
MEMGRAPH_USERNAME=memgraph
MEMGRAPH_PASSWORD=memgraph_password
GRAPH_QUERY_TIMEOUT=600
PLATER_SERVICE_ADDRESS=localhost
PLATER_TITLE=Plater
PLATER_VERSION=1.5.1
Expand Down
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
*env
__pycache__
.pytest_cache
.log
*.log
kubernets
*coverage
.idea
.idea
2 changes: 1 addition & 1 deletion PLATER/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pyaml==20.4.0
pytest==8.3.3
pytest-asyncio==0.24.0
uvicorn==0.24.0
reasoner-transpiler==2.3.5
reasoner-transpiler==2.4.0
reasoner-pydantic==5.0.6
httpx==0.27.2
pytest-httpx==0.32.0
Expand Down
2 changes: 1 addition & 1 deletion PLATER/services/app_trapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
)
from PLATER.services.util.attribute_mapping import ATTRIBUTE_SKIP_LIST, ATTRIBUTE_TYPES
from PLATER.services.util.bl_helper import BLHelper, get_bl_helper
from PLATER.services.util.graph_adapter import GraphInterface
from PLATER.services.util.graph_backends.base import GraphInterface
from PLATER.services.util.metadata import get_graph_metadata, GraphMetadata
from PLATER.services.util.overlay import Overlay
from PLATER.services.util.question import Question
Expand Down
40 changes: 30 additions & 10 deletions PLATER/services/util/api_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,41 @@
from fastapi import Response
from fastapi.openapi.utils import get_openapi

from PLATER.services.util.graph_adapter import GraphInterface
from PLATER.services.util.logutil import LoggingUtil
from PLATER.services.util.graph_backends.base import GraphInterface
from PLATER.services.util.graph_backends.neo4j_adapter import Neo4jBackend
from PLATER.services.util.graph_backends.memgraph_adapter import MemgraphBackend
from PLATER.services.config import config

logger = LoggingUtil.init_logging(__name__,
config.get('logging_level'),
config.get('logging_format'))

async def get_graph_interface():
"""Get graph interface."""
graph_interface = GraphInterface(
host=config.get('NEO4J_HOST', 'localhost'),
port=config.get('NEO4J_BOLT_PORT', '7687'),
auth=(
config.get('NEO4J_USERNAME'),
config.get('NEO4J_PASSWORD')
)
)
await graph_interface.connect_to_neo4j()
graph_db = config.get('GRAPH_DB', 'neo4j')
if graph_db == 'memgraph':
mg_username = config.get('MEMGRAPH_USERNAME', None)
mg_password = config.get('MEMGRAPH_PASSWORD', None)
if mg_username and mg_password:
auth = (mg_username, mg_password)
else:
auth = None
graph_backend = MemgraphBackend(
host=config.get('MEMGRAPH_HOST', 'localhost'),
port=config.get('MEMGRAPH_BOLT_PORT', '7687'),
auth=auth)
else:
graph_backend = Neo4jBackend(
host=config.get('NEO4J_HOST', 'localhost'),
port=config.get('NEO4J_BOLT_PORT', '7687'),
auth=(
config.get('NEO4J_USERNAME'),
config.get('NEO4J_PASSWORD')
))
graph_interface = GraphInterface(graph_backend)

await graph_interface.connect()
return graph_interface


Expand Down
Loading