fix(server): scope --reload watching to source dirs (#569)#611
Open
voidborne-d wants to merge 1 commit intoOpenBMB:mainfrom
Open
fix(server): scope --reload watching to source dirs (#569)#611voidborne-d wants to merge 1 commit intoOpenBMB:mainfrom
--reload watching to source dirs (#569)#611voidborne-d wants to merge 1 commit intoOpenBMB:mainfrom
Conversation
When ``python server_main.py --reload`` was used, uvicorn's default reload_dirs is the current working directory and StatReload walks the whole tree for ``*.py`` files. Agent-generated code under ``WareHouse/session_<uuid>/code_workspace/<file>.py`` therefore triggers a server restart mid-workflow; the webui is left waiting indefinitely and the in-flight session is cancelled. The project already ships a warning in both READMEs telling users to drop ``--reload``, but that is exactly the tool dev loops need. Fix: pass an explicit ``reload_dirs`` list containing only the server's Python source folders (check, entity, functions, mcp_example, runtime, schema_registry, server, tools, utils, workflow) and a matching ``reload_excludes`` set (WareHouse, logs, data, temp, node_modules) so watchfiles-backed installs also stop observing output directories. Users can override either list via repeatable ``--reload-dir`` and ``--reload-exclude`` flags. The reload-kwargs construction is extracted into a pure helper so the behaviour is unit-tested without spinning up a real server; nine new tests cover the default behaviour, user overrides, argparse wiring, and that the returned lists are defensive copies. README / README-zh have been updated to reflect the new default. Fixes OpenBMB#569
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.
Summary
Closes #569.
When
python server_main.py --reloadis used during development, uvicorn defaultsreload_dirsto the current working directory andStatReloadrecursively walks the tree for*.pyfiles. Because the agent writes generated code intoWareHouse/session_<uuid>/code_workspace/<file>.py, every time a workflow produces code the server restarts mid-run, the in-flight session is cancelled, and the webui is left waiting indefinitely.Both READMEs already ship a warning telling users to drop
--reload, but that removes exactly the feedback loop developers need.Fix
server_main.pynow passes uvicorn:reload_dirslist restricted to the project's Python source folders (check,entity,functions,mcp_example,runtime,schema_registry,server,tools,utils,workflow), soStatReload— which ignoresreload_excludesentirely — never walksWareHouse/orlogs/;reload_excludeslist (WareHouse/*,logs/*,data/*,temp/*,node_modules/*) so watchfiles-backed installs also stop observing output dirs. This set mirrors.gitignore.Users can override either list via repeatable
--reload-dir/--reload-excludeflags.The reload-kwargs construction is extracted into a pure helper (
build_reload_kwargs) so the behaviour is unit-testable without spinning up a server.Changes
server_main.py: defineRELOAD_SOURCE_DIRS/RELOAD_EXCLUDES, addbuild_reload_kwargs()+build_parser()helpers, wire new CLI flags, pass the resulting kwargs touvicorn.run(...).tests/test_server_main_reload.py: 9 new tests (defaults excludeWareHouse, includeserver/runtime; overrides win; repeatable flags; returned lists are copies). Uses animportlib.utilspec loader +monkeypatch.setitem(sys.modules, ...)so stubs forruntime.bootstrap/server.appare fully isolated from the rest of the test suite.README.md/README-zh.md: replaced the "remove--reload" workaround note with a description of the new default and the override flags.Verification
build_parser().print_help()renders the new--reload-dir/--reload-excludeoptions.--reloadcode path.Validate YAML Workflows) does not watch these paths, so it should stay green.