Spaces:
Runtime error
Runtime error
Commit
·
8cbf8fc
1
Parent(s):
9014821
Update app.py
Browse files
app.py
CHANGED
|
@@ -88,6 +88,17 @@ def ccogsphere(name: str, rate: int, celsci: str):
|
|
| 88 |
#demo.load()
|
| 89 |
return reviews, total_reviews
|
| 90 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 91 |
def run_actr():
|
| 92 |
from python_actr import log_everything
|
| 93 |
|
|
@@ -107,12 +118,12 @@ def run_actr():
|
|
| 107 |
env.run()
|
| 108 |
|
| 109 |
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
|
| 117 |
|
| 118 |
def load_data():
|
|
@@ -120,6 +131,11 @@ def load_data():
|
|
| 120 |
reviews, total_reviews = get_latest_reviews(db)
|
| 121 |
db.close()
|
| 122 |
return reviews, total_reviews
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 123 |
|
| 124 |
# Creating a sample dataframe
|
| 125 |
#df = pd.DataFrame({
|
|
@@ -136,14 +152,35 @@ css="footer {visibility: hidden}"
|
|
| 136 |
# Applying style to highlight the maximum value in each row
|
| 137 |
#styler = df.style.highlight_max(color = 'lightgreen', axis = 0)
|
| 138 |
with gr.Blocks() as demo:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 139 |
with gr.Row():
|
| 140 |
with gr.Column():
|
| 141 |
celscie = gr.Textbox(label="e",value="robert+west") #, placeholder="What is your name?")
|
| 142 |
|
| 143 |
-
|
| 144 |
-
|
| 145 |
|
| 146 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 147 |
|
| 148 |
with gr.Row():
|
| 149 |
with gr.Column():
|
|
|
|
| 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
|
| 104 |
|
|
|
|
| 118 |
env.run()
|
| 119 |
|
| 120 |
|
| 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():
|
|
|
|
| 131 |
reviews, total_reviews = get_latest_reviews(db)
|
| 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({
|
|
|
|
| 152 |
# Applying style to highlight the maximum value in each row
|
| 153 |
#styler = df.style.highlight_max(color = 'lightgreen', axis = 0)
|
| 154 |
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 |
+
name2 = gr.Textbox(label="a2") #, placeholder="What is your name?")
|
| 169 |
+
rate2 = gr.Textbox(label="b2") #, placeholder="What is your name?") #gr.Radio(label="How satisfied are you with using gradio?", choices=[1, 2, 3, 4, 5])
|
| 170 |
+
celsci2 = gr.Textbox(label="c2") #, lines=10, placeholder="Do you have any feedback on gradio?")
|
| 171 |
+
#run_actr()
|
| 172 |
+
submit2 = gr.Button(value=".")
|
| 173 |
+
submit.click(ccogsphere2, [name2, rate2, celsci2], [data2, count2])
|
| 174 |
+
demo.load(load_data2, None, [data2, count2])
|
| 175 |
+
@name.change(inputs=name2, outputs=celsci2,_js="window.location.reload()")
|
| 176 |
+
@rate.change(inputs=rate2, outputs=name2,_js="window.location.reload()")
|
| 177 |
+
@celsci.change(inputs=celsci2, outputs2=rate,_js="window.location.reload()")
|
| 178 |
+
|
| 179 |
+
def secwork2(name2):
|
| 180 |
+
#if name=="abc":
|
| 181 |
+
#run_code()
|
| 182 |
+
load_data2()
|
| 183 |
+
#return "Hello " + name + "!"
|
| 184 |
|
| 185 |
with gr.Row():
|
| 186 |
with gr.Column():
|