ccm commited on
Commit
d4abd7f
·
verified ·
1 Parent(s): a6e0d00

Deploy native explorer: 3 saved states

Browse files
Files changed (1) hide show
  1. app.py +27 -28
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-render",
147
  concurrency_limit=4,
148
  show_progress="hidden",
149
  )
150
  pause.click(fn=None, cancels=[playback], queue=False)
151
- for slider in (x, y, z, time):
152
- slider.release(
153
- render,
154
- inputs,
155
- outputs,
156
- cancels=[playback],
157
- trigger_mode="always_last",
158
- concurrency_id="native-render",
159
- concurrency_limit=4,
160
- show_progress="hidden",
161
- )
162
- for control in (quantity, resolution):
163
- control.change(
164
- render,
165
- inputs,
166
- outputs,
167
- cancels=[playback],
168
- trigger_mode="always_last",
169
- concurrency_id="native-render",
170
- concurrency_limit=4,
171
- show_progress="hidden",
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-render",
185
- concurrency_limit=4,
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-render",
194
- concurrency_limit=4,
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