Jaywalker061707 commited on
Commit
42d2b5d
·
verified ·
1 Parent(s): ccc9144

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -10
app.py CHANGED
@@ -1,21 +1,31 @@
1
  import gradio as gr
2
  from datasets import load_dataset
3
- from itertools import islice
4
 
5
- def stream_test(n=50):
6
  try:
7
  ds = load_dataset("MultimodalUniverse/jwst", split="train", streaming=True)
8
- count = sum(1 for _ in islice(ds, int(n)))
9
- return f"OK. Streamed {count} JWST records without downloading the full dataset."
 
 
 
 
 
 
 
 
 
 
 
10
  except Exception as e:
11
- return f"Error: {e}"
12
 
13
  demo = gr.Interface(
14
- fn=stream_test,
15
- inputs=gr.Slider(minimum=1, maximum=200, value=50, step=1, label="How many records to stream"),
16
- outputs="text",
17
- title="JWST streaming check",
18
- description="Test that we can stream data from the JWST dataset in small batches."
19
  )
20
 
21
  demo.launch()
 
1
  import gradio as gr
2
  from datasets import load_dataset
 
3
 
4
+ def peek_schema():
5
  try:
6
  ds = load_dataset("MultimodalUniverse/jwst", split="train", streaming=True)
7
+ first = next(iter(ds))
8
+ keys = list(first.keys())
9
+ types = {k: type(first[k]).__name__ for k in keys}
10
+ # show a few short text snippets if present
11
+ previews = {}
12
+ for k, v in first.items():
13
+ if isinstance(v, str) and len(v) > 0:
14
+ previews[k] = v[:200]
15
+ return {
16
+ "keys": keys,
17
+ "types": types,
18
+ "sample_text_preview": previews
19
+ }
20
  except Exception as e:
21
+ return {"error": str(e)}
22
 
23
  demo = gr.Interface(
24
+ fn=peek_schema,
25
+ inputs=None,
26
+ outputs="json",
27
+ title="JWST dataset schema peek",
28
+ description="Streams the first record from the JWST dataset to show available fields."
29
  )
30
 
31
  demo.launch()