Added structured startup validation for runtime dependencies (Issue #3)#33
Added structured startup validation for runtime dependencies (Issue #3)#33sanvishukla wants to merge 5 commits intoEAPD-DRB:mainfrom
Conversation
|
Hi, this is a great initiative! Failing fast before a long scenario run is absolutely critical for the user experience, especially given how heavy these models are. I was reviewing the validation logic and noticed a architectural clash with how the core app currently resolves solver paths, plus a quick thought on extensibility for the upcoming OG-Core integration: 1. System PATH vs Local SOLVERs_FOLDER (Startup Blocker):Currently, If a user relies on these bundled local solvers, this validation script will trigger a false positive and crash the app on startup. We should probably update the validation to check inside 2. Extensibility for OG-Core:As we start wiring up the OG-Core integration (Phase 2), we will need to validate its specific dependencies as well. Leaving the Really solid foundation here, just want to make sure it doesn't accidentally lock out users running the localized solver setup! |
…solution and preserve version detection
|
Thanks @NamanmeetSingh for pointing out that the initial implementation only relied on shutil.which(), which could incorrectly fail for users relying on bundled/local solvers resolved via
I validated the following scenarios:
This ensures startup validation mirrors the actual solver resolution strategy and avoids false positives for users relying on localized solver setups. And you are absolutely right about your 2nd point! The |
…te keys, and refine DATA_STORAGE permission handling
|
Looks perfect @sanvishukla. Checking WebAPP/SOLVERs first is the right move to keep the bundled setups running smoothly. Great turnaround on this! |
|
Thanks for this contribution and for the thoughtful startup-validation work. We really appreciate it. Quick update on merge sequencing: we are about to merge another set of mac-port PRs first (#31, #32, #35, #40, #44, #46, #11). Some of those overlap with parts of this PR (especially Config/path handling and solver-resolution behavior), so we want to avoid introducing conflicts/regressions in this pass. Could you please take another look after those merges land in mac-port, and then update this PR against the latest mac-port branch? If you can align the startup checks with the merged path/solver logic, we would be happy to review again quickly. Thanks again for your work and patience on this. I converted this to draft to make it easier for us to track |
f6dc516 to
725648b
Compare
|
Makes perfect sense, @SeaCelo. Staging the mac-port merges first is definitely the safest move to avoid dependency collisions. @sanvishukla Let me know if you need any help or a second pair of eyes on the solver resolution logic on the mac-port branch. |
|
@SeaCelo @NamanmeetSingh,
Permission behaviour validation
Validation in the comment above 1.Solver present only in WebAPP/SOLVERs → correctly detected locally
Is the automatic creation of WebAPP/DataStorage intentional design, or should validation be responsible for detecting and failing when required directories are missing? |
…esolution + Config-based paths)
35d76fe to
3231d24
Compare
1aa990a to
839a565
Compare
|
@SeaCelo, I have changed this PR according to the new changes in mac-port branch, please check and let me know if anything needs to be added or changed. |











Summary
Added a structured startup validation for deterministic runtime prerequisites, addressing the “Add startup validation with clear errors when required binaries/paths are missing” portion of Issue #3.
Additionally, during validation testing, it was observed that
Config.pyunconditionally setDATA_STORAGEpermissions to0o777, which masked permission-related behavior.This has been refined to avoid overriding environment-level permissions.
This PR introduces a pre-startup validation layer that ensures required directories and solver binaries are available before the server starts, providing clear and actionable feedback instead of runtime crashes.
What changed:
API/startup_validation.pyAPI/app.pyDATA_STORAGEexistence and write permissionsWebAPPdirectory existenceglpsol) availability via PATHDATA_STORAGEpermission handling:0o777permission overrideWhy:
Previously, missing solver binaries or required directories could cause unclear runtime failures or crashes before meaningful feedback was shown.
While validating write-permission behavior, it was discovered that
Config.pywas unconditionally modifying directory permissions at import time. This masked expected validation outcomes and could override externally configured permissions. The logic has been adjusted to ensure predictable behavior while maintaining development usability.This change ensures early, deterministic cross-platform failure detection without modifying existing runtime or path resolution logic.
Related issues
Validation
Validation Steps:
Normal startup (all dependencies installed)
OKRun from a different working directory
API/:cd API python app.pyNote: Running the application from a non-root working directory may still trigger existing path-resolution errors in Config.py. This is part of the broader path refactor tracked under Issue Fix platform-dependent paths and runtime assumptions for cross-platform support #3 and is not modified in this PR.
Missing solver simulation
PATH="" .venv/bin/python API/app.pyFAILMissing WebAPP directory simulation
WebAPP directoryreported asFAILPermission behaviour validation
Development environment:
Expected:
Production/default environment:
Expected:
Change path of DataStorage:

Documentation
No external documentation changes required — internal validation layer only
Scope check
OSeMOSYS/MUIOdependencyEAPD-DRB/MUIOGO:main(not upstream)