Skip to content

Commit

Permalink
Remove old NeoDB driver connection
Browse files Browse the repository at this point in the history
  • Loading branch information
john681611 committed Oct 4, 2023
1 parent 3b787dc commit b5d1ad1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 32 deletions.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,7 @@ Alternatively, you can use the dockerfile with
Some features like Gap Analysis require a neo4j DB running you can start this with
<pre>make docker-neo4j</pre>
enviroment varaibles for app to connect to neo4jDB (default):
- NEO4J_URI (localhost)
- NEO4J_USR (neo4j)
- NEO4J_PASS (password)
- NEO4J_BOLT_URL (bolt://neo4j:password@localhost:7687)

To run the web application for production you need gunicorn and you can run from within the cre_sync dir
<pre>make prod-run</pre>
Expand Down
31 changes: 2 additions & 29 deletions application/database/db.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from neo4j import GraphDatabase
import neo4j
from neomodel import (
config,
StructuredNode,
Expand Down Expand Up @@ -288,22 +286,9 @@ def instance(self):
if self.__instance is None:
self.__instance = self.__new__(self)

URI = os.getenv("NEO4J_URI") or "neo4j://localhost:7687"
AUTH = (
os.getenv("NEO4J_USERNAME") or "neo4j",
os.getenv("NEO4J_PASSWORD") or "password",
config.DATABASE_URL = (
os.getenv("NEO4J_BOLT_URL") or "bolt://neo4j:password@localhost:7687"
)
config.DATABASE_URL = os.getenv("NEO4J_BOLT_URL")
self.driver = GraphDatabase.driver(URI, auth=AUTH)

try:
self.driver.verify_connectivity()
self.connected = True
except neo4j.exceptions.ServiceUnavailable:
logger.error(
"NEO4J ServiceUnavailable error - disabling neo4j related features"
)

return self.__instance

def __init__(sel):
Expand Down Expand Up @@ -339,8 +324,6 @@ def populate_DB(self, session) -> nx.Graph:

@classmethod
def add_cre(self, dbcre: CRE):
if not self.connected:
return
NeoCRE.create_or_update(
{
"name": dbcre.name,
Expand All @@ -354,8 +337,6 @@ def add_cre(self, dbcre: CRE):

@classmethod
def add_dbnode(self, dbnode: Node):
if not self.connected:
return
if dbnode.ntype == "Standard":
NeoStandard.create_or_update(
{
Expand Down Expand Up @@ -410,8 +391,6 @@ def add_dbnode(self, dbnode: Node):

@classmethod
def link_CRE_to_CRE(self, id1, id2, link_type):
if not self.connected:
return
cre1 = NeoCRE.nodes.get(id=id1)
cre2 = NeoCRE.nodes.get(id=id2)

Expand All @@ -425,8 +404,6 @@ def link_CRE_to_CRE(self, id1, id2, link_type):

@classmethod
def link_CRE_to_Node(self, CRE_id, node_id, link_type):
if not self.connected:
return
cre = NeoCRE.nodes.get(id=CRE_id)
node = NeoNode.nodes.get(id=node_id)
if link_type == "Linked To":
Expand All @@ -439,8 +416,6 @@ def link_CRE_to_Node(self, CRE_id, node_id, link_type):

@classmethod
def gap_analysis(self, name_1, name_2):
if not self.connected:
return None, None
base_standard = NeoStandard.nodes.filter(name=name_1)

path_records_all, _ = db.cypher_query(
Expand Down Expand Up @@ -502,8 +477,6 @@ def format_path_record(rec: NeomodelPath):

@classmethod
def standards(self) -> List[str]:
if not self.connected:
return
tools = NeoTool.nodes.all()
standards = NeoStandard.nodes.all()

Expand Down

0 comments on commit b5d1ad1

Please sign in to comment.