Make prod deploys work from a clean checkout of main#66
Merged
Conversation
Three fixes so a fresh 'git pull' + rebuild + restart of main serves correctly on the server, without manual patching: - Add services/segmentation_metrics.py. api_blueprint imported calculate_session_metrics from it, but the module was never committed, so the backend crashed on boot from any clean checkout. Provide a safe module whose only caller already falls back to frontend-supplied metrics. - get-segmentations: cache the uint8-converted mask in /tmp instead of writing a sibling into the read-only mask_only/ data mount. The write 500'd the endpoint in production and violated the never-write-into-mask_only rule. - README deploy steps: check out main before pulling, free the gunicorn port reliably on restart, and verify ping + search + segmentations after deploy.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Production deploys had stopped taking effect. Root causes, all fixed here so a plain
git pull+ rebuild + restart ofmainserves correctly on the server with no manual patching:Backend wouldn't boot from a clean checkout.
api_blueprint.pyimportscalculate_session_metricsfromservices.segmentation_metrics, but that module was never committed to the repo — so a fresh clone/checkout crashes on startup. Added a safe module; its only caller already falls back to frontend-supplied metrics, so behavior is unchanged where the file existed locally./api/get-segmentations500'd on the server. It wrote the uint8-converted mask as a sibling inside the dataset'smask_only/, which is read-only on the server (and writing there violates the never write into image_only/mask_only rule). Now caches the converted copy in/tmpinstead.Deploy runbook hardened (
README.md): check outmainbefore pulling (prod had drifted onto an old branch), free the gunicorn port reliably on restart, and verify ping + search + segmentations after each deploy.Testing
python -m py_compilepasses on both changed Python files./api/searchreturns cases, and/api/get-segmentations/17.nii.gzreturns 200 with masks rendering in the viewer.