Repository navigation
Expand file tree
/
Copy pathmodels.py
More file actions
244 lines (211 loc) · 5.86 KB
/
Copy pathmodels.py
File metadata and controls
244 lines (211 loc) · 5.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
from __future__ import annotations
from dataclasses import dataclass
from enum import StrEnum
from typing import TYPE_CHECKING, Any
if TYPE_CHECKING:
from pathlib import Path
JsonObject = dict[str, Any]
class AssetKind(StrEnum):
IMAGE = "image"
VIDEO = "video"
class OperationKind(StrEnum):
UPLOAD_IMAGE = "upload_image"
T2I = "t2i"
I2I = "i2i"
T2V = "t2v"
I2V = "i2v"
R2V = "r2v"
EXTEND = "extend"
SCENE_CREATE = "scene_create"
CHARACTER = "character"
class OperationStatus(StrEnum):
STARTED = "started"
SUCCEEDED = "succeeded"
FAILED = "failed"
class OperationAssetRole(StrEnum):
INPUT = "input"
OUTPUT = "output"
SEED_START = "seed_start"
SEED_END = "seed_end"
REFERENCE = "reference"
@dataclass(frozen=True)
class ProjectRecord:
id: str
profile_name: str
flow_project_id: str
title: str | None
source: str
created_at: str | None = None
@dataclass(frozen=True)
class AssetRecord:
id: str
profile_name: str
flow_project_id: str | None
flow_media_id: str
flow_workflow_id: str | None
flow_media_generation_id: str | None
kind: AssetKind
status: str
model: str | None
aspect_ratio: str | None
width: int | None
height: int | None
duration_seconds: float | None
seed: int | None
metadata_json: JsonObject
created_at: str | None = None
@classmethod
def minimal_image(
cls,
*,
id: str,
profile_name: str,
flow_project_id: str | None,
flow_media_id: str,
) -> AssetRecord:
return cls(
id=id,
profile_name=profile_name,
flow_project_id=flow_project_id,
flow_media_id=flow_media_id,
flow_workflow_id=None,
flow_media_generation_id=None,
kind=AssetKind.IMAGE,
status="ready",
model=None,
aspect_ratio=None,
width=None,
height=None,
duration_seconds=None,
seed=None,
metadata_json={},
)
@dataclass(frozen=True)
class OperationRecord:
id: str
profile_name: str
flow_project_id: str | None
command: str | None
mode: OperationKind
status: OperationStatus
flow_operation_id: str | None
flow_batch_id: str | None
prompt: str | None
prompt_hash: str | None
prompt_redacted: bool
model: str | None
aspect_ratio: str | None
error_type: str | None
error_detail: str | None
started_at: str | None = None
completed_at: str | None = None
# The Gemini "Creative Director" expansion actually submitted to Flow, when
# a `--tool` ran. None for un-tooled runs and when history_prompts='redacted'.
expanded_prompt: str | None = None
@classmethod
def minimal(
cls,
*,
id: str,
profile_name: str,
flow_project_id: str | None,
mode: OperationKind,
) -> OperationRecord:
return cls(
id=id,
profile_name=profile_name,
flow_project_id=flow_project_id,
command=None,
mode=mode,
status=OperationStatus.SUCCEEDED,
flow_operation_id=None,
flow_batch_id=None,
prompt=None,
prompt_hash=None,
prompt_redacted=False,
model=None,
aspect_ratio=None,
error_type=None,
error_detail=None,
)
@dataclass(frozen=True)
class LocalFileRecord:
id: str
profile_name: str
asset_id: str
path: Path | None # None for cloud-only files
media_type: str | None
bytes: int | None
sha256: str | None
storage_provider: str | None = None # "gcs" | "s3" | None (= local)
cloud_uri: str | None = None # gs://bucket/key or s3://bucket/key
created_at: str | None = None
superseded_at: str | None = None
@dataclass(frozen=True)
class SceneRecord:
id: str
profile_name: str
flow_project_id: str
flow_scene_id: str
total_duration: float | None
source: str
# Local path of the rendered extended video (server-side concat output),
# when `gflow scene create --out-file` was used. None = compose-only.
output_path: str | None = None
created_at: str | None = None
@dataclass(frozen=True)
class SceneClipRecord:
id: str
scene_id: str
position: int
flow_instance_workflow_id: str
flow_source_workflow_id: str | None
flow_media_id: str | None
start_time: float
end_time: float
total_duration: float
created_at: str | None = None
@dataclass(frozen=True)
class ChainLinkRecord:
"""One persisted link of a sequential last-frame I2V chain.
``seed_frame_path`` is the last-frame JPEG extracted to seed the NEXT link;
it is ``None`` when the clip is recorded but extraction has not yet run
(record-before-extract) and also for the final link (which seeds nothing).
A resume query distinguishes the two by ``link_index`` vs the chain length.
"""
id: str
profile_name: str
chain_id: str
link_index: int
flow_project_id: str | None
flow_media_id: str
flow_operation_id: str | None
prompt: str | None
local_path: str
seed_frame_path: str | None = None
created_at: str | None = None
@dataclass(frozen=True)
class AssetLookup:
id: str
profile_name: str
flow_project_id: str | None
flow_media_id: str
flow_workflow_id: str | None
kind: AssetKind
local_files: list[LocalFileRecord]
metadata_json: JsonObject
seed: int | None = None
@dataclass(frozen=True)
class SeedImage:
profile_name: str
flow_project_id: str
flow_media_id: str
flow_workflow_id: str | None
kind: AssetKind
width: int | None
height: int | None
local_path: Path | None
prompt: str | None
model: str | None
aspect_ratio: str | None
created_at: str