CognitiveScience commited on
Commit
e89b97c
·
1 Parent(s): 5f7680f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -22
app.py CHANGED
@@ -88,16 +88,12 @@ def ccogsphere(name: str, rate: int, celsci: str):
88
  #demo.load()
89
  return reviews, total_reviews
90
 
91
- def ccogsphere2(name: str, rate: int, celsci: str):
92
- db = sqlite3.connect(DB_FILE)
93
- cursor = db.cursor()
94
- cursor.execute("INSERT INTO reviews(name, rate, celsci) VALUES(?,?,?)", [name, rate, celsci])
95
- db.commit()
96
- reviews, total_reviews = get_latest_reviews(db)
97
- db.close()
98
- #r = requests.post(url='https://ccml-persistent-data2.hf.space/api/predict/', json={"data": [name,celsci]})
99
- ##demo.load()
100
- return reviews, total_reviews
101
 
102
  def run_actr():
103
  from python_actr import log_everything
@@ -121,9 +117,10 @@ def run_actr():
121
  def run_ecs(inp):
122
  try:
123
  result=ecf(inp)
 
124
  except sqlite3.OperationalError:
125
  print ("db error")
126
- return result
127
 
128
 
129
  def load_data():
@@ -132,10 +129,11 @@ def load_data():
132
  db.close()
133
  return reviews, total_reviews
134
  def load_data2():
135
- db = sqlite3.connect(DB_FILE)
136
- reviews2, total_reviews2 = get_latest_reviews(db)
137
- db.close()
138
- return reviews2, total_reviews2
 
139
 
140
  # Creating a sample dataframe
141
  #df = pd.DataFrame({
@@ -155,21 +153,21 @@ with gr.Blocks() as demo:
155
  with gr.Row():
156
  with gr.Column():
157
  data2 = gr.Dataframe() #styler)
158
- count2 = gr.Number(label="Rates2!")
159
  with gr.Row():
160
  with gr.Column():
161
  celscie = gr.Textbox(label="e",value="robert+west") #, placeholder="What is your name?")
162
 
163
- result=run_ecs(celscie)
164
- df = pd.DataFrame.from_dict(result["videos"])
165
 
166
- gr.Dataframe(df)
167
 
168
  celsci2 = gr.Textbox(label="c2") #, lines=10, placeholder="Do you have any feedback on gradio?")
169
  #run_actr()
170
- submit2 = gr.Button(value=".")
171
- submit2.click(ccogsphere2, [celsci2], [data2, count2])
172
- demo.load(load_data2, None, [data2, count2])
173
 
174
  with gr.Row():
175
  with gr.Column():
 
88
  #demo.load()
89
  return reviews, total_reviews
90
 
91
+ def ccogsphere2(celsci: str):
92
+ result=run_ecs(celscie)
93
+ df = pd.DataFrame.from_dict(result["videos"])
94
+
95
+ gr.Dataframe(df)
96
+ return result
 
 
 
 
97
 
98
  def run_actr():
99
  from python_actr import log_everything
 
117
  def run_ecs(inp):
118
  try:
119
  result=ecf(inp)
120
+ df=pd.DataFrame.from_dict(result["videos"])
121
  except sqlite3.OperationalError:
122
  print ("db error")
123
+ return df
124
 
125
 
126
  def load_data():
 
129
  db.close()
130
  return reviews, total_reviews
131
  def load_data2():
132
+ #result=run_ecs(celscie)
133
+ #df = pd.DataFrame.from_dict(result["videos"])
134
+ reviews2=""
135
+ #gr.Dataframe(df)
136
+ return reviews2
137
 
138
  # Creating a sample dataframe
139
  #df = pd.DataFrame({
 
153
  with gr.Row():
154
  with gr.Column():
155
  data2 = gr.Dataframe() #styler)
156
+ count2 = gr.Number(label="Rates2!",value=13)
157
  with gr.Row():
158
  with gr.Column():
159
  celscie = gr.Textbox(label="e",value="robert+west") #, placeholder="What is your name?")
160
 
161
+ #result=run_ecs(celscie)
162
+ #df = pd.DataFrame.from_dict(result["videos"])
163
 
164
+ #gr.Dataframe(df)
165
 
166
  celsci2 = gr.Textbox(label="c2") #, lines=10, placeholder="Do you have any feedback on gradio?")
167
  #run_actr()
168
+ submit2 = gr.Button(value="E")
169
+ submit2.click(run_ecs, [celsci2], [data2])
170
+ #demo.load(load_data2, None, [data2])
171
 
172
  with gr.Row():
173
  with gr.Column():