diff --git a/README.md b/README.md index 86d932d..182efdb 100644 --- a/README.md +++ b/README.md @@ -210,7 +210,7 @@ The `worker_consumer.py` script is a background service that runs on each ComfyU **Workflow normalization toggle:** -- Set `NILOR_WORKFLOW_OS_NORMALIZATION_ENABLED=false` to disable this behavior (default: enabled). +- Set `NILOR_WORKFLOW_OS_NORMALIZATION_ENABLED=false` (via environment or `config/config.json5`) to disable this behavior (default: enabled). @@ -221,7 +221,7 @@ The sidecar uses a small, typed configuration loader with JSON5 defaults and opt - **Precedence**: environment variables > `config/config.json5` (controlled by `allow_env_override: true`). - **No hot‑reload**: configuration is loaded once at process start and passed to components. - **Paths/keys**: JSON5 at `ComfyUI/custom_nodes/nilor-nodes/config/config.json5` with `NILOR_*` keys (e.g., `NILOR_COMFYUI_API_URL`, `NILOR_SQS_ENDPOINT_URL`). Secrets (AWS secret) must be set via `.env`. -- **Typed object**: loader returns a `NilorNodesConfig` with `comfy` and `worker` sections. +- **Typed object**: loader returns a `NilorNodesConfig` with `comfy`, `worker`, and `hygiene` sections. Pseudocode usage: diff --git a/config/config.json5 b/config/config.json5 index 072565e..3aca549 100644 --- a/config/config.json5 +++ b/config/config.json5 @@ -48,6 +48,11 @@ NILOR_MEMORY_HYGIENE_MAX_CYCLE_DURATION_SECONDS: 15, // ---- Worker / Queue settings ---- + // Workflow normalization (applies in worker_consumer before submission) + // When enabled, nilor-nodes will normalize OS-specific path formatting inside + // incoming workflows (e.g. Windows backslashes vs POSIX slashes). + NILOR_WORKFLOW_OS_NORMALIZATION_ENABLED: true, + // ElasticMQ/SQS endpoint URL (used by consumer and status updates) NILOR_SQS_ENDPOINT_URL: "http://localhost:9324", // Queue to pull new jobs from (polled by worker_consumer) diff --git a/config/config.py b/config/config.py index f97bb4a..c486e9f 100644 --- a/config/config.py +++ b/config/config.py @@ -79,6 +79,8 @@ class WorkerConfig: aws_secret_access_key: Secret access key for the SQS client (must be overridden via environment for real deployments). aws_region: AWS region name used by the SQS client. worker_client_id: Stable identifier for routing websocket events to this worker. + workflow_os_normalization_enabled: When true, normalize OS-specific path formatting + inside ComfyUI prompt graphs before submission. """ sqs_endpoint_url: str @@ -90,6 +92,7 @@ class WorkerConfig: aws_secret_access_key: str aws_region: str worker_client_id: str + workflow_os_normalization_enabled: bool @dataclass(frozen=True) @@ -199,6 +202,9 @@ class NilorNodesConfig(BaseConfig): ).strip(), aws_region=str(config_dict.get("NILOR_AWS_DEFAULT_REGION", "")).strip(), worker_client_id=worker_client_id, + workflow_os_normalization_enabled=_coerce_bool( + config_dict.get("NILOR_WORKFLOW_OS_NORMALIZATION_ENABLED", True) + ), ) # Memory hygiene @@ -332,6 +338,10 @@ def _apply_env_overrides(cfg: NilorNodesConfig) -> None: ) worker_region = os.getenv("NILOR_AWS_DEFAULT_REGION", cfg.worker.aws_region) worker_client_id = os.getenv("NILOR_WORKER_CLIENT_ID", cfg.worker.worker_client_id) + worker_workflow_os_norm = os.getenv( + "NILOR_WORKFLOW_OS_NORMALIZATION_ENABLED", + cfg.worker.workflow_os_normalization_enabled, + ) cfg.worker = WorkerConfig( sqs_endpoint_url=str(worker_sqs_endpoint_url), jobs_queue=str(worker_jobs_queue), @@ -342,6 +352,7 @@ def _apply_env_overrides(cfg: NilorNodesConfig) -> None: aws_secret_access_key=str(worker_secret_key), aws_region=str(worker_region), worker_client_id=str(worker_client_id), + workflow_os_normalization_enabled=_coerce_bool(worker_workflow_os_norm), ) # Re-validate after overrides diff --git a/worker_consumer.py b/worker_consumer.py index cf21437..6b6267b 100644 --- a/worker_consumer.py +++ b/worker_consumer.py @@ -432,10 +432,7 @@ class WorkerConsumer: # Normalize OS-sensitive path formatting inside the ComfyUI prompt graph. # This lets us accept workflows authored on a different OS (e.g. Windows # backslashes) and run them on the current worker OS. - enabled_raw = os.getenv( - "NILOR_WORKFLOW_OS_NORMALIZATION_ENABLED", "true" - ).strip() - enabled = enabled_raw.lower() not in ("0", "false", "no", "off") + enabled = self.cfg.worker.workflow_os_normalization_enabled if enabled and "prompt" in payload: try: normalized_prompt, rewritten = (