Skip to content

Commit 14a9b34

Browse files
authored
Merge branch 'master' into feat/partner-nodes/tripo-remove-refine
2 parents 6776065 + 2618d32 commit 14a9b34

10 files changed

Lines changed: 845 additions & 32 deletions

File tree

app/database/db.py

Lines changed: 53 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from app.logger import log_startup_warning
55
from utils.install_util import get_missing_requirements_message
66
from filelock import FileLock, Timeout
7-
from comfy.cli_args import args
7+
from comfy.cli_args import args, database_default_path
88

99
_DB_AVAILABLE = False
1010
Session = None
@@ -57,19 +57,66 @@ def get_alembic_config():
5757

5858
config = Config(config_path)
5959
config.set_main_option("script_location", scripts_path)
60-
config.set_main_option("sqlalchemy.url", args.database_url)
60+
config.set_main_option("sqlalchemy.url", get_database_url())
6161

6262
return config
6363

6464

65+
def get_database_url():
66+
if args.database_url is not None:
67+
return args.database_url
68+
69+
import folder_paths
70+
71+
db_path = os.path.join(folder_paths.get_user_directory(), "comfyui.db")
72+
return f"sqlite:///{db_path}"
73+
74+
75+
def get_legacy_default_db_path():
76+
return database_default_path
77+
78+
6579
def get_db_path():
66-
url = args.database_url
80+
url = get_database_url()
6781
if url.startswith("sqlite:///"):
68-
return url.split("///")[1]
82+
return url.split("///", 1)[1]
6983
else:
7084
raise ValueError(f"Unsupported database URL '{url}'.")
7185

7286

87+
def copy_legacy_default_db(db_path):
88+
if args.database_url is not None:
89+
return
90+
91+
legacy_db_path = get_legacy_default_db_path()
92+
if legacy_db_path is None:
93+
return
94+
95+
if os.path.abspath(legacy_db_path) == os.path.abspath(db_path):
96+
return
97+
98+
if os.path.exists(db_path) or not os.path.exists(legacy_db_path):
99+
return
100+
101+
backup_path = legacy_db_path + ".bak"
102+
if os.path.exists(backup_path):
103+
return
104+
105+
os.replace(legacy_db_path, backup_path)
106+
shutil.copy(backup_path, db_path)
107+
logging.info(
108+
f"Renamed legacy database '{legacy_db_path}' to '{backup_path}' and copied it to '{db_path}'"
109+
)
110+
111+
112+
def prepare_file_db_path(db_path):
113+
db_dir = os.path.dirname(db_path)
114+
if db_dir:
115+
os.makedirs(db_dir, exist_ok=True)
116+
117+
copy_legacy_default_db(db_path)
118+
119+
73120
_db_lock = None
74121

75122
def _acquire_file_lock(db_path):
@@ -97,7 +144,7 @@ def _is_memory_db(db_url):
97144

98145

99146
def init_db():
100-
db_url = args.database_url
147+
db_url = get_database_url()
101148
logging.debug(f"Database URL: {db_url}")
102149

103150
if _is_memory_db(db_url):
@@ -134,6 +181,7 @@ def set_sqlite_pragma(dbapi_connection, connection_record):
134181
def _init_file_db(db_url):
135182
"""Initialize a file-backed SQLite database using Alembic migrations."""
136183
db_path = get_db_path()
184+
prepare_file_db_path(db_path)
137185
db_exists = os.path.exists(db_path)
138186

139187
config = get_alembic_config()

comfy/cli_args.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ def is_valid_directory(path: str) -> str:
268268
database_default_path = os.path.abspath(
269269
os.path.join(os.path.dirname(__file__), "..", "user", "comfyui.db")
270270
)
271-
parser.add_argument("--database-url", type=str, default=f"sqlite:///{database_default_path}", help="Specify the database URL, e.g. for an in-memory database you can use 'sqlite:///:memory:'.")
271+
parser.add_argument("--database-url", type=str, default=None, help="Specify the database URL, e.g. for an in-memory database you can use 'sqlite:///:memory:'. Defaults to 'comfyui.db' in the effective user directory.")
272272
parser.add_argument("--enable-assets", action="store_true", help="Enable the assets system (API routes, database synchronization, and background scanning).")
273273
parser.add_argument("--enable-asset-hashing", action="store_true", help="Compute blake3 content hashes when scanning assets. Hashing enables future asset-portability features (deduplication, cross-machine model resolution) but adds startup cost and per-output cost on large models directories. Off by default; enable to opt in.")
274274
parser.add_argument("--feature-flag", type=str, action='append', default=[], metavar="KEY[=VALUE]", help="Set a server feature flag. Use KEY=VALUE to set an explicit value, or bare KEY to set it to true. Can be specified multiple times. Boolean values (true/false) and numbers are auto-converted. Examples: --feature-flag show_signin_button=true or --feature-flag show_signin_button")

