From b5d1ad1214ed7f6178b8e6bef640cc1daffe3b2b Mon Sep 17 00:00:00 2001 From: john681611 Date: Wed, 4 Oct 2023 14:12:25 +0100 Subject: [PATCH] Remove old NeoDB driver connection --- README.md | 4 +--- application/database/db.py | 31 ++----------------------------- 2 files changed, 3 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index 6e1925678..7ca1ec1c3 100644 --- a/README.md +++ b/README.md @@ -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
make docker-neo4j
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
make prod-run
diff --git a/application/database/db.py b/application/database/db.py index 9144a4441..547b0c606 100644 --- a/application/database/db.py +++ b/application/database/db.py @@ -1,5 +1,3 @@ -from neo4j import GraphDatabase -import neo4j from neomodel import ( config, StructuredNode, @@ -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): @@ -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, @@ -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( { @@ -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) @@ -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": @@ -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( @@ -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()