Skip to content

🐙 octavia-cli: add generate for connections #10809

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 28 commits into from
Mar 9, 2022

Conversation

marcosmarxm
Copy link
Member

What

Describe what the change is solving
It helps to add screenshots if it affects the frontend.

How

Describe the solution

Recommended reading order

  1. x.java
  2. y.python

🚨 User Impact 🚨

Are there any breaking changes? What is the end result perceived by the user? If yes, please merge this PR with the 🚨🚨 emoji so changelog authors can further highlight this if needed.

Pre-merge Checklist

Expand the relevant checklist and delete the others.

New Connector

Community member or Airbyter

  • Community member? Grant edit access to maintainers (instructions)
  • Secrets in the connector's spec are annotated with airbyte_secret
  • Unit & integration tests added and passing. Community members, please provide proof of success locally e.g: screenshot or copy-paste unit, integration, and acceptance test output. To run acceptance tests for a Python connector, follow instructions in the README. For java connectors run ./gradlew :airbyte-integrations:connectors:<name>:integrationTest.
  • Code reviews completed
  • Documentation updated
    • Connector's README.md
    • Connector's bootstrap.md. See description and examples
    • docs/SUMMARY.md
    • docs/integrations/<source or destination>/<name>.md including changelog. See changelog example
    • docs/integrations/README.md
    • airbyte-integrations/builds.md
  • PR name follows PR naming conventions

Airbyter

If this is a community PR, the Airbyte engineer reviewing this PR is responsible for the below items.

  • Create a non-forked branch based on this PR and test the below items on it
  • Build is successful
  • Credentials added to Github CI. Instructions.
  • /test connector=connectors/<name> command is passing
  • New Connector version released on Dockerhub by running the /publish command described here
  • After the connector is published, connector added to connector index as described here
  • Seed specs have been re-generated by building the platform and committing the changes to the seed spec files, as described here
Updating a connector

Community member or Airbyter

  • Grant edit access to maintainers (instructions)
  • Secrets in the connector's spec are annotated with airbyte_secret
  • Unit & integration tests added and passing. Community members, please provide proof of success locally e.g: screenshot or copy-paste unit, integration, and acceptance test output. To run acceptance tests for a Python connector, follow instructions in the README. For java connectors run ./gradlew :airbyte-integrations:connectors:<name>:integrationTest.
  • Code reviews completed
  • Documentation updated
    • Connector's README.md
    • Connector's bootstrap.md. See description and examples
    • Changelog updated in docs/integrations/<source or destination>/<name>.md including changelog. See changelog example
  • PR name follows PR naming conventions

Airbyter

If this is a community PR, the Airbyte engineer reviewing this PR is responsible for the below items.

  • Create a non-forked branch based on this PR and test the below items on it
  • Build is successful
  • Credentials added to Github CI. Instructions.
  • /test connector=connectors/<name> command is passing
  • New Connector version released on Dockerhub by running the /publish command described here
  • After the new connector version is published, connector version bumped in the seed directory as described here
  • Seed specs have been re-generated by building the platform and committing the changes to the seed spec files, as described here
Connector Generator
  • Issue acceptance criteria met
  • PR name follows PR naming conventions
  • If adding a new generator, add it to the list of scaffold modules being tested
  • The generator test modules (all connectors with -scaffold in their name) have been updated with the latest scaffold by running ./gradlew :airbyte-integrations:connector-templates:generator:testScaffoldTemplates then checking in your changes
  • Documentation which references the generator is updated as needed

Tests

Unit

Put your unit tests output here.

Integration

Put your integration tests output here.

Acceptance

Put your acceptance tests output here.

@marcosmarxm marcosmarxm requested a review from alafanechere March 2, 2022 21:06
@marcosmarxm marcosmarxm temporarily deployed to more-secrets March 2, 2022 21:07 Inactive
@marcosmarxm marcosmarxm temporarily deployed to more-secrets March 2, 2022 21:07 Inactive
@marcosmarxm marcosmarxm temporarily deployed to more-secrets March 3, 2022 14:32 Inactive
@marcosmarxm marcosmarxm temporarily deployed to more-secrets March 3, 2022 14:32 Inactive
from airbyte_api_client.model.source_id_request_body import SourceIdRequestBody


class Connection:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry but I've a strong refacto suggestion 😄 :

  • I think that the class you describe here is not a Connection but a Catalog
  • I think that catalog should be attributes of sources (in the API discover_schema is called within the source endpoint: /v1/sources/discover_schema)
  • In the octavia apply PR I created Source objects (here)
  • My suggestion is to add a catalog attribute to the Source and publically expose this attribute, enabling this kind of interactions:
