Skip to content

Commit

Permalink
Copy changes made in ygg-mule.py (untested)
Browse files Browse the repository at this point in the history
  • Loading branch information
glrs committed Nov 20, 2024
1 parent 3464048 commit 08a4d58
Showing 1 changed file with 45 additions and 45 deletions.
90 changes: 45 additions & 45 deletions ygg_trunk.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 08a4d58

Please sign in to comment.