From 99488ddcc50fd16b8753019864e80b37b947a76d Mon Sep 17 00:00:00 2001 From: Augustin Date: Tue, 9 Jan 2024 16:30:49 +0100 Subject: [PATCH] airbyte-ci: fix assertion error on report existence (#33979) --- airbyte-ci/connectors/pipelines/README.md | 1 + .../pipelines/airbyte_ci/connectors/publish/context.py | 1 + .../pipelines/pipelines/airbyte_ci/metadata/pipeline.py | 9 ++++++--- .../pipelines/models/contexts/pipeline_context.py | 3 +-- airbyte-ci/connectors/pipelines/pyproject.toml | 2 +- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/airbyte-ci/connectors/pipelines/README.md b/airbyte-ci/connectors/pipelines/README.md index ad890b75397d..0eb970821c0b 100644 --- a/airbyte-ci/connectors/pipelines/README.md +++ b/airbyte-ci/connectors/pipelines/README.md @@ -521,6 +521,7 @@ E.G.: running `pytest` on a specific test folder: | Version | PR | Description | | ------- | ---------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------- | +| 3.1.1 | [#33979](https://github.com/airbytehq/airbyte/pull/33979) | Fix AssertionError on report existence again | | 3.1.0 | [#33994](https://github.com/airbytehq/airbyte/pull/33994) | Log more context information in CI. | | 3.0.2 | [#33987](https://github.com/airbytehq/airbyte/pull/33987) | Fix type checking issue when running --help | | 3.0.1 | [#33981](https://github.com/airbytehq/airbyte/pull/33981) | Fix issues with deploying dagster, pin pendulum version in dagster-cli install | diff --git a/airbyte-ci/connectors/pipelines/pipelines/airbyte_ci/connectors/publish/context.py b/airbyte-ci/connectors/pipelines/pipelines/airbyte_ci/connectors/publish/context.py index 5bd5a29f9175..a4471bac7eca 100644 --- a/airbyte-ci/connectors/pipelines/pipelines/airbyte_ci/connectors/publish/context.py +++ b/airbyte-ci/connectors/pipelines/pipelines/airbyte_ci/connectors/publish/context.py @@ -120,6 +120,7 @@ def create_slack_message(self) -> str: message += "🔴" message += f" {self.state.value['description']}\n" if self.state is ContextState.SUCCESSFUL: + assert self.report is not None, "Report should be set when state is successful" message += f"⏲️ Run duration: {format_duration(self.report.run_duration)}\n" if self.state is ContextState.FAILURE: message += "\ncc. " # @dev-connector-ops diff --git a/airbyte-ci/connectors/pipelines/pipelines/airbyte_ci/metadata/pipeline.py b/airbyte-ci/connectors/pipelines/pipelines/airbyte_ci/metadata/pipeline.py index 30a84d3337e2..eae516a8db79 100644 --- a/airbyte-ci/connectors/pipelines/pipelines/airbyte_ci/metadata/pipeline.py +++ b/airbyte-ci/connectors/pipelines/pipelines/airbyte_ci/metadata/pipeline.py @@ -164,6 +164,8 @@ async def run_metadata_orchestrator_deploy_pipeline( pipeline_start_timestamp: Optional[int], ci_context: Optional[str], ) -> bool: + success: bool = False + metadata_pipeline_context = PipelineContext( pipeline_name="Metadata Service Orchestrator Unit Test Pipeline", is_local=is_local, @@ -175,7 +177,6 @@ async def run_metadata_orchestrator_deploy_pipeline( pipeline_start_timestamp=pipeline_start_timestamp, ci_context=ci_context, ) - async with dagger.Connection(DAGGER_CONFIG) as dagger_client: metadata_pipeline_context.dagger_client = dagger_client.pipeline(metadata_pipeline_context.pipeline_name) @@ -196,9 +197,11 @@ async def run_metadata_orchestrator_deploy_pipeline( ], ] steps_results = await run_steps(steps) - metadata_pipeline_context.report = Report( + report = Report( pipeline_context=metadata_pipeline_context, steps_results=list(steps_results.values()), name="METADATA ORCHESTRATOR DEPLOY RESULTS", ) - return metadata_pipeline_context.report.success + metadata_pipeline_context.report = report + success = report.success + return success diff --git a/airbyte-ci/connectors/pipelines/pipelines/models/contexts/pipeline_context.py b/airbyte-ci/connectors/pipelines/pipelines/models/contexts/pipeline_context.py index 0495bfb01c69..83b1cb8e4b6d 100644 --- a/airbyte-ci/connectors/pipelines/pipelines/models/contexts/pipeline_context.py +++ b/airbyte-ci/connectors/pipelines/pipelines/models/contexts/pipeline_context.py @@ -149,8 +149,7 @@ def repo(self) -> GitRepository: return self.dagger_client.git(AIRBYTE_REPO_URL, keep_git_dir=True) @property - def report(self) -> Report | ConnectorReport: - assert self._report is not None, "The report was not set on this PipelineContext." + def report(self) -> Report | ConnectorReport | None: return self._report @report.setter diff --git a/airbyte-ci/connectors/pipelines/pyproject.toml b/airbyte-ci/connectors/pipelines/pyproject.toml index faf30e9fc8ad..d370f0a8e71b 100644 --- a/airbyte-ci/connectors/pipelines/pyproject.toml +++ b/airbyte-ci/connectors/pipelines/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api" [tool.poetry] name = "pipelines" -version = "3.1.0" +version = "3.1.1" description = "Packaged maintained by the connector operations team to perform CI for connectors' pipelines" authors = ["Airbyte "]