From 08a4d585e1cba9d081d4e7fa28a90e8c76b0b5ff Mon Sep 17 00:00:00 2001 From: glrs <5999366+glrs@users.noreply.github.com> Date: Wed, 20 Nov 2024 10:48:47 +0100 Subject: [PATCH] Copy changes made in ygg-mule.py (untested) --- ygg_trunk.py | 90 ++++++++++++++++++++++++++-------------------------- 1 file changed, 45 insertions(+), 45 deletions(-) diff --git a/ygg_trunk.py b/ygg_trunk.py index f5b0710..d47de6d 100644 --- a/ygg_trunk.py +++ b/ygg_trunk.py @@ -22,54 +22,54 @@ async def process_couchdb_changes(): # Fetch data from CouchDB and call the appropriate module async for data, module_loc in pdm.fetch_changes(): try: - project_id = data.get("project_id") - - # Check if the project exists - existing_document = ydm.check_project_exists(project_id) - - if existing_document is None: - projects_reference = data.get("_id") - method = data.get("details", {}).get( - "library_construction_method" - ) - - # Create a new project if it doesn't exist - ydm.create_project(project_id, projects_reference, method) - process_project = True - else: - # If the project exists, check if it is completed - if existing_document.get("status") == "completed": - logging.info( - f"Project with ID {project_id} is already completed. Skipping further processing." - ) - process_project = False + # project_id = data.get("project_id") + + # # Check if the project exists + # existing_document = ydm.check_project_exists(project_id) + + # if existing_document is None: + # projects_reference = data.get("_id") + # method = data.get("details", {}).get( + # "library_construction_method" + # ) + + # # Create a new project if it doesn't exist + # ydm.create_project(project_id, projects_reference, method) + # process_project = True + # else: + # # If the project exists, check if it is completed + # if existing_document.get("status") == "completed": + # logging.info( + # f"Project with ID {project_id} is already completed. Skipping further processing." + # ) + # process_project = False + # else: + # logging.info( + # f"Project with ID {project_id} is ongoing and will be processed." + # ) + # process_project = True + + # if process_project: + # Dynamically load the module + # module = Ygg.load_module(module_loc) + print(f">>> Module location: {module_loc}") + RealmClass = Ygg.load_realm_class(module_loc) + + if RealmClass: + # Call the module's launch function + realm = RealmClass(data, ydm) + if realm.proceed: + task = asyncio.create_task(realm.launch()) + tasks.append(task) + # print(f"Tasks ({realm.project_info['project_id']}): {tasks}") else: logging.info( - f"Project with ID {project_id} is ongoing and will be processed." - ) - process_project = True - - if process_project: - # Dynamically load the module - # module = Ygg.load_module(module_loc) - print(f">>> Module location: {module_loc}") - RealmClass = Ygg.load_realm_class(module_loc) - - if RealmClass: - # Call the module's launch function - realm = RealmClass(data, ydm) - if realm.proceed: - task = asyncio.create_task(realm.launch()) - tasks.append(task) - # print(f"Tasks ({realm.project_info['project_id']}): {tasks}") - else: - logging.info( - f"Skipping task creation due to missing required information. {data.get('project_id')}" - ) - else: - logging.warning( - f"Failed to load module '{module_loc}' for '{data['details']['library_construction_method']}'." + f"Skipping task creation due to missing required information. {data.get('project_id')}" ) + else: + logging.warning( + f"Failed to load module '{module_loc}' for '{data['details']['library_construction_method']}'." + ) except Exception as e: logging.warning( f"Error while trying to load module: {e}", exc_info=True