-
Notifications
You must be signed in to change notification settings - Fork 31
fix: (CDK) (manifest-only) - add ability to debug manifest-only sources / destinations
#407
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
2970d9e
add
3834109
updated gitignore
d9c34e5
Update debug_manifest/README.md
f6ee5d2
Update debug_manifest/README.md
652146d
Update debug_manifest/README.md
d541824
Update debug_manifest/README.md
933c9dc
Merge branch 'main' into baz/cdk/add-manifest-only-debug-capabilities
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| # Ignore all resource files | ||
| resources/* | ||
|
|
||
| # But do not ignore .gitkeep files, to keep an empty `resources` directory | ||
| !resources/.gitkeep |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| # Configuring the Debugger | ||
|
|
||
| ## For VSCode | ||
|
|
||
| ### Set Up the debugger configuration (one-time setup step) | ||
| To configure the debugger in VSCode to run the `debug_manifest`, follow these steps: | ||
|
|
||
| 1. Clone or Open the existing `airbyte-python-cdk` project in VSCode. | ||
| 2. Click on the Run and Debug icon in the Activity Bar on the side of the window. | ||
| 3. Click on the `create a launch.json file` link to create a new configuration file. | ||
| 4. Select `Python` from the list of environments. | ||
| 5. Replace the contents of the generated `launch.json` file with the following configuration: | ||
|
|
||
| ```json | ||
| { | ||
| "version": "0.2.0", | ||
| "configurations": [ | ||
| { | ||
| "name": "Python: Debug Manifest", | ||
| "type": "debugpy", | ||
| "request": "launch", | ||
| "console": "integratedTerminal", | ||
| "cwd": "${workspaceFolder}/debug_manifest", | ||
| "python": "<PATH_TO_CDK_ENV>/bin/python", | ||
| "module": "debug_manifest", | ||
| "args": [ | ||
| // SPECIFY THE COMMAND: [spec, check, discover, read] | ||
| "read", | ||
| // SPECIFY THE CONFIG | ||
| "--config", | ||
| // PATH TO THE CONFIG FILE | ||
| "resources/config.json", | ||
| // SPECIFY THE CATALOG | ||
| "--catalog", | ||
| // PATH TO THE CATALOG FILE | ||
| "resources/catalog.json", | ||
| // SPECIFY THE STATE (optional) | ||
| // "--state", | ||
| // PATH TO THE STATE FILE | ||
| // "resources/state.json", | ||
| // ADDITIONAL FLAGS, like `--debug` (optional) | ||
| "--debug" | ||
| ], | ||
| } | ||
| ] | ||
| } | ||
| ``` | ||
|
|
||
| 6. Save the `launch.json` file. | ||
| 7. Install `CDK dependencies` by running `poetry install --all-extras` | ||
| 8. Replace the `"python": "<PATH_TO_CDK_ENV>/bin/python"` with the correct interpreter `PATH` pointing to the `CDK env` installed from Step `7` (use `which python` to have the complete python path), to wire the CDK env to the debugger. Alternatively you can swith the default interpreter you use in your IDE. | ||
|
|
||
| ### Set up the neccessary resources to use within the manifest-only connector | ||
bazarnov marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| * These resources are ignorred by `git`, in the `.gitignore`, thus should not be commited | ||
|
|
||
bazarnov marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| 1. Put the `config.json` inside the `/airbyte_cdk/debug_manifest/resources` (this will hold the `source input configuration`). | ||
| 2. Put the `catalog.json` inside the `/airbyte_cdk/debug_manifest/resources` (this will hold the `configured catalog` for the target source). | ||
| 3. Put the `manifest.yaml` inside the `/airbyte_cdk/debug_manifest/resources` | ||
| 4. (Optional) Put the `state.json` inside the `/airbyte_cdk/debug_manifest/resources` | ||
|
|
||
| ## Debuging Steps | ||
|
|
||
bazarnov marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| 1. Set any necessary breakpoints in your code, or `CDK` components code. | ||
| 2. Press `F5` / `Shift + CMD + D` / click the green play button in the `Run and Debug` view to start debugging. | ||
| 3. Iterate over the `2` and `3`, to debug your `manifest-only` source. | ||
|
|
||
| Basically, you're now able to run the `manifest-only` sources like the regular python source, with `spec`, `check`, `discover` and `read` commands, as well as having the `--debug` alongside. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| # | ||
| # Copyright (c) 2023 Airbyte, Inc., all rights reserved. | ||
| # | ||
|
|
||
| import sys | ||
| from typing import Any, Mapping | ||
|
|
||
| from airbyte_cdk.entrypoint import launch | ||
| from airbyte_cdk.sources.declarative.yaml_declarative_source import ( | ||
| YamlDeclarativeSource, | ||
| ) | ||
|
|
||
| configuration: Mapping[str, Any] = { | ||
| "path_to_yaml": "resources/manifest.yaml", | ||
| } | ||
|
|
||
|
|
||
| def debug_manifest(source: YamlDeclarativeSource, args: list[str]) -> None: | ||
| """ | ||
| Run the debug manifest with the given source and arguments. | ||
| """ | ||
| launch(source, args) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| debug_manifest( | ||
| YamlDeclarativeSource(**configuration), | ||
| sys.argv[1:], | ||
| ) |
Empty file.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.