diff --git a/.gitignore b/.gitignore index d8a8dbfe..99f1651c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ .idea **/*mlruns* +**/*.env* **/*build* **/*egg* **/*pycache* diff --git a/src/flowcept/commons/daos/docdb_dao/lmdb_dao.py b/src/flowcept/commons/daos/docdb_dao/lmdb_dao.py index 7b011f60..632bfe98 100644 --- a/src/flowcept/commons/daos/docdb_dao/lmdb_dao.py +++ b/src/flowcept/commons/daos/docdb_dao/lmdb_dao.py @@ -292,7 +292,7 @@ def workflow_query( def close(self): """Close lmdb.""" - self.logger.warn("We are not closing this database.") + self.logger.warning("We are not closing this database.") return # self._env.close() # self._is_closed = True diff --git a/src/flowcept/flowcept_api/db_api.py b/src/flowcept/flowcept_api/db_api.py index db04588f..d4d1197b 100644 --- a/src/flowcept/flowcept_api/db_api.py +++ b/src/flowcept/flowcept_api/db_api.py @@ -10,7 +10,7 @@ from flowcept.commons.flowcept_dataclasses.task_object import TaskObject from flowcept.commons.flowcept_logger import FlowceptLogger -from flowcept.configs import DATABASES +from flowcept.configs import MONGO_ENABLED, LMDB_ENABLED class DBAPI(object): @@ -37,12 +37,12 @@ def __init__( if self.with_webserver: raise NotImplementedError("We did not implement webserver API for this yet.") - if "mongodb" in DATABASES and DATABASES["mongodb"].get("enabled", False): + if MONGO_ENABLED: # Currently MongoDB has precedence over LMDB if both are enabled. from flowcept.commons.daos.docdb_dao.mongodb_dao import MongoDBDAO self._dao = MongoDBDAO(create_indices=False) - elif "lmdb" in DATABASES and DATABASES["lmdb"].get("enabled", False): + elif LMDB_ENABLED: from flowcept.commons.daos.docdb_dao.lmdb_dao import LMDBDAO self._dao = LMDBDAO() diff --git a/tests/api/db_api_test.py b/tests/api/db_api_test.py index 7791d086..80afa507 100644 --- a/tests/api/db_api_test.py +++ b/tests/api/db_api_test.py @@ -45,7 +45,10 @@ def test_wf_dao(self): wf2.interceptor_ids = ["1234"] assert Flowcept.db.insert_or_update_workflow(wf2) wf_obj = Flowcept.db.get_workflow(wf2_id) - assert len(wf_obj.interceptor_ids) == 2 + if MONGO_ENABLED: + # TODO: note that some of these tests currently only work on MongoDB because + # updating is not yet implemented in LMDB + assert len(wf_obj.interceptor_ids) == 2 wf2.machine_info = {"123": tel.capture_machine_info()} assert Flowcept.db.insert_or_update_workflow(wf2) wf_obj = Flowcept.db.get_workflow(wf2_id) @@ -53,7 +56,8 @@ def test_wf_dao(self): wf2.machine_info = {"1234": tel.capture_machine_info()} assert Flowcept.db.insert_or_update_workflow(wf2) wf_obj = Flowcept.db.get_workflow(wf2_id) - assert len(wf_obj.machine_info) == 2 + if MONGO_ENABLED: + assert len(wf_obj.machine_info) == 2 @unittest.skipIf(not MONGO_ENABLED, "MongoDB is disabled") def test_save_blob(self): diff --git a/tests/api/query_test.py b/tests/api/query_test.py index 2f8682a0..127a7588 100644 --- a/tests/api/query_test.py +++ b/tests/api/query_test.py @@ -17,7 +17,7 @@ Status, ) from flowcept.commons.flowcept_logger import FlowceptLogger -from flowcept.configs import WEBSERVER_PORT, WEBSERVER_HOST +from flowcept.configs import WEBSERVER_PORT, WEBSERVER_HOST, MONGO_ENABLED from flowcept.flowcept_api.task_query_api import TaskQueryAPI from flowcept.flowcept_webserver.app import app, BASE_ROUTE from flowcept.flowcept_webserver.resources.query_rsrc import TaskQuery @@ -129,6 +129,7 @@ def gen_mock_data(size=1, with_telemetry=False): return new_docs, new_task_ids +@unittest.skipIf(not MONGO_ENABLED, "MongoDB is disabled") class QueryTest(unittest.TestCase): URL = f"http://{WEBSERVER_HOST}:{WEBSERVER_PORT}{BASE_ROUTE}{TaskQuery.ROUTE}"