MCPcopy Create free account
hub / github.com/ComfyWorkflows/ComfyUI-Launcher / create_comfyui_project

Function create_comfyui_project

server/tasks.py:8–121  ·  view source on GitHub ↗
(
    project_folder_path, models_folder_path, id, name, launcher_json=None, port=None, create_project_folder=True
)

Source from the content-addressed store, hash-verified

6
7@shared_task(ignore_result=False)
8def create_comfyui_project(
9 project_folder_path, models_folder_path, id, name, launcher_json=None, port=None, create_project_folder=True
10):
11 project_folder_path = os.path.abspath(project_folder_path)
12 models_folder_path = os.path.abspath(models_folder_path)
13
14 try:
15 if create_project_folder:
16 assert not os.path.exists(project_folder_path), f"Project folder already exists at {project_folder_path}"
17 os.makedirs(project_folder_path)
18 else:
19 assert os.path.exists(project_folder_path), f"Project folder does not exist at {project_folder_path}"
20
21 set_launcher_state_data(
22 project_folder_path,
23 {"id":id,"name":name, "status_message": "Downloading ComfyUI...", "state": "download_comfyui"},
24 )
25 # Modify the subprocess.run calls to capture and log the stdout
26 run_command(
27 ["git", "clone", COMFYUI_REPO_URL, os.path.join(project_folder_path, 'comfyui')],
28 )
29
30 if launcher_json:
31 comfyui_commit_hash = launcher_json["snapshot_json"]["comfyui"]
32 if comfyui_commit_hash:
33 run_command(
34 ["git", "checkout", comfyui_commit_hash],
35 cwd=os.path.join(project_folder_path, 'comfyui'),
36 )
37 launcher_json['workflow_json'] = normalize_model_filepaths_in_workflow_json(launcher_json['workflow_json'])
38
39
40 # move the comfyui/web/index.html file to comfyui/web/comfyui_index.html
41 os.rename(
42 os.path.join(project_folder_path, "comfyui", "web", "index.html"),
43 os.path.join(project_folder_path, "comfyui", "web", "comfyui_index.html"),
44 )
45
46 # copy the web/comfy_frame.html file to comfyui/web/index.html
47 shutil.copy(
48 os.path.join("web", "comfy_frame.html"),
49 os.path.join(project_folder_path, "comfyui", "web", "index.html"),
50 )
51
52 # remove the models folder that exists in comfyui and symlink the shared_models folder as models
53 if os.path.exists(os.path.join(project_folder_path, "comfyui", "models")):
54 shutil.rmtree(
55 os.path.join(project_folder_path, "comfyui", "models"), ignore_errors=True
56 )
57
58 if not os.path.exists(models_folder_path):
59 setup_initial_models_folder(models_folder_path)
60
61 # create a folder in project folder/comfyui/models that is a symlink to the models folder
62 create_symlink(models_folder_path, os.path.join(project_folder_path, "comfyui", "models"))
63
64 set_launcher_state_data(
65 project_folder_path,

Callers

nothing calls this directly

Tested by

no test coverage detected