Migrate solver execution logging in DataFileClass.run() from print() to logging#15
Conversation
|
@VedranKapor can you review this |
|
Hi @parthdagia05 Great refactor — this definitely improves maintainability and makes the solver pipeline more production-ready. Moving away from print() is an important step, especially as MUIO evolves toward cross-platform support and potentially more complex or coupled solver workflows. One small suggestion: it might be beneficial to explicitly use Additionally, introducing some DEBUG-level logs for fine-grained stage timing (while keeping high-level milestones at INFO) could make the logging more flexible for profiling and performance diagnostics without increasing default verbosity. Overall, this is a clean and low-risk improvement — nice work |
…to logging - Replace informational print() calls with logger.info() - Replace exception print with logger.error(..., exc_info=True) - Configure logging in app.py using logging.basicConfig() - Preserve solver execution behavior and UI response No functional changes introduced. Refs OSeMOSYS#14
9705829 to
4e6e601
Compare
|
Hi @Aaravanand00, Thank you for the thoughtful feedback. I’ve incorporated the refinements directly into the existing commit: |
|
Just wanted to say thanks for forking repo and adding the logger. I’m currently working on a real‑time logging system for the optimization runs, since they can take a while and it’s useful for users to see live progress. |
|
Hi @VedranKapor, A real-time logging system for optimization runs sounds very valuable, especially for longer executions where user feedback makes a big difference in perceived responsiveness. I’d definitely be interested in contributing if there’s anything I can help with whether it’s structuring the logging flow, exploring streaming updates (e.g., via websockets), or helping design a clean interface between the solver and the frontend. Looking forward to collaborating further! |
Refactor: Migrate Solver Execution Logging to Python
logging🪵Closes: #14
Overview
This PR replaces legacy
print()statements within theDataFileClass.run()method with Python’s nativeloggingmodule.As the project evolves toward cross-platform support and more complex solver workflows, transitioning from unformatted stdout to structured logging is essential for professional debugging, maintainability, and future-proofing.
Changes
1. Structured Logging in
DataFileClassprint()calls withlogger.info().print(ex)withlogger.error(..., exc_info=True). This captures the full stack trace in the server logs while maintaining a clean output for the end-user.DataFileClass)2. Centralized Configuration
Introduced a standardized logging configuration in
API/app.py: