fix(generate): read WORKSPACE_DIR dynamically so relocated output isn't lost - #287
Open
kevin9327 wants to merge 1 commit into
Open
fix(generate): read WORKSPACE_DIR dynamically so relocated output isn't lost#287kevin9327 wants to merge 1 commit into
kevin9327 wants to merge 1 commit into
Conversation
…'t lost
_run_generation bound WORKSPACE_DIR via `from services.generator_registry
import WORKSPACE_DIR`, capturing the path at import time. POST /settings/paths
-> generator_registry.update_paths() rebinds that module global (and repoints
every generator's outputs_dir), so after the user relocates the workspace the
generation path kept writing into the *old* directory while /workspace/ serves
files from the new one — the generated mesh 404s and never appears.
Reference the module (registry.WORKSPACE_DIR) at call time instead, matching
how ply_to_splat and the settings router already read it ("workspace dir may
change at runtime"). Covers both /generate/from-image and /workflow-runs
(both funnel through _run_generation).
Adds api/tests/test_generation_router.py: a run started after the workspace is
relocated must file output under the current workspace (fails before, passes
after).
Co-Authored-By: Claude Opus 4.8 <[email protected]>
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.
What
After the workspace is relocated at runtime (
POST /settings/paths), 3D generations kept writing their output into the previous workspace directory, while/workspace/{path}served files from the new one — so the finished mesh 404s and never appears in the app.Why it triggers
api/routers/generation.pybound the workspace path withfrom services.generator_registry import WORKSPACE_DIR, capturing thePathat import time.POST /settings/paths→generator_registry.update_paths()rebinds theWORKSPACE_DIRmodule global (and repoints every loaded generator'soutputs_dir):Because
_run_generationused the stale imported name, it recomputedcoll_dir = WORKSPACE_DIR / collectionagainst the old directory and setgen.outputs_dirback to it — overriding the valueupdate_pathshad just written — then builtoutput_urlrelative to the same stale path./workspace/...reads the currentWORKSPACE_DIRdynamically, so it can't find the file.This affects both
/generate/from-imageand/workflow-runs/from-image(both funnel through_run_generation).Fix
Reference the module attribute
registry.WORKSPACE_DIRat call time instead of a name captured at import — the same wayoptimize.ply_to_splat(comment: "workspace dir may change at runtime") and the settings router already read it.Verification
api/tests/test_generation_router.py: drives_run_generationwith a fake generator after relocating the workspace, and asserts the output is filed under the current workspace (and thatoutput_urlmatches). Fails before, passes after.python -m unittest discover -s testsinapi/(venv withfastapi+python-multipart+httpx): all pass, 0 failures.