system HF Staff commited on
Commit
65656a0
·
verified ·
1 Parent(s): c05d239

Deploy hyper3labs/HyperView from Hyper3Labs/hyperview-spaces@ae41c8d

Browse files
Files changed (3) hide show
  1. Dockerfile +8 -2
  2. README.md +2 -2
  3. demo.py +53 -6
Dockerfile CHANGED
@@ -21,8 +21,8 @@ WORKDIR $HOME/app
21
 
22
  RUN pip install --upgrade pip
23
 
24
- ARG HYPERVIEW_VERSION=0.6.2
25
- ARG HYPER_MODELS_VERSION=0.3.0
26
 
27
  # Install CPU-only PyTorch first so the Space does not pull the default CUDA bundle,
28
  # then pin released HyperView packages so Docker cache cannot hold an older release.
@@ -32,6 +32,12 @@ RUN pip install "hyper-models[ml]==${HYPER_MODELS_VERSION}" && python -c "import
32
 
33
  COPY --chown=user demo.py ./demo.py
34
 
 
 
 
 
 
 
35
  ENV HYPERVIEW_DATASETS_DIR=/home/user/app/demo_data/datasets \
36
  HYPERVIEW_MEDIA_DIR=/home/user/app/demo_data/media
37
 
 
21
 
22
  RUN pip install --upgrade pip
23
 
24
+ ARG HYPERVIEW_VERSION=1.0.0
25
+ ARG HYPER_MODELS_VERSION=0.3.1
26
 
27
  # Install CPU-only PyTorch first so the Space does not pull the default CUDA bundle,
28
  # then pin released HyperView packages so Docker cache cannot hold an older release.
 
32
 
33
  COPY --chown=user demo.py ./demo.py
34
 
35
+ # HyperView 1.0 mints a session token and rejects unauthenticated runtime
36
+ # commands. A public Space has no way to hand visitors that token, so panel
37
+ # creation and case switching 401 without this. It marks the server public:
38
+ # visitors get the viewer commands and nothing else, so provider registration,
39
+ # extension install, tool execution and compute stay closed.
40
+ ENV HYPERVIEW_NO_AUTH=1
41
  ENV HYPERVIEW_DATASETS_DIR=/home/user/app/demo_data/datasets \
42
  HYPERVIEW_MEDIA_DIR=/home/user/app/demo_data/media
43
 
README.md CHANGED
@@ -25,8 +25,8 @@ rights holder.
25
 
26
  The Docker image installs released packages from PyPI:
27
 
28
- - `hyperview==0.6.2`
29
- - `hyper-models[ml]==0.3.0`
30
 
31
  ## Dataset
32
 
 
25
 
26
  The Docker image installs released packages from PyPI:
27
 
28
+ - `hyperview==1.0.0`
29
+ - `hyper-models[ml]==0.3.1`
30
 
31
  ## Dataset
32
 
demo.py CHANGED
@@ -184,10 +184,14 @@ def add_inat24_samples(dataset: hv.Dataset) -> None:
184
  raise RuntimeError(f"Could not build the target iNat24 Tiny sample. Missing: {missing}.")
185
 
186
 
187
- def build_dataset() -> hv.Dataset:
188
  dataset = hv.Dataset(DATASET_NAME)
189
  add_inat24_samples(dataset)
190
 
 
 
 
 
191
  for embedding in EMBEDDING_LAYOUTS:
192
  print(f"Ensuring {embedding['name']} embeddings ({embedding['model']})...", flush=True)
193
  space_key = dataset.compute_embeddings(
@@ -198,15 +202,58 @@ def build_dataset() -> hv.Dataset:
198
 
199
  for layout in embedding["layouts"]:
200
  print(f"Ensuring {embedding['name']} {layout} layout...", flush=True)
201
- dataset.compute_visualization(space_key=space_key, layout=layout)
202
-
203
- return dataset
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
204
 
205
 
206
  def main() -> None:
207
- dataset = build_dataset()
208
  print(f"Starting HyperView on {SPACE_HOST}:{SPACE_PORT}", flush=True)
209
- hv.launch(dataset, host=SPACE_HOST, port=SPACE_PORT, open_browser=False)
 
 
 
 
 
 
210
 
211
 
212
  if __name__ == "__main__":
 
184
  raise RuntimeError(f"Could not build the target iNat24 Tiny sample. Missing: {missing}.")
185
 
186
 
187
+ def build_dataset() -> tuple[hv.Dataset, dict[str, str]]:
188
  dataset = hv.Dataset(DATASET_NAME)
189
  add_inat24_samples(dataset)
190
 
191
+ # Layout keys carry a content hash, so they are only knowable after the
192
+ # layout is computed. Collect them here and hand them to the view rather
193
+ # than pinning them as constants that a rebuild would invalidate.
194
+ layout_keys: dict[str, str] = {}
195
  for embedding in EMBEDDING_LAYOUTS:
196
  print(f"Ensuring {embedding['name']} embeddings ({embedding['model']})...", flush=True)
197
  space_key = dataset.compute_embeddings(
 
202
 
203
  for layout in embedding["layouts"]:
204
  print(f"Ensuring {embedding['name']} {layout} layout...", flush=True)
205
+ layout_keys[f"{embedding['name']}:{layout}"] = dataset.compute_visualization(
206
+ space_key=space_key, layout=layout
207
+ )
208
+
209
+ return dataset, layout_keys
210
+
211
+
212
+ def build_demo_view(layout_keys: dict[str, str]) -> hv.ui.View:
213
+ """Open the showcase on its three geometries, side by side.
214
+
215
+ Without an explicit view the workspace launches with no active layout, so
216
+ the embeddings panel renders "No 2D embeddings layout available" even
217
+ though three layouts exist -- the one thing this demo is here to show.
218
+ """
219
+
220
+ panels: list[hv.ui.Scatter | hv.ui.Samples] = []
221
+ previous_id: str | None = None
222
+ for label, layout_key in layout_keys.items():
223
+ name, layout = label.split(":", 1)
224
+ panel = hv.ui.Scatter(
225
+ id=f"map-{layout.replace(':', '-')}",
226
+ title=f"{name} · {layout}",
227
+ layout_key=layout_key,
228
+ position="center",
229
+ reference_panel_id=previous_id,
230
+ direction="right" if previous_id else None,
231
+ layout=hv.ui.PanelLayout(min_width=220, min_height=260),
232
+ )
233
+ panels.append(panel)
234
+ previous_id = panel.id
235
+
236
+ panels.append(
237
+ hv.ui.Samples(
238
+ id="samples",
239
+ title="iNat24 Tiny · 300 observations",
240
+ position="bottom",
241
+ layout=hv.ui.PanelLayout(height=260, min_height=180),
242
+ )
243
+ )
244
+ return hv.ui.View(*panels, active_panel=panels[0].id)
245
 
246
 
247
  def main() -> None:
248
+ dataset, layout_keys = build_dataset()
249
  print(f"Starting HyperView on {SPACE_HOST}:{SPACE_PORT}", flush=True)
250
+ hv.launch(
251
+ dataset,
252
+ host=SPACE_HOST,
253
+ port=SPACE_PORT,
254
+ open_browser=False,
255
+ view=build_demo_view(layout_keys),
256
+ )
257
 
258
 
259
  if __name__ == "__main__":