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

Connector Ops: Fix third party support in get_all_connectors_in_repo #31166

Merged
merged 4 commits into from
Oct 11, 2023

Conversation

bnchrch
Copy link
Contributor

@bnchrch bnchrch commented Oct 8, 2023

Problem

Third party pathing breaks get_all_connectors_in_repo and the Connector class

related to a comment from #30456

Solution

  1. Refactor Connector to take a relative path as its init argument
  2. Update technical name to be based off that relative path
  3. Update documentation paths to be based off documentation url
  4. Update type to be based off metadata
  5. Add tests to assert that all connectors returned by get_all_connectors_in_repo have metadata and docs
  6. Fix the appstore documentation path

@vercel
Copy link

vercel bot commented Oct 8, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
airbyte-docs ⬜️ Ignored (Inspect) Visit Preview Oct 10, 2023 7:39pm

@octavia-squidington-iii octavia-squidington-iii added the area/documentation Improvements or additions to documentation label Oct 8, 2023
@bnchrch bnchrch force-pushed the bnchrch/fix-third-party-support branch from 1d7f0d9 to d986431 Compare October 9, 2023 17:56
Base automatically changed from 09-14-change_our_python_connector_build_process_to_use_the_base_images to master October 10, 2023 17:16
@bnchrch bnchrch force-pushed the bnchrch/fix-third-party-support branch from 8bf1cc5 to 7a182d1 Compare October 10, 2023 19:07
@bnchrch bnchrch requested a review from a team October 10, 2023 19:10
Copy link
Contributor

@alafanechere alafanechere left a comment

Choose a reason for hiding this comment

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

LGTM, minor questions and suggestions. Thank you for this improvement!

def technical_name(self) -> str:
"""
Return the technical name of the connector from the given _relative_connector_path
e.g. source-google-sheets -> google-sheets or third-party/farosai/airbyte-pagerduty-source -> airbyte-pagerduty-source
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
e.g. source-google-sheets -> google-sheets or third-party/farosai/airbyte-pagerduty-source -> airbyte-pagerduty-source
e.g. source-google-sheets -> source-google-sheets or third-party/farosai/airbyte-pagerduty-source -> airbyte-pagerduty-source

@property
def name(self):
return self._get_type_and_name_from_technical_name()[1]

@property
def connector_type(self) -> str:
return self._get_type_and_name_from_technical_name()[0]
return self.metadata["connectorType"]
Copy link
Contributor

Choose a reason for hiding this comment

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

This question is outside the scope of this PR but I'm wondering if we should deserialize metadata with the metadata lib to interact with pydantic models instead of interacting with dict.


@property
def documentation_directory(self) -> Path:
if self.has_external_documentation:
return None
return Path(f"./docs/integrations/{self.connector_type}s")
Copy link
Contributor

Choose a reason for hiding this comment

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

This .docs is one of the reason why airbyte-ci is required to run from the repo root. For more flexibility we shall add a constant like GIT_REPO_ROOT = git.Repo(search_parent_directories=True) and build path from this root.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So I would have love to do this inside this PR but it got a bit big so I broke it out into this branch
#31409

Though it definately raises the question of if we would want to do this way....

The alternative is just having airbyte-ci set the working directory to the repo root 🤔

@@ -297,7 +317,7 @@ def icon_path(self) -> Path:

@property
def code_directory(self) -> Path:
return Path(f"./airbyte-integrations/connectors/{self.technical_name}")
return Path(f"./{CONNECTOR_PATH_PREFIX}/{self._relative_connector_path}")
Copy link
Contributor

Choose a reason for hiding this comment

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

Same suggestion as above: build the path from the GIT_REPO_ROOT

for connector in all_connectors:
assert isinstance(connector, utils.Connector)
assert connector.metadata is not None
assert connector.documentation_file_path.exists()
Copy link
Contributor

Choose a reason for hiding this comment

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

This test would fail if a connector does not have a doc. Do we want this lib test to fail in this scenario? At the moment missing doc would lead to a failing QA check. What do you think about asserting the documention path structure instead of checking its existence?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good call. I updated to check if a connector has an airbyte.com documentation url before running this check
#31324

@octavia-approvington octavia-approvington merged commit 625a4b1 into master Oct 11, 2023
@octavia-approvington octavia-approvington deleted the bnchrch/fix-third-party-support branch October 11, 2023 22:18
bnchrch added a commit that referenced this pull request Oct 11, 2023
@bnchrch bnchrch restored the bnchrch/fix-third-party-support branch October 11, 2023 22:24
@bnchrch
Copy link
Contributor Author

bnchrch commented Oct 11, 2023

Accidentally approved and merge.

( I cant believe I typed that)

I reverted the commit and reopened the PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants