MCPcopy Index your code
hub / github.com/easydiffusion/easydiffusion / apply_backend_config_env_overrides

Function apply_backend_config_env_overrides

scripts/check_modules.py:46–77  ·  view source on GitHub ↗

Apply (a small allowlist of) backend_config keys from config.yaml to environment variables. Keeping an explicit allowlist helps prevent accidental or unsafe env overrides.

(backend_config: dict, env=None)

Source from the content-addressed store, hash-verified

44BLACKWELL_DEVICES = re.compile(r"\b(?:5060|5070|5080|5090)\b")
45
46def apply_backend_config_env_overrides(backend_config: dict, env=None) -> None:
47 """
48 Apply (a small allowlist of) backend_config keys from config.yaml to environment variables.
49
50 Keeping an explicit allowlist helps prevent accidental or unsafe env overrides.
51 """
52
53 if not backend_config:
54 return
55
56 if env is None:
57 env = os.environ
58
59 def _set(key: str, value) -> None:
60 if value is None:
61 return
62 env[key] = str(value)
63 print(f"backend_config overrode {key} to {env[key]}")
64
65 if "HSA_OVERRIDE_GFX_VERSION" in backend_config:
66 _set("HSA_OVERRIDE_GFX_VERSION", backend_config["HSA_OVERRIDE_GFX_VERSION"])
67 if "HIP_VISIBLE_DEVICES" in backend_config:
68 _set("HIP_VISIBLE_DEVICES", backend_config["HIP_VISIBLE_DEVICES"])
69
70 if "COMMANDLINE_ARGS" in backend_config:
71 cmdline_args = backend_config["COMMANDLINE_ARGS"]
72 if isinstance(cmdline_args, (list, tuple)):
73 cmdline_args = " ".join(map(str, cmdline_args))
74 _set("COMMANDLINE_ARGS", cmdline_args)
75
76 if "FORCE_FULL_PRECISION" in backend_config:
77 _set("FORCE_FULL_PRECISION", backend_config["FORCE_FULL_PRECISION"])
78
79
80def version(module_name: str) -> str:

Callers 1

launch_uvicornFunction · 0.85

Calls 1

_setFunction · 0.85

Tested by

no test coverage detected