Spaces:
Sleeping
Sleeping
Commit
·
5c470da
1
Parent(s):
7703304
Fix app.py
Browse files
app.py
CHANGED
@@ -174,39 +174,40 @@ with gr.Blocks(title="Code Summarizer", theme=gr.themes.Soft()) as demo:
|
|
174 |
|
175 |
|
176 |
if __name__ == "__main__":
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
)
|
197 |
-
|
198 |
-
try:
|
199 |
-
args = parser.parse_args()
|
200 |
-
log.info("Running in CLI mode.")
|
201 |
-
run_pipeline(
|
202 |
-
repo_url=args.url,
|
203 |
-
skip_existing=args.skip_existing,
|
204 |
-
save_local=not args.no_save
|
205 |
)
|
206 |
-
except SystemExit as e:
|
207 |
-
# Exit triggered by argparse on error (e.g., missing --url)
|
208 |
-
if e.code != 0: # Don't log error for --help etc.
|
209 |
-
log.error(f"Argument parsing error (Exit Code: {e.code}). Ensure --url is provided for CLI mode.")
|
210 |
-
sys.exit(e.code)
|
211 |
|
212 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
174 |
|
175 |
|
176 |
if __name__ == "__main__":
|
177 |
+
if len(sys.argv) > 1 and "--url" in sys.argv:
|
178 |
+
parser = argparse.ArgumentParser(
|
179 |
+
description="Code Summarizer CLI.",
|
180 |
+
formatter_class=argparse.ArgumentDefaultsHelpFormatter
|
181 |
+
)
|
182 |
+
parser.add_argument(
|
183 |
+
"--url",
|
184 |
+
required=True,
|
185 |
+
help="HTTPS URL of the public GitHub repository."
|
186 |
+
)
|
187 |
+
parser.add_argument(
|
188 |
+
"--skip_existing",
|
189 |
+
action="store_true",
|
190 |
+
help="Skip if repo already summarized in Firebase."
|
191 |
+
)
|
192 |
+
parser.add_argument(
|
193 |
+
"--no_save",
|
194 |
+
action="store_true",
|
195 |
+
help="Disable saving local summaries.json."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
196 |
)
|
|
|
|
|
|
|
|
|
|
|
197 |
|
198 |
+
try:
|
199 |
+
args = parser.parse_args()
|
200 |
+
log.info("Running in CLI mode.")
|
201 |
+
run_pipeline(
|
202 |
+
repo_url=args.url,
|
203 |
+
skip_existing=args.skip_existing,
|
204 |
+
save_local=not args.no_save
|
205 |
+
)
|
206 |
+
except SystemExit as e:
|
207 |
+
if e.code != 0:
|
208 |
+
log.error(f"Argument parsing error (Exit Code: {e.code}). Ensure --url is provided for CLI mode.")
|
209 |
+
sys.exit(e.code)
|
210 |
+
else:
|
211 |
+
# No CLI args → launch Gradio
|
212 |
+
log.info("Launching Gradio UI...")
|
213 |
+
demo.launch()
|