Repository navigation
feat(backend): respect MULTIACE_CONFIG_DIR and resolve post-processor via _CFG_DIR - #153
Conversation
198407b to
7fcd71e
Compare
decay71
left a comment
There was a problem hiding this comment.
Thanks Simon, looks good. One small thing: tests/test_backend_config_dir.py and tests/backend_config_dir_selfcheck.py are identical, could you keep just one? Then I'll merge.
Dirk
|
Removed the duplicate test file as requested. Thanks Dirk! |
|
Would probably be safer to pull in main (since 151 was merged in) and see what is left on this PR to resolve conflicts! |
|
Thanks Simon. #151 is merged now and already adds MULTIACE_CONFIG_DIR to the backend, so #153 conflicts in main.py. Please merge main in (or rebase, it gets squashed anyway) and keep the resolver from #151; what's left from your PR is the post-processor part. One test needs adjusting: with #151, a MULTIACE_CONFIG_DIR pointing to a missing directory is still used rather than falling back, so that case should expect the env value. |
dd8d959 to
111f0e1
Compare
|
Rebased onto main to incorporate #151's config dir resolver, kept our post-processor script resolution, and updated tests to match. Ready for review! Thanks Dirk. |
1. Executive Summary & Problem Statement
Following the environment variable unification landed in #148,
ace.pyin Klipper honorsMULTIACE_CONFIG_DIRandMULTIACE_PRINTER_DATA. However, the web backend (multiace/web/backend/main.py) still resolved_CFG_DIRexclusively by searching default user paths (printer_data/config). On hosts using custom configuration roots (such as containerized deployments, custom multi-instance setups, or PAXX-managed environments), the backend would read and write filament snapshots, slot overrides, and spool databases under the stock fallback path rather than the configuration directory used by Klipper.Additionally, two locations in
main.py(_load_post_processorandpreflight_pysrc) contained hardcoded references toprinter_data/config/tools/post_process_virtual_toolheads.pyvia_user_paths(), bypassing custom configuration directories.This PR completes the host path alignment requested in #142 by making
MULTIACE_CONFIG_DIRthe first preference for_CFG_DIRand ensuring the post-processor script lookups follow_CFG_DIR.2. Implementation Details
multiace/web/backend/main.pyMULTIACE_CONFIG_DIR._resolve_cfg_dir(): Added a dedicated resolver that queriesos.environ.get("MULTIACE_CONFIG_DIR")as its first preference. If set, it returnsos.path.abspath(env_dir). If unset or empty, it falls back to the existing_first_existing(_user_paths("printer_data/config"))._CFG_EXT_DIR: dynamically derives asos.path.join(_CFG_DIR, "extended").MULTIACE_CFG_PATH: continues to serve as the explicit file override (MULTIACE_CFG_PATH), falling back to_CFG_EXT_DIR/ace.cfgand_CFG_DIR/ace.cfg.SNAPSHOT_DIR: defaults toos.path.join(_CFG_EXT_DIR, "multiace", "filament_snapshots").OVERRIDE_FILE: defaults toos.path.join(_CFG_EXT_DIR, "multiace", "slot_overrides.json").SPOOL_DB_PATH: defaults toos.path.join(_CFG_DIR, "persistent", "multiace_spools.json")._load_post_processor(): Replaced hardcoded_user_paths("printer_data/config/tools/...")withPath(_CFG_DIR) / "tools" / "post_process_virtual_toolheads.py", maintaining repo-leveltools/as the fallback.preflight_pysrc(): Replaced hardcoded_user_paths("printer_data/config/tools/...")withPath(_CFG_DIR) / "tools" / "post_process_virtual_toolheads.py", ensuring consistent module delivery to the browser preflight worker.tests/backend_config_dir_selfcheck.pytests/verifying:MULTIACE_CONFIG_DIRenvironment override takes precedence and correctly roots all derivative paths.MULTIACE_CONFIG_DIRis unset.MULTIACE_CFG_PATHexplicit override priority over_CFG_DIR.<custom_config_dir>/tools/.3. Verification Matrix & Test Evidence
MULTIACE_CONFIG_DIROverrideMULTIACE_CONFIG_DIR=/tmp/custom_printer_configset_CFG_DIRresolves to absolute custom path; extended dir, snapshots, slot overrides, and spool db derive correctlyMULTIACE_CONFIG_DIRnot set_CFG_DIRresolves to first existing user config candidateMULTIACE_CFG_PATH=/path/to/my_ace.cfgsetMULTIACE_CFG_PATHpreserved verbatim regardless of_CFG_DIR<_CFG_DIR>/tools/post_process_virtual_toolheads.pymultiace/tools/post_process_virtual_toolheads.pypython3 tests/backend_config_dir_selfcheck.py4. Backward Compatibility & Impact Assessment
MULTIACE_CONFIG_DIRis not set) execute the exact same fallback resolution chain as before.ace.pyin Klipper and external service wrappers, guaranteeing all multiACE components operate on the identical configuration root.Fixes #142