Repository navigation
fix(flow): guard __main__.py entrypoints with if __name__ == '__main__' - #2639
Conversation
Unblocks main push CI (flow core unit shard 2/2: test_fresh_imports.py:: test_every_module_imports_alone) so packages-gate turns green and release-package.yml can publish openadapt-flow 4.0.0. Both openadapt_flow.agent_test.__main__ and openadapt_flow.verify_draft.__main__ called main() unconditionally at import time, causing argparse to exit when imported in a fresh interpreter.
Independent adversarial review: APPROVEFrom: Claude This PR fixes the only failure in main's
This also unblocks the types 0.24.2 publish. Types' newest commit is b454999, and its push run can't go green because the bug exists at that commit. After this merges, a commit that changes |
Independent adversarial review: REQUEST CHANGESFrom: Grok The code fix is correct. The blocker is what this merge would publish. The fix works.
P1: merging this publishes openadapt-flow 4.0.0 with the
That is the publish #2640 and #2637 say must not happen: "Flow 4.0.0 imports #2637 can't land first, because Flow's lock can't take 0.24.2 until PyPI serves it. What the branch needs: keep Flow 4.0.0 from passing the release plan until #2637 merges. The simplest way I see is to leave the v4.0.0 entry undated in this PR, so Generality gate: the change is a generic entrypoint guard with no app-specific logic. I did not run Windows. |
* fix(flow): require openadapt-types>=0.24.2 for Flow 4.0.0 Flow 4.0.0 imports openadapt_types.check_level and evidence_scope (#2495), which no released types version has. The >=0.24.0 floor let pip resolve types 0.24.0 and fail on import. * chore(flow): hold Flow 4.0.0 until its types floor is 0.24.2 release_plan publishes a version only when CHANGELOG.md's first dated entry matches it. Undating v4.0.0 keeps the plan at wait, so #2639's green push run can't publish 4.0.0 with openadapt-types>=0.24.0, which fails on import. #2637 re-dates the entry together with the >=0.24.2 floor. * chore(flow): re-date v4.0.0 with the 0.24.2 types floor (undoes the #2641 hold) * chore(flow): relock openadapt-types 0.24.2 * chore(connectors): relock eligibility for the 0.24.2 types floor; name all new types imports
Fixes the deterministic
main-push CI failure inpackages.ymlrun45435843467(flow core unit (shard 2/2)), which cancelled shard 1/2 via matrix fail-fast and blockedpackages-gate/ PyPI publishing ofopenadapt-flow 4.0.0.Root Cause
tests/test_fresh_imports.py::test_every_module_imports_alone(skipped in the PR fast lane, runs onmainpush) imports every module underopenadapt_flowin a fresh interpreter. Two__main__.pymodules calledmain()unconditionally at import time:packages/flow/openadapt_flow/agent_test/__main__.pypackages/flow/openadapt_flow/verify_draft/__main__.pyFix
Wrap both entrypoints in
if __name__ == "__main__":(verified no otheropenadapt_flow/**/__main__.pyfiles are missing this guard).Verification
importlib.import_moduleon both modules: OKruff check&ruff format --check: OKgitleaks: 0 leaks@claude @grok — tiny 2-file CI unblock (
dda5d10eaf29e0d794986132017f145f5aaa1826), ready for quick review & merge.