Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion bin/generate-component-manifest-dagger.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@

set -e

pip install dagger-io==0.13.3
python bin/generate_component_manifest_files.py
10 changes: 9 additions & 1 deletion debug_manifest/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,19 @@ To configure the debugger in VSCode to run the `debug_manifest`, follow these st
"request": "launch",
"console": "integratedTerminal",
"cwd": "${workspaceFolder}/debug_manifest",
"python": "<PATH_TO_CDK_ENV>/bin/python",
"python": "<PATH_TO_CDK_ENV>/bin/python", // REPLACE ME
"module": "debug_manifest",
"args": [
// SPECIFY THE COMMAND: [spec, check, discover, read]
"read",
// SPECIFY THE MANIFEST FILE
"--manifest-path",
// PATH TO THE MANIFEST FILE
"resources/manifest.yaml",
// SPECIFY A COMPONENTS.PY FILE (OPTIONAL)
"--components-path",
// PATH TO THE COMPONENTS FILE
"resources/components.py",
// SPECIFY THE CONFIG
"--config",
// PATH TO THE CONFIG FILE
Expand Down
37 changes: 31 additions & 6 deletions debug_manifest/debug_manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,59 @@
#

import sys
from typing import Any, Mapping

from airbyte_cdk.entrypoint import AirbyteEntrypoint, 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)

def _register_components_from_file(filepath: str) -> None:
"""Load and register components from a Python file specified in the args."""
import importlib.util
import sys
from pathlib import Path

components_path = Path(filepath)

module_name = "components"
sdm_module_name = "source_declarative_manifest.components"

# Create module spec
spec = importlib.util.spec_from_file_location(module_name, components_path)
if spec is None or spec.loader is None:
raise ImportError(f"Could not load module from {components_path}")

# Create module and execute code, registering the module before executing its code
# To avoid issues with dataclasses that look up the module
module = importlib.util.module_from_spec(spec)
sys.modules[module_name] = module
sys.modules[sdm_module_name] = module

spec.loader.exec_module(module)


if __name__ == "__main__":
args = sys.argv[1:]
parsed_args = AirbyteEntrypoint.parse_args(args)

manifest_path = getattr(parsed_args, "manifest_path", None) or "resources/manifest.yaml"
components_path = getattr(parsed_args, "components_path", None)
if components_path:
_register_components_from_file(components_path)
catalog_path = AirbyteEntrypoint.extract_catalog(args)
config_path = AirbyteEntrypoint.extract_config(args)
state_path = AirbyteEntrypoint.extract_state(args)

debug_manifest(
YamlDeclarativeSource(
path_to_yaml="resources/manifest.yaml",
path_to_yaml=manifest_path,
catalog=YamlDeclarativeSource.read_catalog(catalog_path) if catalog_path else None,
config=YamlDeclarativeSource.read_config(config_path) if config_path else None,
state=YamlDeclarativeSource.read_state(state_path) if state_path else None,
Expand Down
Loading
Loading