comfy_api_nodes/apis/meshy.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class InputShouldRemesh(TypedDict):
1414
class InputShouldTexture(TypedDict):
1515
should_texture: str
1616
enable_pbr: bool
17+
texture_resolution: str
1718
texture_prompt: str
1819
texture_image: Input.Image | None
1920

@@ -25,7 +26,7 @@ class MeshyTaskResponse(BaseModel):
2526
class MeshyTextToModelRequest(BaseModel):
2627
mode: str = Field("preview")
2728
prompt: str = Field(..., max_length=600)
28-
art_style: str = Field(..., description="'realistic' or 'sculpture'")
29+
art_style: str = Field(...)
2930
ai_model: str = Field(...)
3031
topology: str | None = Field(..., description="'quad' or 'triangle'")
3132
target_polycount: int | None = Field(..., ge=100, le=300000)
@@ -35,6 +36,7 @@ class MeshyTextToModelRequest(BaseModel):
3536
)
3637
symmetry_mode: str = Field(..., description="'auto', 'off' or 'on'")
3738
pose_mode: str = Field(...)
39+
ultra_mode: bool = Field(False)
3840
seed: int = Field(...)
3941
moderation: bool = Field(False)
4042

@@ -43,6 +45,7 @@ class MeshyRefineTask(BaseModel):
4345
mode: str = Field("refine")
4446
preview_task_id: str = Field(...)
4547
enable_pbr: bool | None = Field(...)
48+
texture_resolution: str = Field(...)
4649
texture_prompt: str | None = Field(...)
4750
texture_image_url: str | None = Field(...)
4851
ai_model: str = Field(...)
@@ -61,7 +64,9 @@ class MeshyImageToModelRequest(BaseModel):
6164
)
6265
should_texture: bool = Field(...)
6366
enable_pbr: bool | None = Field(...)
67+
texture_resolution: str | None = Field(None)
6468
pose_mode: str = Field(...)
69+
ultra_mode: bool = Field(False)
6570
texture_prompt: str | None = Field(None, max_length=600)
6671
texture_image_url: str | None = Field(None)
6772
seed: int = Field(...)
@@ -80,6 +85,7 @@ class MeshyMultiImageToModelRequest(BaseModel):
8085
)
8186
should_texture: bool = Field(...)
8287
enable_pbr: bool | None = Field(...)
88+
texture_resolution: str | None = Field(None)
8389
pose_mode: str = Field(...)
8490
texture_prompt: str | None = Field(None, max_length=600)
8591
texture_image_url: str | None = Field(None)
@@ -103,8 +109,10 @@ class MeshyTextureRequest(BaseModel):
103109
ai_model: str = Field(...)
104110
enable_original_uv: bool = Field(...)
105111
enable_pbr: bool = Field(...)
106-
text_style_prompt: str | None = Field(...)
107-
image_style_url: str | None = Field(...)
112+
texture_resolution: str = Field(...)
113+
text_style_prompt: str | None = Field(None)
114+
image_style_url: str | None = Field(None)
115+
multiview_image_urls: list[str] | None = Field(None)
108116

109117

110118
class MeshyModelsUrls(BaseModel):

comfy_api_nodes/apis/wan.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,32 @@ class Wan27Text2VideoTaskCreationRequest(BaseModel):
184184
parameters: Wan27Text2VideoParametersField = Field(...)
185185

186186

187+
class Wan3MediaItem(BaseModel):
188+
type: str = Field(...)
189+
url: str = Field(...)
190+
191+
192+
class Wan3InputField(BaseModel):
193+
prompt: str | None = Field(None)
194+
media: list[Wan3MediaItem] | None = Field(None)
195+
196+
197+
class Wan3ParametersField(BaseModel):
198+
resolution: str = Field(...)
199+
ratio: str = Field(...)
200+
duration: int = Field(..., ge=-1, le=30)
201+
seed: int = Field(..., ge=0, le=2147483647)
202+
audio: bool = Field(True)
203+
prompt_extend: bool = Field(True)
204+
watermark: bool = Field(False)
205+
206+
207+
class Wan3TaskCreationRequest(BaseModel):
208+
model: str = Field(...)
209+
input: Wan3InputField = Field(...)
210+
parameters: Wan3ParametersField = Field(...)
211+
212+
187213
class TaskCreationOutputField(BaseModel):
188214
task_id: str = Field(...)
189215
task_status: str = Field(...)

0 commit comments

Comments
 (0)