feat(product-suite): persist current generation rounds
This commit is contained in:
@@ -302,6 +302,7 @@ CREATE TABLE IF NOT EXISTS image_studio_projects (
|
||||
target_detail_count INTEGER NOT NULL DEFAULT 12,
|
||||
draft_prompt TEXT,
|
||||
suite_settings_json TEXT NOT NULL DEFAULT '{}',
|
||||
current_generation_round_key TEXT,
|
||||
status TEXT NOT NULL DEFAULT 'active',
|
||||
created_at TEXT NOT NULL,
|
||||
updated_at TEXT NOT NULL,
|
||||
@@ -351,6 +352,8 @@ CREATE TABLE IF NOT EXISTS image_studio_jobs (
|
||||
points_cost INTEGER,
|
||||
points_balance INTEGER,
|
||||
call_id TEXT,
|
||||
generation_round_key TEXT,
|
||||
generation_slot_index INTEGER,
|
||||
created_at TEXT NOT NULL,
|
||||
updated_at TEXT NOT NULL,
|
||||
submitted_at TEXT,
|
||||
@@ -484,6 +487,7 @@ def init_db(path=None, conn=None) -> None:
|
||||
_ensure_image_studio_project_suite_columns(database)
|
||||
_ensure_image_studio_project_draft_columns(database)
|
||||
_ensure_image_studio_job_recovery_columns(database)
|
||||
_ensure_image_studio_generation_round_columns(database)
|
||||
|
||||
|
||||
def _ensure_batch_delete_columns(database):
|
||||
@@ -578,6 +582,36 @@ def _ensure_image_studio_job_recovery_columns(database):
|
||||
"""
|
||||
)
|
||||
|
||||
|
||||
def _ensure_image_studio_generation_round_columns(database):
|
||||
project_columns = {
|
||||
row["name"]
|
||||
for row in database.execute("PRAGMA table_info(image_studio_projects)").fetchall()
|
||||
}
|
||||
if "current_generation_round_key" not in project_columns:
|
||||
database.execute(
|
||||
"ALTER TABLE image_studio_projects "
|
||||
"ADD COLUMN current_generation_round_key TEXT"
|
||||
)
|
||||
|
||||
job_columns = {
|
||||
row["name"]
|
||||
for row in database.execute("PRAGMA table_info(image_studio_jobs)").fetchall()
|
||||
}
|
||||
if "generation_round_key" not in job_columns:
|
||||
database.execute(
|
||||
"ALTER TABLE image_studio_jobs ADD COLUMN generation_round_key TEXT"
|
||||
)
|
||||
if "generation_slot_index" not in job_columns:
|
||||
database.execute(
|
||||
"ALTER TABLE image_studio_jobs ADD COLUMN generation_slot_index INTEGER"
|
||||
)
|
||||
database.execute(
|
||||
"CREATE INDEX IF NOT EXISTS idx_image_studio_jobs_generation_round "
|
||||
"ON image_studio_jobs("
|
||||
"project_id, generation_round_key, generation_slot_index, id)"
|
||||
)
|
||||
|
||||
def create_batch(file_paths: Iterable[str], note=None, path=None, conn=None) -> str:
|
||||
batch_id = datetime.now().strftime("%Y%m%d_%H%M%S_") + uuid.uuid4().hex[:8]
|
||||
files = [os.path.abspath(file_path) for file_path in file_paths]
|
||||
|
||||
Reference in New Issue
Block a user