Commit Graph

4 Commits

Author SHA1 Message Date
Jedrzej Kosinski
38e5aac7bd Read .comfy_environment from ComfyUI install dir, not --base-directory
folder_paths.base_path is overridden by --base-directory to a user-supplied
location. Launchers/installers write the .comfy_environment marker next to the
ComfyUI install itself, so reading from base_path would silently fall back to
'local-git' whenever --base-directory is in use, defeating the purpose of the
env header.

Amp-Thread-ID: https://ampcode.com/threads/T-019df554-0cf8-755a-9f84-674e974aa5d1
Co-authored-by: Amp <amp@ampcode.com>
2026-05-04 16:52:15 -07:00
Jedrzej Kosinski
2001646f78 Switch deploy-environment value convention from underscores to dashes
Some checks are pending
Python Linting / Run Ruff (push) Waiting to run
Python Linting / Run Pylint (push) Waiting to run
Default value is now 'local-git' (was 'local_git'). Dashes are easier to type and more conventional in HTTP-header-adjacent identifiers. Tests updated accordingly.

Amp-Thread-ID: https://ampcode.com/threads/T-019df26e-96f4-7518-94da-0e4263680e3c
Co-authored-by: Amp <amp@ampcode.com>
2026-05-04 07:20:22 -07:00
Jedrzej Kosinski
22186b3dae Use functools.cache instead of manual global cache
Replaces the hand-rolled '_cached_value' module global with @functools.cache, which is the standard Python idiom for memoization. Tests now use the built-in get_deploy_environment.cache_clear() to reset between cases.

Amp-Thread-ID: https://ampcode.com/threads/T-019df26e-96f4-7518-94da-0e4263680e3c
Co-authored-by: Amp <amp@ampcode.com>
2026-05-04 06:55:54 -07:00
Jedrzej Kosinski
06e416bd0d Bound .comfy_environment read at 128 bytes; add unit tests
Defense-in-depth: cap readline() so a malformed or maliciously-large single-line file cannot blow up memory before the value is sanitized.

Adds tests-unit/deploy_environment_test.py covering: missing file fallback, basic read, whitespace strip, multi-line (only first line used), empty + whitespace-only files, control-char stripping (header-injection protection), non-ASCII stripping, 128-byte read cap, cache stickiness, and OSError fallback.

Amp-Thread-ID: https://ampcode.com/threads/T-019df26e-96f4-7518-94da-0e4263680e3c
Co-authored-by: Amp <amp@ampcode.com>
2026-05-04 06:53:40 -07:00