From 221831afc12a6aa7d4c5e4be1f8acb357149a9fc Mon Sep 17 00:00:00 2001 From: Rene Cannao Date: Wed, 24 Dec 2025 06:00:39 +0000 Subject: [PATCH] Add usage examples to script documentation and help output Changes: 1. Add comprehensive usage examples to script docstring with: - Remote API example (requires API_KEY environment variable) - Local Ollama example (uses --local-ollama flag) - Both examples show all common command line options 2. Add epilog to argparse help with concise examples: - Shows minimal command line for both modes - Points to docstring for full examples - Uses RawDescriptionHelpFormatter for proper formatting Users now have multiple ways to access usage information: - Read script header with `head -50 scripts/process_posts_embeddings.py` - Run `python3 scripts/process_posts_embeddings.py --help` - Both show appropriate examples for remote API and local Ollama modes --- scripts/process_posts_embeddings.py | 40 ++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/scripts/process_posts_embeddings.py b/scripts/process_posts_embeddings.py index 3bd9513f1..cddfb495a 100755 --- a/scripts/process_posts_embeddings.py +++ b/scripts/process_posts_embeddings.py @@ -17,6 +17,30 @@ Prerequisites: For remote API: Environment variable API_KEY must be set for API authentication. For local Ollama: Use --local-ollama flag (no API_KEY required). If Posts_embeddings table doesn't exist, the script will fail. + +Usage Examples: + +1. Remote API (requires API_KEY environment variable): + export API_KEY='your-api-key' + python3 process_posts_embeddings.py \ + --host 127.0.0.1 \ + --port 6030 \ + --user root \ + --password root \ + --database main \ + --client-name posts-embed-client \ + --batch-size 10 + +2. Local Ollama server (no API_KEY required): + python3 process_posts_embeddings.py \ + --local-ollama \ + --host 127.0.0.1 \ + --port 6030 \ + --user root \ + --password root \ + --database main \ + --client-name posts-embed-client \ + --batch-size 10 """ import os @@ -28,8 +52,22 @@ from mysql.connector import Error def parse_args(): """Parse command line arguments.""" + epilog = """ +Usage Examples: + +1. Remote API (requires API_KEY environment variable): + export API_KEY='your-api-key' + python3 process_posts_embeddings.py --host 127.0.0.1 --port 6030 + +2. Local Ollama server (no API_KEY required): + python3 process_posts_embeddings.py --local-ollama --host 127.0.0.1 --port 6030 + +See script docstring for full examples with all options. +""" parser = argparse.ArgumentParser( - description='Process Posts table embeddings in ProxySQL SQLite3 server' + description='Process Posts table embeddings in ProxySQL SQLite3 server', + epilog=epilog, + formatter_class=argparse.RawDescriptionHelpFormatter ) parser.add_argument('--host', default='127.0.0.1', help='ProxySQL SQLite3 server host (default: 127.0.0.1)')