Skip to content

Auto processing improvements #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions stage0_mongodb_api/managers/config_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,16 @@ def process_all_collections(self) -> Dict[str, List[Dict]]:
Dict[str, List[Dict]]: Dictionary mapping collection names to their operation results
"""
results = {}
any_collection_failed = False

for collection_name in self.collection_configs.keys():
try:
results[collection_name] = self.process_collection_versions(collection_name)

# Check if this collection had any errors
if any(isinstance(op, dict) and op.get("status") == "error" for op in results[collection_name]):
any_collection_failed = True

except Exception as e:
logger.error(f"Error processing collection {collection_name}: {str(e)}")
results[collection_name] = [{
Expand All @@ -182,6 +188,23 @@ def process_all_collections(self) -> Dict[str, List[Dict]]:
"error": str(e),
"status": "error"
}]
any_collection_failed = True

# Add final overall status operation
overall_status = "error" if any_collection_failed else "success"
overall_message = "Some collections failed to process" if any_collection_failed else "All collections processed successfully"

# Add the overall status to each collection's results
for collection_name in results.keys():
results[collection_name].append({
"operation": "overall_status",
"status": overall_status,
"message": overall_message,
"collections_processed": len(self.collection_configs),
"collections_failed": sum(1 for result in results.values()
if any(isinstance(op, dict) and op.get("status") == "error"
for op in result))
})

return results

Expand Down
3 changes: 2 additions & 1 deletion stage0_mongodb_api/server.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import json
import sys
import signal
from flask import Flask
Expand Down Expand Up @@ -47,7 +48,7 @@ def handle_exit(signum, frame):

# Process all collections
processing_output = config_manager.process_all_collections()
logger.info(f"Processing Output: {processing_output}")
logger.info(f"Processing Output: {json.dumps(processing_output, indent=4)}")
logger.info(f"============= Auto Processing is Completed ===============")

if config.EXIT_AFTER_PROCESSING:
Expand Down
Loading