loubnabnl HF Staff commited on
Commit
49e9afa
·
1 Parent(s): 07f32ab

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -6
app.py CHANGED
@@ -17,21 +17,19 @@ def show_extra_info(e):
17
  try:
18
  data_v = json.loads(e["dataset_versions"])[0]
19
  except:
20
- datav = ""
21
- nb_title = kv["Title"]
22
- nb_votes = kv["TotalVotes"]
23
  if data_v:
24
  data_title = data_v["Title"]
25
  import numpy as np
26
  decription = data_v["Description"] if str(data_v["Description"]) != 'nan' else "<empty_description>"
27
- data_text = f"It uses dataset: '{data_title}', described as: {decription}"
28
  else:
29
  data_text = ""
30
 
31
- text = f"The title of the notebook is: **'{nb_title}'** and it has **{nb_votes} upvotes**. {data_text}"
32
  return text
33
 
34
  samples = load_data()
35
- index_example = st.number_input(f"Index of the chosen sample from the existing {len(samples)}", min_value=0, max_value=len(samples)-1, value=0, step=1)
36
  st.markdown(show_extra_info(samples[index_example]))
37
  st.code(samples[index_example]["script"])
 
17
  try:
18
  data_v = json.loads(e["dataset_versions"])[0]
19
  except:
20
+ data_v = ""
 
 
21
  if data_v:
22
  data_title = data_v["Title"]
23
  import numpy as np
24
  decription = data_v["Description"] if str(data_v["Description"]) != 'nan' else "<empty_description>"
25
+ data_text = f"**Dataset description**\nTitle: '{data_title}', described as: {decription}"
26
  else:
27
  data_text = ""
28
 
29
+ text = f"The title of the notebook is: **'{kv["Title"]}'** and it has **{kv["TotalVotes"]} upvotes**.\n{data_text}"
30
  return text
31
 
32
  samples = load_data()
33
+ index_example = st.number_input(f"Chose a sample from the existing {len(samples)} notebooks:", min_value=0, max_value=len(samples)-1, value=0, step=1)
34
  st.markdown(show_extra_info(samples[index_example]))
35
  st.code(samples[index_example]["script"])