Skip to content

Migrate run() pipeline logging from print() to Python logging module#160

Open
krrishrastogi05 wants to merge 1 commit intoEAPD-DRB:mainfrom
krrishrastogi05:print-to-log
Open

Migrate run() pipeline logging from print() to Python logging module#160
krrishrastogi05 wants to merge 1 commit intoEAPD-DRB:mainfrom
krrishrastogi05:print-to-log

Conversation

@krrishrastogi05
Copy link
Copy Markdown
Contributor

Summary

  • What changed: Replaced print() statements in the solver execution pipeline (run() method in DataFileClass.py) with Python's logging module.

  • Why: The current print() calls work fine for basic debugging, but they don't give us log levels, timestamps, or any way to capture output programmatically. As we move forward, we'll need to track multi-step execution and potentially stream progress to the UI. Python logging gives us all that while keeping the same console output by default.

Related issues

Validation

  • Tests added/updated (or not applicable)
  • Validation steps documented
  • Evidence attached (logs/screenshots/output as relevant)

How to test:

cd API
python app.py
# Run any model case through the UI
# Console output looks the same as before

To see the structured logging with timestamps, add this to app.py:

import logging
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')

Then output becomes:

2026-03-03 10:30:45 - Classes.Case.DataFileClass - INFO - PREPROCESSING DONE! --- 2.50 seconds --- case1
2026-03-03 10:30:48 - Classes.Case.DataFileClass - INFO - CREATION OF LP FILE DONE! --- 5.30 seconds --- case1

Documentation

  • Docs updated in this PR (or not applicable)
  • Any setup/workflow changes reflected in repo docs

No doc changes needed — this is a drop-in replacement that doesn't change any external behavior.

Scope check

  • No unrelated refactors
  • Implemented from a feature branch
  • Change is deliverable without upstream OSeMOSYS/MUIO dependency
  • Base repo/branch is EAPD-DRB/MUIOGO:main (not upstream)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Task] Migrate run() pipeline logging from print() to Python logging module

1 participant