@@ -70,7 +70,9 @@ <h1>Airbyte CDK WASM Compatibility Test</h1>
7070 Initializing Pyodide...
7171 </ div >
7272
73- < button id ="runTest " onclick ="runCDKTest() " disabled > Run CDK Test</ button >
73+ < button id ="setupCDK " onclick ="setupCDK() " disabled > Set up CDK</ button >
74+ < button id ="testSpec " onclick ="testSpec() " disabled > Test SPEC</ button >
75+ < button id ="testRead " onclick ="testRead() " disabled > Test Read</ button >
7476
7577 < div class ="container ">
7678 < h3 > Test Output:</ h3 >
@@ -81,17 +83,19 @@ <h3>Test Output:</h3>
8183 < h3 > Test Details:</ h3 >
8284 < p > This test will:</ p >
8385 < ol >
84- < li > Install the airbyte-cdk package using micropip </ li >
85- < li > Download the PokeAPI manifest and catalog files </ li >
86- < li > Run the declarative source CLI commands </ li >
86+ < li > Click "Set up CDK" to install the airbyte-cdk package and download test files </ li >
87+ < li > Click "Test SPEC" to run the declarative source spec command </ li >
88+ < li > Click "Test Read" to run the declarative source read command </ li >
8789 </ ol >
8890 </ div >
8991 </ div >
9092
9193 < script >
9294 const output = document . getElementById ( "output" ) ;
9395 const status = document . getElementById ( "status" ) ;
94- const runButton = document . getElementById ( "runTest" ) ;
96+ const setupButton = document . getElementById ( "setupCDK" ) ;
97+ const specButton = document . getElementById ( "testSpec" ) ;
98+ const readButton = document . getElementById ( "testRead" ) ;
9599
96100 function addToOutput ( text ) {
97101 output . textContent += text + "\n" ;
@@ -110,7 +114,7 @@ <h3>Test Details:</h3>
110114 window . pyodide = await loadPyodide ( ) ;
111115
112116 updateStatus ( "Pyodide loaded successfully!" , "success" ) ;
113- runButton . disabled = false ;
117+ setupButton . disabled = false ;
114118 addToOutput ( "✓ Pyodide initialized successfully" ) ;
115119 addToOutput ( "✓ Python version: " + pyodide . runPython ( "import sys; sys.version" ) ) ;
116120 addToOutput ( "✓ Platform: " + pyodide . runPython ( "import sys; sys.platform" ) ) ;
@@ -121,6 +125,205 @@ <h3>Test Details:</h3>
121125 }
122126 }
123127
128+ async function setupCDK ( ) {
129+ try {
130+ setupButton . disabled = true ;
131+ updateStatus ( "Setting up CDK..." , "loading" ) ;
132+ addToOutput ( "\n" + "=" . repeat ( 50 ) ) ;
133+ addToOutput ( "Starting Airbyte CDK setup" ) ;
134+ addToOutput ( "=" . repeat ( 50 ) ) ;
135+
136+ // Install required packages
137+ addToOutput ( "\n1. Installing packages..." ) ;
138+ await pyodide . loadPackage ( "micropip" ) ;
139+ addToOutput ( "✓ micropip loaded successfully" ) ;
140+ await pyodide . loadPackage ( "ssl" ) ;
141+ addToOutput ( "✓ ssl loaded successfully" ) ;
142+ await pyodide . runPython ( `
143+ import pyodide
144+ # pyodide.loadPackage("micropip");
145+ import micropip
146+ micropip.install(
147+ "https://files.pythonhosted.org/packages/e6/63/b1d16101e54a65af9f0cea700447563876f3bb1a1cc8a71da48271aa7869/airbyte_cdk-6.60.0.post22.dev16503405621-py3-none-any.whl",
148+ keep_going=True,
149+ )
150+ ` ) ;
151+ addToOutput ( "✓ airbyte-cdk installed successfully" ) ;
152+
153+ // Download test files
154+ addToOutput ( "\n2. Downloading test files..." ) ;
155+ const downloadsResult = await pyodide . runPython ( `
156+ import pathlib
157+ from pyodide.http import open_url
158+
159+ # Download catalog
160+ catalog_url = "https://raw.githubusercontent.com/airbytehq/airbyte/refs/heads/master/airbyte-integrations/connectors/source-pokeapi/integration_tests/configured_catalog.json"
161+ catalog_content = open_url(catalog_url).read()
162+ pathlib.Path("catalog.json").write_text(catalog_content)
163+ print("✓ Downloaded catalog.json")
164+
165+ # Download manifest
166+ manifest_url = "https://raw.githubusercontent.com/airbytehq/airbyte/refs/heads/master/airbyte-integrations/connectors/source-pokeapi/manifest.yaml"
167+ manifest_content = open_url(manifest_url).read()
168+ pathlib.Path("manifest.yaml").write_text(manifest_content)
169+ print("✓ Downloaded manifest.yaml")
170+
171+ # Create config
172+ config_content = '{"pokemon_name": "pikachu"}'
173+ pathlib.Path("config.json").write_text(config_content)
174+ print("✓ Created config.json")
175+
176+ "All files downloaded and created successfully!"
177+ ` ) ;
178+ addToOutput ( downloadsResult ) ;
179+
180+ addToOutput ( "\n" + "=" . repeat ( 50 ) ) ;
181+ addToOutput ( "CDK setup completed!" ) ;
182+ addToOutput ( "=" . repeat ( 50 ) ) ;
183+
184+ updateStatus ( "CDK setup completed successfully!" , "success" ) ;
185+ specButton . disabled = false ;
186+ readButton . disabled = false ;
187+
188+ } catch ( error ) {
189+ addToOutput ( "✗ Setup failed with error: " + error . message ) ;
190+ updateStatus ( "Setup failed: " + error . message , "error" ) ;
191+ } finally {
192+ setupButton . disabled = false ;
193+ }
194+ }
195+
196+ async function testSpec ( ) {
197+ try {
198+ specButton . disabled = true ;
199+ updateStatus ( "Testing SPEC command..." , "loading" ) ;
200+
201+ // Test CDK CLI functionality
202+ addToOutput ( "\n" + "=" . repeat ( 30 ) ) ;
203+ addToOutput ( "Testing 'spec' functionality..." ) ;
204+ addToOutput ( "=" . repeat ( 30 ) ) ;
205+
206+ const specResult = await pyodide . runPython ( `
207+ import sys
208+ from io import StringIO
209+ from airbyte_cdk.cli.source_declarative_manifest import run
210+
211+ try:
212+ # Test the CLI with a simple command first
213+ print("Testing 'spec' command...", file=sys.stderr)
214+ # Capture both stdout and stderr
215+ old_stdout = sys.stdout
216+ old_stderr = sys.stderr
217+ captured_stdout = StringIO()
218+ captured_stderr = StringIO()
219+
220+ sys.stdout = captured_stdout
221+ sys.stderr = captured_stderr
222+
223+ args = [
224+ "spec",
225+ "--manifest-path",
226+ "manifest.yaml",
227+ "--config",
228+ "config.json",
229+ "--catalog",
230+ "catalog.json",
231+ ]
232+
233+ # Run the CLI
234+ run(args)
235+
236+ result = "✓ CLI executed successfully"
237+
238+ except Exception as e:
239+ result = f"✗ CLI execution failed: {str(e)}"
240+ import traceback
241+ result += f"\\nTraceback: {traceback.format_exc()}"
242+ finally:
243+ # Get captured output
244+ stdout_content = captured_stdout.getvalue()
245+ stderr_content = captured_stderr.getvalue()
246+
247+ result = "✓ CLI executed successfully\\n"
248+ if stdout_content:
249+ result += f"STDOUT:\\n{stdout_content}\\n"
250+ if stderr_content:
251+ result += f"STDERR:\\n{stderr_content}\\n"
252+
253+ # Restore original stdout/stderr
254+ sys.stdout = old_stdout
255+ sys.stderr = old_stderr
256+
257+ result
258+ ` ) ;
259+ addToOutput ( specResult ) ;
260+
261+ updateStatus ( "SPEC test completed successfully!" , "success" ) ;
262+
263+ } catch ( error ) {
264+ addToOutput ( "✗ SPEC test failed with error: " + error . message ) ;
265+ updateStatus ( "SPEC test failed: " + error . message , "error" ) ;
266+ } finally {
267+ specButton . disabled = false ;
268+ }
269+ }
270+
271+ async function testRead ( ) {
272+ try {
273+ readButton . disabled = true ;
274+ updateStatus ( "Testing READ command..." , "loading" ) ;
275+
276+ addToOutput ( "\n" + "=" . repeat ( 30 ) ) ;
277+ addToOutput ( "Testing 'read' functionality..." ) ;
278+ addToOutput ( "=" . repeat ( 30 ) ) ;
279+
280+ const readResult = await pyodide . runPython ( `
281+ import sys
282+ from io import StringIO
283+ from airbyte_cdk.cli.source_declarative_manifest import run
284+
285+ # # Capture stdout
286+ # old_stdout = sys.stdout
287+ # sys.stdout = captured_output = StringIO()
288+
289+ try:
290+ # Test the CLI with a simple command first
291+ print("Testing 'read' command...", file=sys.stderr)
292+
293+ args = [
294+ "read",
295+ "--manifest-path",
296+ "manifest.yaml",
297+ "--config",
298+ "config.json",
299+ "--catalog",
300+ "catalog.json",
301+ ]
302+
303+ # Run the CLI
304+ run(args)
305+
306+ result = "✓ CLI executed successfully"
307+
308+ except Exception as e:
309+ result = f"✗ CLI execution failed: {str(e)}"
310+ import traceback
311+ result += f"\\nTraceback: {traceback.format_exc()}"
312+
313+ result
314+ ` ) ;
315+ addToOutput ( readResult ) ;
316+
317+ updateStatus ( "READ test completed successfully!" , "success" ) ;
318+
319+ } catch ( error ) {
320+ addToOutput ( "✗ READ test failed with error: " + error . message ) ;
321+ updateStatus ( "READ test failed: " + error . message , "error" ) ;
322+ } finally {
323+ readButton . disabled = false ;
324+ }
325+ }
326+
124327 async function runCDKTest ( ) {
125328 try {
126329 runButton . disabled = true ;
@@ -272,13 +475,8 @@ <h3>Test Details:</h3>
272475 addToOutput ( "WASM compatibility test completed!" ) ;
273476 addToOutput ( "=" . repeat ( 50 ) ) ;
274477
275- updateStatus ( "Test completed successfully!" , "success" ) ;
276-
277- } catch ( error ) {
278- addToOutput ( "✗ Test failed with error: " + error . message ) ;
279- updateStatus ( "Test failed: " + error . message , "error" ) ;
280478 } finally {
281- runButton . disabled = false ;
479+ readButton . disabled = false ;
282480 }
283481 }
284482
0 commit comments