Skip to content
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

Add more help in the singer template #816

Closed
cgardens opened this issue Nov 4, 2020 · 2 comments
Closed

Add more help in the singer template #816

cgardens opened this issue Nov 4, 2020 · 2 comments
Labels
type/enhancement New feature or request

Comments

@cgardens
Copy link
Contributor

cgardens commented Nov 4, 2020

Singer Template Currently produces this:

class SourceGoogleAdwordsSinger(SingerSource):
    def __init__(self):
        super().__init__()

    def check(self, logger: AirbyteLogger, config_container: ConfigContainer) -> AirbyteConnectionStatus:
        raise Exception("unimplemented")

    def discover_cmd(self, logger: AirbyteLogger, config_path: str) -> str:
        # discover the schema with the provided config
        raise Exception("unimplemented")

    def read_cmd(self, logger: AirbyteLogger, config_path: str, catalog_path: str, state_path: str = None) -> str:
        raise Exception("unimplemented")

But there's a bunch more boilerplate that we do the same each time. It's much faster to get to a correct state to copy and paste an existing integration's source.py than it is to use the generated by the template.

e.g. of existing

class SourceGithubSinger(SingerSource):
    def __init__(self):
        pass

    def check(self, logger, config_container) -> AirbyteConnectionStatus:
        try:
            json_config = config_container.rendered_config
            r = requests.get("https://api.github.com/repos/airbytehq/airbyte/commits", auth=(json_config["access_token"], ""))
            if r.status_code == 200:
                return AirbyteConnectionStatus(status=Status.SUCCEEDED)
            else:
                return AirbyteConnectionStatus(status=Status.FAILED, message=r.text)
        except Exception as e:
            return AirbyteConnectionStatus(status=Status.FAILED, message=f"{str(e)}")

    def discover_cmd(self, logger, config_path) -> str:
        return f"tap-github --config {config_path} --discover"

    def read_cmd(self, logger, config_path, catalog_path, state_path=None) -> str:
        config_option = f"--config {config_path}"
        properties_option = f"--properties {catalog_path}"
        state_option = f"--state {state_path}" if state_path else ""
        return f"tap-github {config_option} {properties_option} {state_option}"
@cgardens cgardens added the type/enhancement New feature or request label Nov 4, 2020
@ChristopheDuong
Copy link
Contributor

I think that's what is being introduced by the BaseSingerSource class

class BaseSingerSource(SingerSource):

@sherifnada was saying this is the transitioning state to that new abstraction

@cgardens
Copy link
Contributor Author

agreed. i think we can call this closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants