Wen-Ding Li commited on
Commit
6f6391b
·
1 Parent(s): 1b3afee
Files changed (1) hide show
  1. app.py +14 -47
app.py CHANGED
@@ -2,62 +2,29 @@ import streamlit as st
2
  import json
3
  from datasets import load_dataset
4
 
5
- st.set_page_config(page_title="Kaggle Notebooks inspection", layout="wide")
6
 
7
- st.markdown("<h1 style='text-align: center; color: #00BFFF;'>Kaggle Notebooks inspection 🔍</h1>", unsafe_allow_html=True)
8
 
9
  st.markdown("""
10
- Here you can inspect Kaggle notebooks that were converted to python scripts and deduplicated.
11
 
12
- In the sidebar, you can choose to display:
13
- - **dataset description and title** when it exists; this information was already available in Kaggle dataset
14
- - only files for which we **retrieved extra information on the datasets being loaded** in the notebook using Kaggle API (e.g., column names, types, summary...), which makes up about 8% of the dataset.
15
- There might be multiple CSV files loaded in the same notebook; we use delimiters `<start_description>` and `<end_description>` to separate them.
16
  """)
17
 
18
  @st.cache()
19
- def load_data(upvote=0, size=0, has_data_info=False):
20
- ds = load_dataset("loubnabnl/kaggle_scripts_final_wdata", split="train")
21
- if has_data_info:
22
- ds = ds.filter(lambda x: x["has_data_info"])
23
- ds = ds.filter(lambda x: x["upvotes"] >= upvote and x["script_nb_tokens"] >= size)
24
  return ds
25
 
26
- def show_extra_info(e):
27
- kv = json.loads(e["kversion"])[0]
28
- try:
29
- data_v = json.loads(e["dataset_versions"])[0]
30
- except:
31
- data_v = ""
32
- if data_v:
33
- data_title = data_v["Title"]
34
- import numpy as np
35
- description = data_v["Description"] if str(data_v["Description"]) != 'nan' else "<empty_description>"
36
- data_text = f"<br>**📚 Dataset description:**<br>Title: **{data_title}**, described as: {description}."
37
- else:
38
- data_text = ""
39
-
40
- text = f"The title of the notebook is: **{kv['Title']}** and it has **{kv['TotalVotes']} ⬆️ upvotes**.{data_text}"
41
- return text
42
-
43
- st.sidebar.header('Notebook Filters')
44
- vote = st.sidebar.slider("Minimum notebook ⬆️ upvotes", min_value=0, max_value=100, step=1, value=0)
45
- size = st.sidebar.slider("Length of the notebook in number of tokens (only the script)", min_value=0, max_value=15_000, step=1000, value=0)
46
-
47
- st.sidebar.header('Display Settings')
48
- show_data_metadata = st.sidebar.checkbox("Show associated (not necessarily retrieved) data Title and Description", value=True)
49
- show_only_files_with_data = st.sidebar.checkbox("Show only files for which we retrieved dataset information", value=False)
50
-
51
- samples = load_data(vote, size, show_only_files_with_data)
52
  st.sidebar.header('Sample Selection')
53
  index_example = st.sidebar.number_input(f"Choose a sample from the existing {len(samples)} notebooks:", min_value=0, max_value=max(0, len(samples)-1), value=0, step=1)
54
 
55
- if show_data_metadata:
56
- st.markdown(f'<h2 style="color:blue;">Kaggle dataset description:</h2>', unsafe_allow_html=True)
57
- st.markdown(show_extra_info(samples[index_example]), unsafe_allow_html=True)
58
-
59
- if samples[index_example]["has_data_info"]:
60
- st.markdown(f'<h2 style="color:blue;">Retrieved data information:</h2>', unsafe_allow_html=True)
61
- st.code(samples[index_example]["retreived_data_description"])
62
- st.markdown(f'<h2 style="color:blue;">Notebook {index_example} converted to script:</h2>', unsafe_allow_html=True)
63
- st.code(samples[index_example]["script"])
 
2
  import json
3
  from datasets import load_dataset
4
 
5
+ st.set_page_config(page_title="BIRD SQL inspection", layout="wide")
6
 
7
+ st.markdown("<h1 style='text-align: center; color: #00BFFF;'>BIRD SQL inspection 🔍</h1>", unsafe_allow_html=True)
8
 
9
  st.markdown("""
10
+ Here you can inspect BIRD SQL data with schemas.
11
 
 
 
 
 
12
  """)
13
 
14
  @st.cache()
15
+ def load_data():
16
+ ds = load_dataset("xu3kev/BIRD-SQL-data", split="train")
 
 
 
17
  return ds
18
 
19
+
20
+ samples = load_data()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  st.sidebar.header('Sample Selection')
22
  index_example = st.sidebar.number_input(f"Choose a sample from the existing {len(samples)} notebooks:", min_value=0, max_value=max(0, len(samples)-1), value=0, step=1)
23
 
24
+ db_id = samples[index_example]["db_id"]
25
+ st.markdown(f'<h2 style="color:blue;">{db_id} schema:</h2>', unsafe_allow_html=True)
26
+ st.code(samples[index_example]["schema"])
27
+ st.markdown(f'<h2 style="color:blue;">{index_example} Question:</h2>', unsafe_allow_html=True)
28
+ st.code(samples[index_example]["question"])
29
+ st.markdown(f'<h2 style="color:blue;">{index_example} SQL:</h2>', unsafe_allow_html=True)
30
+ st.code(samples[index_example]["SQL"])