Skip to content

Commit 856ad46

Browse files
feat(connector-insights): track manifest usage of $parameters and custom component classes (#43036)
Co-authored-by: Octavia Squidington III <[email protected]>
1 parent 7b65691 commit 856ad46

File tree

10 files changed

+281
-218
lines changed

10 files changed

+281
-218
lines changed

airbyte-ci/connectors/connectors_insights/README.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ connectors-insights generate --output-directory <path-to-local-output-dir> --gcs
2525
### CLI Options
2626

2727
- `generate`: The command to generate the artifacts.
28-
28+
2929
- `-o, --output-dir`: Specifies the local directory where the generated artifacts will be saved. In this example, artifacts are saved to `/Users/augustin/Desktop/insights`.
3030

3131
- `-g, --gcs-uri`: The Google Cloud Storage (GCS) URI prefix where the artifacts will be uploaded. In the form: `gs://<bucket>/<key-prefix>`.
@@ -56,6 +56,9 @@ This CLI is currently running nightly in GitHub Actions. The workflow can be fou
5656

5757
## Changelog
5858

59+
### 0.3.0
60+
Adding `manifest_uses_parameters`, `manifest_uses_custom_components`, and `manifest_custom_components_classes` insights.
61+
5962
### 0.2.4
6063
Do not generate insights for `*-scaffold-*` and `*-strict-encrypt` connectors.
6164

airbyte-ci/connectors/connectors_insights/poetry.lock

+252-209
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

airbyte-ci/connectors/connectors_insights/pyproject.toml

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "connectors-insights"
3-
version = "0.2.4"
3+
version = "0.3.0"
44
description = ""
55
authors = ["Airbyte <[email protected]>"]
66
readme = "README.md"
@@ -31,6 +31,9 @@ mypy = "^1.8.0"
3131
types-requests = "^2.32.0.20240602"
3232
types-beautifulsoup4 = "^4.12.0.20240511"
3333

34+
[tool.ruff]
35+
line-length = 140
36+
3437
[tool.ruff.lint]
3538
select = ["F"]
3639

airbyte-ci/connectors/connectors_insights/src/connectors_insights/cli.py

-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ async def generate(
8383
concurrency: int,
8484
rewrite: bool,
8585
) -> None:
86-
8786
logger = logging.getLogger(__name__)
8887
result_backends: List[ResultBackend] = []
8988
if output_directory:

airbyte-ci/connectors/connectors_insights/src/connectors_insights/insights.py

+15-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# Copyright (c) 2024 Airbyte, Inc., all rights reserved.
2-
32
from __future__ import annotations
43

54
import datetime
@@ -14,6 +13,7 @@
1413
from connectors_insights.pylint import get_pylint_output
1514
from connectors_insights.result_backends import FileToPersist, ResultBackend
1615
from connectors_insights.sbom import get_json_sbom
16+
from typing_extensions import Mapping
1717

1818
if TYPE_CHECKING:
1919
from typing import Dict, List, Tuple
@@ -23,6 +23,19 @@
2323
from connector_ops.utils import Connector # type: ignore
2424

2525

26+
def get_manifest_inferred_insights(connector: Connector) -> dict:
27+
manifest = connector.manifest_path.read_text()
28+
29+
schemas_directory = connector.code_path / connector.technical_name.replace("-", "_") / "schemas"
30+
31+
return {
32+
"manifest_uses_parameters": manifest.find("$parameters") != -1,
33+
"manifest_uses_custom_components": manifest.find("class_name:") != -1,
34+
"manifest_custom_component_classes": re.findall(r"class_name: (.+)", manifest),
35+
"has_json_schemas": schemas_directory.is_dir() and any(schemas_directory.iterdir()),
36+
}
37+
38+
2639
def get_metadata_inferred_insights(connector: Connector) -> Dict:
2740
return {
2841
"connector_technical_name": connector.technical_name,
@@ -155,6 +168,7 @@ def generate_insights(connector: Connector, sbom: str | None, pylint_output: str
155168
return ConnectorInsights(
156169
**{
157170
**get_metadata_inferred_insights(connector),
171+
**get_manifest_inferred_insights(connector),
158172
**get_pylint_inferred_insights(pylint_output),
159173
**get_sbom_inferred_insights(sbom, connector),
160174
"ci_on_master_report": ci_on_master_report,

airbyte-ci/connectors/connectors_insights/src/connectors_insights/models.py

+4
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ class ConnectorInsights(BaseModel):
3434
deprecated_classes_in_use: list[str] | None
3535
deprecated_modules_in_use: list[str] | None
3636
forbidden_method_names_in_use: list[str] | None
37+
manifest_uses_parameters: StrictBool
38+
manifest_uses_custom_components: StrictBool
39+
manifest_custom_component_classes: list[str] | None
40+
has_json_schemas: StrictBool
3741

3842
class Config:
3943
json_encoders = {dict: lambda v: json.dumps(v, default=pydantic_encoder)}

airbyte-ci/connectors/connectors_insights/src/connectors_insights/pylint.py

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
from connectors_insights.utils import never_fail_exec
1111

1212
if TYPE_CHECKING:
13-
1413
import dagger
1514
from connector_ops.utils import Connector # type: ignore
1615

airbyte-ci/connectors/connectors_insights/src/connectors_insights/result_backends.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# Copyright (c) 2024 Airbyte, Inc., all rights reserved.
2-
32
from __future__ import annotations
43

54
import logging
@@ -65,7 +64,6 @@ def artifact_already_exists(self, connector: Connector, file_to_persist: FileToP
6564

6665

6766
class GCSBucket(ResultBackend):
68-
6967
DEFAULT_GCP_PROJECT = "prod-ab-cloud-proj"
7068

7169
def __init__(self, bucket_name: str, key_prefix: str, gcp_project: str = DEFAULT_GCP_PROJECT):

airbyte-ci/connectors/connectors_insights/src/connectors_insights/sbom.py

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
from typing import TYPE_CHECKING
77

88
if TYPE_CHECKING:
9-
109
import dagger
1110
from connector_ops.utils import Connector # type: ignore
1211

airbyte-ci/connectors/connectors_insights/src/connectors_insights/utils.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
from typing import TYPE_CHECKING
88

99
if TYPE_CHECKING:
10-
from typing import Set, Tuple, List, Callable
10+
from typing import Callable, List, Set, Tuple
11+
1112
from dagger import Container
1213

1314
from connector_ops.utils import METADATA_FILE_NAME, Connector # type: ignore

0 commit comments

Comments
 (0)