|
1 | 1 | # Copyright (c) 2025 Airbyte, Inc., all rights reserved. |
2 | 2 | """Standalone CLI for the Airbyte CDK Manifest Runner. |
3 | 3 |
|
4 | | -This CLI provides commands for running and managing the FastAPI-based manifest runner server. |
| 4 | +This CLI provides commands for running and managing the manifest runner server. |
5 | 5 |
|
6 | 6 | **Installation:** |
7 | 7 |
|
|
22 | 22 | ``` |
23 | 23 | """ |
24 | 24 |
|
25 | | -import sys |
26 | | -from typing import Optional |
27 | | - |
28 | 25 | import rich_click as click |
29 | 26 |
|
30 | | -# Import server dependencies with graceful fallback |
31 | | -try: |
32 | | - import fastapi |
33 | | - import uvicorn |
34 | | - |
35 | | - FASTAPI_AVAILABLE = True |
36 | | -except ImportError: |
37 | | - FASTAPI_AVAILABLE = False |
38 | | - fastapi = None |
39 | | - uvicorn = None |
40 | | - |
41 | | - |
42 | | -def _check_manifest_runner_dependencies() -> None: |
43 | | - """Check if manifest-runner dependencies are installed.""" |
44 | | - if not FASTAPI_AVAILABLE: |
45 | | - click.echo( |
46 | | - "❌ Manifest runner dependencies not found. Please install with:\n\n" |
47 | | - " pip install airbyte-cdk[manifest-runner]\n" |
48 | | - " # or\n" |
49 | | - " poetry install --extras manifest-runner\n", |
50 | | - err=True, |
51 | | - ) |
52 | | - sys.exit(1) |
| 27 | +from ._info import info |
| 28 | +from ._openapi import generate_openapi |
| 29 | +from ._start import start |
53 | 30 |
|
54 | 31 |
|
55 | 32 | @click.group( |
56 | 33 | help=__doc__.replace("\n", "\n\n"), # Render docstring as help text (markdown) |
57 | 34 | invoke_without_command=True, |
58 | 35 | ) |
59 | | -@click.option( |
60 | | - "--version", |
61 | | - is_flag=True, |
62 | | - help="Show the version of the Airbyte CDK Manifest Runner.", |
63 | | -) |
64 | 36 | @click.pass_context |
65 | 37 | def cli( |
66 | 38 | ctx: click.Context, |
67 | | - version: bool, |
68 | 39 | ) -> None: |
69 | | - """Airbyte CDK Manifest Runner CLI.""" |
70 | | - if version: |
71 | | - click.echo("Airbyte CDK Manifest Runner v1.0.0") |
72 | | - ctx.exit() |
| 40 | + """Airbyte Manifest Runner CLI.""" |
73 | 41 |
|
74 | 42 | if ctx.invoked_subcommand is None: |
75 | 43 | # If no subcommand is provided, show the help message. |
76 | 44 | click.echo(ctx.get_help()) |
77 | 45 | ctx.exit() |
78 | 46 |
|
79 | 47 |
|
80 | | -@cli.command() |
81 | | -@click.option( |
82 | | - "--host", |
83 | | - default="127.0.0.1", |
84 | | - help="Host to bind the server to", |
85 | | - show_default=True, |
86 | | -) |
87 | | -@click.option( |
88 | | - "--port", |
89 | | - default=8000, |
90 | | - help="Port to bind the server to", |
91 | | - show_default=True, |
92 | | -) |
93 | | -@click.option( |
94 | | - "--reload", |
95 | | - is_flag=True, |
96 | | - help="Enable auto-reload for development", |
97 | | -) |
98 | | -def start(host: str, port: int, reload: bool) -> None: |
99 | | - """Start the FastAPI manifest runner server.""" |
100 | | - _check_manifest_runner_dependencies() |
101 | | - |
102 | | - # Import and use the main server function |
103 | | - from airbyte_cdk.manifest_runner.main import run_server |
104 | | - |
105 | | - run_server( |
106 | | - host=host, |
107 | | - port=port, |
108 | | - reload=reload, |
109 | | - ) |
110 | | - |
111 | | - |
112 | | -@cli.command() |
113 | | -def info() -> None: |
114 | | - """Show manifest runner information and status.""" |
115 | | - if FASTAPI_AVAILABLE: |
116 | | - click.echo("✅ Manifest runner dependencies are installed") |
117 | | - click.echo(f" FastAPI version: {fastapi.__version__}") |
118 | | - click.echo(f" Uvicorn version: {uvicorn.__version__}") |
119 | | - else: |
120 | | - click.echo("❌ Manifest runner dependencies not installed") |
121 | | - click.echo(" Install with: pip install airbyte-cdk[manifest-runner]") |
| 48 | +cli.add_command(start) |
| 49 | +cli.add_command(info) |
| 50 | +cli.add_command(generate_openapi) |
122 | 51 |
|
123 | 52 |
|
124 | 53 | def run() -> None: |
|
0 commit comments