feat: add modal cloud builder

This commit is contained in:
BennyKok
2024-01-04 22:28:19 +08:00
parent d879889e1b
commit 314eb9fd16
17 changed files with 694 additions and 0 deletions
@@ -0,0 +1,3 @@
[
]
@@ -0,0 +1,11 @@
comfyui:
base_path: /runpod-volume/ComfyUI/
checkpoints: models/checkpoints/
clip: models/clip/
clip_vision: models/clip_vision/
configs: models/configs/
controlnet: models/controlnet/
embeddings: models/embeddings/
loras: models/loras/
upscale_models: models/upscale_models/
vae: models/vae/
@@ -0,0 +1,51 @@
import json
import requests
import time
import subprocess
command = ["python3", "/comfyui/main.py", "--disable-auto-launch", "--disable-metadata", "--cpu"]
# Start the server
server_process = subprocess.Popen(command)
def check_server(url, retries=50, delay=500):
for i in range(retries):
try:
response = requests.head(url)
# If the response status code is 200, the server is up and running
if response.status_code == 200:
print(f"builder - API is reachable")
return True
except requests.RequestException as e:
# If an exception occurs, the server may not be ready
pass
# Wait for the specified delay before retrying
time.sleep(delay / 1000)
print(
f"builder- Failed to connect to server at {url} after {retries} attempts."
)
return False
check_server("http://127.0.0.1:8188")
url = "http://127.0.0.1:8188/customnode/install"
headers = {"Content-Type": "application/json"}
# Load JSON array from deps.json
with open('deps.json') as f:
packages = json.load(f)
# Make a POST request for each package
for package in packages:
response = requests.request("POST", url, json=package, headers=headers)
print(response.text)
# restore_snapshot_url = "http://127.0.0.1:8188/snapshot/restore?target=snapshot"
# response = requests.request("GET", restore_snapshot_url, headers=headers)
# print(response.text)
# Close the server
server_process.terminate()
print("Finished installing dependencies.")
@@ -0,0 +1,5 @@
{
"comfyui": "d0165d819afe76bd4e6bdd710eb5f3e571b6a804",
"git_custom_nodes": {},
"file_custom_nodes": []
}
@@ -0,0 +1,6 @@
#!/usr/bin/env bash
# Your custom startup commands here.
echo "Starting modal"
exec "$@" # Runs the command passed to the entrypoint script.