my_source = Source(api_client, ...)
my_source.catalog.streams

This will be a way to explicitly declare the dependency between a source (or destination) existence before generating the connection YAML file.
I think this also can lead to the following change of your command function (octavia generate connection):

octavia generate connection --source ./path/to/my/source.yaml --destination  ./path/to/my/destination.yaml my_connection_name

The command will do something like:

import octavia_cli.apply.resources

source = resources.factory(api_client, workspace_id, source_file_path)
destination = resources.factory(api_client, workspace_id, destination_file_path)
if not (source.was_created and destination.was_created):
  raise resources.NonExistingRessourceError("...")
connection_renderer = ConnectionRenderer(connection_name, source.resource_id, destination.resource_id, source.catalog.streams)
connection_renderer.write_yaml(".")

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha! Makes sense

Comment on lines 38 to 39
@click.argument("source_id", type=click.STRING)
@click.argument("destination_id", type=click.STRING)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that this command should rather take the source and destination YAML file path. I explain why in my next comment :)

Comment on lines 1 to 3
name: {{ resource_name }}
source_id: {{ source_id }}
destination_id: {{ destination_id }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
name: {{ resource_name }}
source_id: {{ source_id }}
destination_id: {{ destination_id }}
resource_name: mock_connection
definition_type: connection
source_id: mock_source
destination_id: mock_destination

Could you please try to mimic the top of the other template?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can create template composition with Jinja to make source_or_destination.yaml.j2 and connection.yaml.j2 share the same headers.

@marcosmarxm marcosmarxm temporarily deployed to more-secrets March 7, 2022 11:39 Inactive
@marcosmarxm marcosmarxm marked this pull request as ready for review March 7, 2022 12:51
@marcosmarxm marcosmarxm requested a review from alafanechere March 7, 2022 12:51
@marcosmarxm marcosmarxm temporarily deployed to more-secrets March 7, 2022 12:52 Inactive
@marcosmarxm marcosmarxm temporarily deployed to more-secrets March 7, 2022 12:52 Inactive
@alafanechere alafanechere temporarily deployed to more-secrets March 7, 2022 15:06 Inactive
@alafanechere alafanechere temporarily deployed to more-secrets March 7, 2022 15:06 Inactive
@alafanechere alafanechere temporarily deployed to more-secrets March 7, 2022 16:41 Inactive
@alafanechere alafanechere temporarily deployed to more-secrets March 7, 2022 16:41 Inactive
@marcosmarxm marcosmarxm changed the title octavia-cli: add generate for connections 🐙 octavia-cli: add generate for connections Mar 7, 2022
@alafanechere alafanechere temporarily deployed to more-secrets March 8, 2022 10:48 Inactive
@alafanechere alafanechere temporarily deployed to more-secrets March 8, 2022 10:48 Inactive
@alafanechere alafanechere temporarily deployed to more-secrets March 8, 2022 10:52 Inactive
@alafanechere alafanechere temporarily deployed to more-secrets March 8, 2022 10:52 Inactive
@alafanechere alafanechere temporarily deployed to more-secrets March 8, 2022 11:15 Inactive
@alafanechere alafanechere temporarily deployed to more-secrets March 8, 2022 11:15 Inactive
@alafanechere alafanechere temporarily deployed to more-secrets March 8, 2022 19:12 Inactive
@alafanechere alafanechere temporarily deployed to more-secrets March 8, 2022 19:13 Inactive
@alafanechere alafanechere temporarily deployed to more-secrets March 9, 2022 12:41 Inactive
@alafanechere alafanechere temporarily deployed to more-secrets March 9, 2022 12:41 Inactive
@alafanechere alafanechere temporarily deployed to more-secrets March 9, 2022 12:44 Inactive
@alafanechere alafanechere temporarily deployed to more-secrets March 9, 2022 12:44 Inactive
@alafanechere alafanechere temporarily deployed to more-secrets March 9, 2022 13:05 Inactive
@alafanechere alafanechere temporarily deployed to more-secrets March 9, 2022 13:05 Inactive
@marcosmarxm marcosmarxm merged commit 8f49e19 into master Mar 9, 2022
@marcosmarxm marcosmarxm deleted the marcos/octavia-generate-connection branch March 9, 2022 13:06
@alafanechere alafanechere linked an issue Mar 9, 2022 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🐙 octavia-cli: Generate YAML template file for connections
2 participants