-
Notifications
You must be signed in to change notification settings - Fork 4
Add FastAPI server and visualization for SimpleAudit results #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| """ | ||
| CLI interface for SimpleAudit tools. | ||
| """ | ||
| import argparse | ||
| import sys | ||
|
|
||
|
|
||
| def main(): | ||
| """Main entry point for simpleaudit CLI.""" | ||
| parser = argparse.ArgumentParser( | ||
| prog="simpleaudit", | ||
| description="SimpleAudit CLI - AI Safety Auditing Tools" | ||
| ) | ||
|
|
||
| subparsers = parser.add_subparsers(dest="command", help="Available commands") | ||
|
|
||
| # Serve command | ||
| serve_parser = subparsers.add_parser( | ||
| "serve", | ||
| help="Start a web server to visualize audit results" | ||
| ) | ||
| serve_parser.add_argument( | ||
| "--results_dir", | ||
| type=str, | ||
| default=None, | ||
| help="Directory containing JSON result files to visualize (default: current directory)" | ||
| ) | ||
| serve_parser.add_argument( | ||
| "--port", | ||
| type=int, | ||
| default=8000, | ||
| help="Port to run the server on (default: 8000)" | ||
| ) | ||
| serve_parser.add_argument( | ||
| "--host", | ||
| type=str, | ||
| default="127.0.0.1", | ||
| help="Host to bind the server to (default: 127.0.0.1)" | ||
| ) | ||
|
|
||
| args = parser.parse_args() | ||
|
|
||
| if args.command == "serve": | ||
| from .visualization.server import start_server | ||
|
|
||
| # Default to current directory if not specified | ||
| results_dir = args.results_dir | ||
| if results_dir is None: | ||
| results_dir = "." | ||
| print("⚠️ Warning: --results_dir not specified, using current directory '.'") | ||
| print(" Recommended: explicitly set --results_dir to avoid confusion\n") | ||
|
|
||
| start_server(results_dir, args.host, args.port) | ||
| else: | ||
| parser.print_help() | ||
| sys.exit(1) | ||
|
Comment on lines
+8
to
+56
|
||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
simpleaudit servewill import the visualization server unconditionally; if users installed the base package without thevisualizeextra, this will raise ImportError for fastapi/uvicorn. Catch that import error and print a clear message telling the user to installsimpleaudit[visualize].