MassimoGregorioTotaro commited on
Commit
462a012
·
1 Parent(s): 2dd6312
Files changed (1) hide show
  1. app.py +10 -9
app.py CHANGED
@@ -148,21 +148,21 @@ class Data:
148
  .hide(axis=0)
149
  .hide(axis=1)
150
  .background_gradient(cmap="RdYlGn", vmax=8, vmin=-8)
151
- .to_html())
152
 
153
  def calculate(self):
154
  "run model and parse output"
155
  self.model.run_model(self)
156
- return self, self.parse_output()
157
 
158
  def app(*argv):
159
  "run app"
160
- seq, trg, model_name, scoring_strategy, out_file, *_ = argv
161
- data, html = Data(seq, trg, model_name, scoring_strategy, out_file).calculate()
 
 
 
162
  return html, gr.File.update(value=out_file.name, visible=True)
163
- # df = pd.DataFrame((pd.np.random.random((10, 5))-0.5)*10, columns=list('ABCDE'))
164
- # df.to_csv(out_file.name, index=False)
165
- # return df.to_html(), gr.File.update(value=out_file.name, visible=True)
166
 
167
  with gr.Blocks() as demo, NamedTemporaryFile(mode='w+', prefix='out_', suffix='.csv') as out_file, open("instructions.md", "r") as md:
168
  gr.Markdown(md.read())
@@ -170,9 +170,10 @@ with gr.Blocks() as demo, NamedTemporaryFile(mode='w+', prefix='out_', suffix='.
170
  trg = gr.Textbox(lines=1, label="Substitutions", placeholder="Substitutions here...", value="61 214 19 30 122 140")
171
  model_name = gr.Dropdown(MODELS, label="Model", value=MODELS[1])
172
  scoring_strategy = gr.Dropdown(SCORING, label="Scoring strategy", value=SCORING[1])
173
- btn = gr.Button(value="Submit")
174
  out = gr.HTML()
175
  bto = gr.File(value=out_file.name, visible=False, label="Download", file_count='single', interactive=False)
176
  btn.click(fn=app, inputs=[seq, trg, model_name, scoring_strategy, bto], outputs=[out, bto])
177
 
178
- # demo.launch(share=True, server_name="0.0.0.0", server_port=7878)
 
 
148
  .hide(axis=0)
149
  .hide(axis=1)
150
  .background_gradient(cmap="RdYlGn", vmax=8, vmin=-8)
151
+ .to_html(justify='center'))
152
 
153
  def calculate(self):
154
  "run model and parse output"
155
  self.model.run_model(self)
156
+ return self.parse_output()
157
 
158
  def app(*argv):
159
  "run app"
160
+ # seq, trg, model_name, scoring_strategy, out_file, *_ = argv
161
+ # html = Data(seq, trg, model_name, scoring_strategy, out_file).calculate()
162
+ df = pd.DataFrame((pd.np.random.random((10, 5))-0.5)*10, columns=list('ABCDE'))
163
+ df.to_csv(out_file.name, index=False)
164
+ html = df.to_html(justify='center')
165
  return html, gr.File.update(value=out_file.name, visible=True)
 
 
 
166
 
167
  with gr.Blocks() as demo, NamedTemporaryFile(mode='w+', prefix='out_', suffix='.csv') as out_file, open("instructions.md", "r") as md:
168
  gr.Markdown(md.read())
 
170
  trg = gr.Textbox(lines=1, label="Substitutions", placeholder="Substitutions here...", value="61 214 19 30 122 140")
171
  model_name = gr.Dropdown(MODELS, label="Model", value=MODELS[1])
172
  scoring_strategy = gr.Dropdown(SCORING, label="Scoring strategy", value=SCORING[1])
173
+ btn = gr.Button(value="Run")
174
  out = gr.HTML()
175
  bto = gr.File(value=out_file.name, visible=False, label="Download", file_count='single', interactive=False)
176
  btn.click(fn=app, inputs=[seq, trg, model_name, scoring_strategy, bto], outputs=[out, bto])
177
 
178
+ if __name__ == "__main__":
179
+ demo.launch()