Enzo Reis de Oliveira commited on
Commit
68704e5
·
1 Parent(s): 6b91e18

Better error message

Browse files
Files changed (1) hide show
  1. app.py +7 -2
app.py CHANGED
@@ -35,6 +35,12 @@ def process_inputs(smiles: str, file_obj):
35
  smiles_col = smiles_cols[0]
36
  smiles_list = df_in[smiles_col].astype(str).tolist()
37
 
 
 
 
 
 
 
38
  embeddings = []
39
  for sm in smiles_list:
40
  vec = model.encode(sm, return_torch=True)[0].tolist()
@@ -62,8 +68,7 @@ def process_inputs(smiles: str, file_obj):
62
  df_out.to_csv("embeddings.csv", index=False)
63
  return json.dumps(vec), gr.update(value="embeddings.csv", visible=True)
64
  except Exception as e:
65
- return f"Error extracting embedding: {e}", gr.update(visible=False)
66
-
67
 
68
  # 4) Build the Gradio Blocks interface
69
  with gr.Blocks() as demo:
 
35
  smiles_col = smiles_cols[0]
36
  smiles_list = df_in[smiles_col].astype(str).tolist()
37
 
38
+ if (len(smiles_list) > 100):
39
+ return (
40
+ "Error: The CSV must have up to 100 Smiles.",
41
+ gr.update(visible=False),
42
+ )
43
+
44
  embeddings = []
45
  for sm in smiles_list:
46
  vec = model.encode(sm, return_torch=True)[0].tolist()
 
68
  df_out.to_csv("embeddings.csv", index=False)
69
  return json.dumps(vec), gr.update(value="embeddings.csv", visible=True)
70
  except Exception as e:
71
+ return f"The following input '{smiles}' is not a valid SMILES"
 
72
 
73
  # 4) Build the Gradio Blocks interface
74
  with gr.Blocks() as demo: