Deploy native explorer: 3 saved states
Browse files
app.py
CHANGED
|
@@ -68,7 +68,7 @@ def render_state(dataset, frame, x, y, z, quantity, n):
|
|
| 68 |
render_slice(dataset, frame, plane, coord, quantity, n)
|
| 69 |
for plane, coord in zip(("yz", "xz", "xy"), (x, y, z))
|
| 70 |
]
|
| 71 |
-
status = f"Frame {frame + 1}/{len(dataset.times)} · t = {dataset.times[frame]:.8f} · {n}² display samples per plane\n\n{dataset.cache_status}"
|
| 72 |
return (*images, status)
|
| 73 |
|
| 74 |
|
|
@@ -143,33 +143,32 @@ def make_app(dataset):
|
|
| 143 |
inputs,
|
| 144 |
[time, *outputs],
|
| 145 |
api_name=False,
|
| 146 |
-
concurrency_id="native-
|
| 147 |
concurrency_limit=4,
|
| 148 |
show_progress="hidden",
|
| 149 |
)
|
| 150 |
pause.click(fn=None, cancels=[playback], queue=False)
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
)
|
| 173 |
for button, increment in ((previous, -1), (following, 1)):
|
| 174 |
|
| 175 |
def advance(frame, *args, amount=increment):
|
|
@@ -181,8 +180,8 @@ def make_app(dataset):
|
|
| 181 |
inputs,
|
| 182 |
[time, *outputs],
|
| 183 |
cancels=[playback],
|
| 184 |
-
concurrency_id="native-
|
| 185 |
-
concurrency_limit=
|
| 186 |
show_progress="hidden",
|
| 187 |
)
|
| 188 |
app.load(
|
|
@@ -190,8 +189,8 @@ def make_app(dataset):
|
|
| 190 |
inputs,
|
| 191 |
outputs,
|
| 192 |
api_name="slice",
|
| 193 |
-
concurrency_id="native-
|
| 194 |
-
concurrency_limit=
|
| 195 |
)
|
| 196 |
return app.queue(max_size=16, default_concurrency_limit=4)
|
| 197 |
|
|
|
|
| 68 |
render_slice(dataset, frame, plane, coord, quantity, n)
|
| 69 |
for plane, coord in zip(("yz", "xz", "xy"), (x, y, z))
|
| 70 |
]
|
| 71 |
+
status = f"Frame {frame + 1}/{len(dataset.times)} · t = {dataset.times[frame]:.8f} · {quantity} · {n}² display samples per plane\n\nx = {x:.5f} · y = {y:.5f} · z = {z:.5f}\n\n{dataset.cache_status}"
|
| 72 |
return (*images, status)
|
| 73 |
|
| 74 |
|
|
|
|
| 143 |
inputs,
|
| 144 |
[time, *outputs],
|
| 145 |
api_name=False,
|
| 146 |
+
concurrency_id="native-playback",
|
| 147 |
concurrency_limit=4,
|
| 148 |
show_progress="hidden",
|
| 149 |
)
|
| 150 |
pause.click(fn=None, cancels=[playback], queue=False)
|
| 151 |
+
# One ordered event for all controls: a slower old request must not
|
| 152 |
+
# overwrite a newer quantity/coordinate choice. Playback uses a separate
|
| 153 |
+
# bounded group so one long animation cannot monopolize manual controls.
|
| 154 |
+
gr.on(
|
| 155 |
+
triggers=[
|
| 156 |
+
x.release,
|
| 157 |
+
y.release,
|
| 158 |
+
z.release,
|
| 159 |
+
time.release,
|
| 160 |
+
quantity.change,
|
| 161 |
+
resolution.change,
|
| 162 |
+
],
|
| 163 |
+
fn=render,
|
| 164 |
+
inputs=inputs,
|
| 165 |
+
outputs=outputs,
|
| 166 |
+
cancels=[playback],
|
| 167 |
+
trigger_mode="always_last",
|
| 168 |
+
concurrency_id="native-manual",
|
| 169 |
+
concurrency_limit=1,
|
| 170 |
+
show_progress="hidden",
|
| 171 |
+
)
|
|
|
|
| 172 |
for button, increment in ((previous, -1), (following, 1)):
|
| 173 |
|
| 174 |
def advance(frame, *args, amount=increment):
|
|
|
|
| 180 |
inputs,
|
| 181 |
[time, *outputs],
|
| 182 |
cancels=[playback],
|
| 183 |
+
concurrency_id="native-manual",
|
| 184 |
+
concurrency_limit=1,
|
| 185 |
show_progress="hidden",
|
| 186 |
)
|
| 187 |
app.load(
|
|
|
|
| 189 |
inputs,
|
| 190 |
outputs,
|
| 191 |
api_name="slice",
|
| 192 |
+
concurrency_id="native-manual",
|
| 193 |
+
concurrency_limit=1,
|
| 194 |
)
|
| 195 |
return app.queue(max_size=16, default_concurrency_limit=4)
|
| 196 |
|