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

Function start_backend

ui/easydiffusion/backends/webui.py:91–139  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

89
90
91def start_backend():
92 config = getConfig()
93 backend_config = config.get("backend_config") or {}
94
95 log.info(f"Backend dir: {BACKEND_DIR}")
96
97 install_backend() # will do nothing if already installed
98
99 env = dict(os.environ)
100 env.update(get_env())
101
102 was_still_installing = not is_installed()
103
104 if backend_config.get("auto_update", True):
105 # Ensure the remote origin points to the correct repository
106 try:
107 current_remote = (
108 check_output_in_conda(["git", "remote", "get-url", "origin"], cwd=WEBUI_DIR, env=env)
109 .decode("utf-8")
110 .strip()
111 )
112 if current_remote != WEBUI_REPO:
113 log.info(f"Updating remote origin from {current_remote} to {WEBUI_REPO}")
114 run_in_conda(["git", "remote", "set-url", "origin", WEBUI_REPO], cwd=WEBUI_DIR, env=env)
115 except Exception as e:
116 log.warning(f"Failed to check/update git remote: {e}")
117
118 run_in_conda(["git", "add", "-A", "."], cwd=WEBUI_DIR, env=env)
119 run_in_conda(["git", "stash"], cwd=WEBUI_DIR, env=env)
120 run_in_conda(["git", "reset", "--hard"], cwd=WEBUI_DIR, env=env)
121 run_in_conda(["git", "fetch"], cwd=WEBUI_DIR, env=env)
122 run_in_conda(["git", "-c", "advice.detachedHead=false", "checkout", WEBUI_COMMIT], cwd=WEBUI_DIR, env=env)
123
124 # workaround for the installations that broke out of conda and used ED's python 3.8 instead of WebUI conda's Py 3.10
125 run_in_conda(["python", "-m", "pip", "install", "-q", "--upgrade", "urllib3==2.2.3"], cwd=WEBUI_DIR, env=env)
126
127 webui_common.WEBUI_API_PREFIX = ""
128
129 def run_fn():
130 cmd = "webui.bat" if OS_NAME == "Windows" else "./webui.sh"
131
132 log.info(f"starting: {cmd} in {WEBUI_DIR}")
133 log.info(f"COMMANDLINE_ARGS: {env['COMMANDLINE_ARGS']}")
134
135 return run_in_conda([cmd], cwd=WEBUI_DIR, env=env, wait=False, output_prefix="[WebUI] ")
136
137 do_start_backend(was_still_installing, run_fn)
138
139 start_proxy()
140
141
142def start_proxy():

Callers

nothing calls this directly

Calls 9

getConfigFunction · 0.90
do_start_backendFunction · 0.90
get_envFunction · 0.85
check_output_in_condaFunction · 0.85
run_in_condaFunction · 0.85
start_proxyFunction · 0.85
getMethod · 0.80
install_backendFunction · 0.70
is_installedFunction · 0.70

Tested by

no test coverage detected