amirali1985 commited on
Commit
950401f
·
1 Parent(s): 920d4d8

update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -45
app.py CHANGED
@@ -1,8 +1,6 @@
1
  import os, subprocess, shutil, textwrap
2
  import gradio as gr
3
 
4
- CLI_JAR = "psl-cli-3.0.1.jar" # <-- use this exact jar name
5
-
6
  # --- Utilities ---------------------------------------------------------------
7
 
8
  def ensure_java_env():
@@ -99,47 +97,6 @@ def psl_health_check():
99
  out.append("pslpython import FAILED ❌")
100
  out.append(repr(e))
101
 
102
- # 4) PSL CLI jar available and working?
103
- if os.path.exists(CLI_JAR):
104
- out.append(f">>> java -jar {CLI_JAR} --help (first 10 lines)")
105
- out.append(run(["bash","-lc",f"java -jar {CLI_JAR} --help | head -n 10"]))
106
- else:
107
- out.append(f"{CLI_JAR} not found (skip). Add a postBuild to download it if you need CLI.")
108
-
109
- return "\n".join(out)
110
-
111
- def psl_toy_infer():
112
- ensure_java_env()
113
- out = []
114
-
115
- if not os.path.exists(CLI_JAR):
116
- return (
117
- f"{CLI_JAR} not found in repo root.\n"
118
- "Add a postBuild that downloads it, e.g.:\n"
119
- "curl -L -o psl-cli-3.0.1.jar "
120
- "https://repo1.maven.org/maven2/org/linqs/psl-cli/3.0.1/psl-cli-3.0.1.jar\n"
121
- )
122
-
123
- # Clean any previous outputs
124
- if os.path.isdir("inferred-predicates"):
125
- shutil.rmtree("inferred-predicates", ignore_errors=True)
126
-
127
- write_top_level_files()
128
-
129
- out.append(">>> Running toy inference with PSL CLI")
130
- cmd = f"java -jar {CLI_JAR} --infer --model model.psl --data model.data --output ."
131
- out.append(f"$ {cmd}")
132
- out.append(run(["bash","-lc", cmd]))
133
-
134
- # Show results if produced
135
- pred_path = "inferred-predicates/FRIEND.txt"
136
- if os.path.exists(pred_path):
137
- out.append(f"=== {pred_path} ===")
138
- out.append(run(["bash","-lc", f"cat {pred_path}"]))
139
- else:
140
- out.append("No FRIEND.txt produced. Check the CLI output above for parsing errors.")
141
-
142
- return "\n".join(out)
143
 
144
  # --- Gradio UI ---------------------------------------------------------------
145
 
@@ -147,11 +104,10 @@ with gr.Blocks() as demo:
147
  gr.Markdown("# PSL setup check & toy inference (top-level files)")
148
  with gr.Row():
149
  btn_health = gr.Button("Run health check")
150
- btn_demo = gr.Button("Run toy inference")
151
  out = gr.Textbox(lines=32, label="Output", show_copy_button=True)
152
 
153
  btn_health.click(fn=psl_health_check, outputs=out)
154
- btn_demo.click(fn=psl_toy_infer, outputs=out)
155
 
156
  if __name__ == "__main__":
157
  demo.launch()
 
1
  import os, subprocess, shutil, textwrap
2
  import gradio as gr
3
 
 
 
4
  # --- Utilities ---------------------------------------------------------------
5
 
6
  def ensure_java_env():
 
97
  out.append("pslpython import FAILED ❌")
98
  out.append(repr(e))
99
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100
 
101
  # --- Gradio UI ---------------------------------------------------------------
102
 
 
104
  gr.Markdown("# PSL setup check & toy inference (top-level files)")
105
  with gr.Row():
106
  btn_health = gr.Button("Run health check")
107
+
108
  out = gr.Textbox(lines=32, label="Output", show_copy_button=True)
109
 
110
  btn_health.click(fn=psl_health_check, outputs=out)
 
111
 
112
  if __name__ == "__main__":
113
  demo.launch()