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

Function launch_uvicorn

scripts/check_modules.py:325–383  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

323
324
325def launch_uvicorn():
326 config = get_config()
327
328 pprint(config)
329
330 with open("scripts/install_status.txt", "a") as f:
331 f.write("sd_weights_downloaded\n")
332 f.write("sd_install_complete\n")
333
334 print("\n\nEasy Diffusion installation complete, starting the server!\n\n")
335
336 import torchruntime
337
338 torchruntime.configure()
339 if hasattr(torchruntime, "info"):
340 torchruntime.info()
341
342 # allow a user to override the HSA_OVERRIDE_GFX_VERSION and HIP_VISIBLE_DEVICES variables
343 # until ED gets process-based multi-GPU support (which will allow different processes to use different GPUs)
344 apply_backend_config_env_overrides(config.get("backend_config", {}))
345
346 if os_name == "Windows":
347 os.environ["PYTHONPATH"] = str(Path(os.environ["INSTALL_ENV_DIR"], "lib", "site-packages"))
348 else:
349 os.environ["PYTHONPATH"] = str(Path(os.environ["INSTALL_ENV_DIR"], "lib", "python3.8", "site-packages"))
350 os.environ["SD_UI_PATH"] = str(Path(Path.cwd(), "ui"))
351
352 print(f"PYTHONPATH={os.environ['PYTHONPATH']}")
353 print(f"Python: {shutil.which('python')}")
354 print(f"Version: {platform. python_version()}")
355
356 bind_ip = "127.0.0.1"
357 listen_port = 9000
358 if "net" in config:
359 print("Checking network settings")
360 if "listen_port" in config["net"]:
361 listen_port = config["net"]["listen_port"]
362 print("Set listen port to ", listen_port)
363 if "listen_to_network" in config["net"] and config["net"]["listen_to_network"] == True:
364 if "bind_ip" in config["net"]:
365 bind_ip = config["net"]["bind_ip"]
366 else:
367 bind_ip = "0.0.0.0"
368 print("Set bind_ip to ", bind_ip)
369
370 os.chdir("stable-diffusion")
371
372 print("\nLaunching uvicorn\n")
373
374 import uvicorn
375
376 uvicorn.run(
377 "main:server_api",
378 port=listen_port,
379 log_level="error",
380 app_dir=os.environ["SD_UI_PATH"],
381 host=bind_ip,
382 access_log=False,

Callers 1

mainFunction · 0.85

Calls 4

get_configFunction · 0.85
getMethod · 0.80
runMethod · 0.45

Tested by

no test coverage detected