Skip to content

Commit 3a4bd1e

Browse files
committed
improve logging and parallelization
1 parent ab794c1 commit 3a4bd1e

File tree

1 file changed

+34
-4
lines changed
  • airbyte-ci/connectors/pipelines/pipelines/airbyte_ci/test

1 file changed

+34
-4
lines changed

airbyte-ci/connectors/pipelines/pipelines/airbyte_ci/test/commands.py

+34-4
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,38 @@
11
#
22
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
33
#
4+
from __future__ import annotations
45

56
import logging
67
from pathlib import Path
7-
from typing import List
8+
from typing import TYPE_CHECKING
89

910
import asyncclick as click
11+
import asyncer
1012
from pipelines.cli.click_decorators import click_ignore_unused_kwargs, click_merge_args_into_context_obj
1113
from pipelines.consts import DOCKER_VERSION
1214
from pipelines.helpers.utils import sh_dash_c
1315
from pipelines.models.contexts.click_pipeline_context import ClickPipelineContext, pass_pipeline_context
1416

17+
if TYPE_CHECKING:
18+
from typing import List, Tuple
19+
20+
import dagger
21+
22+
## HELPERS
23+
async def run_poetry_command(container: dagger.Container, command: str) -> Tuple[str, str]:
24+
"""Run a poetry command in a container and return the stdout and stderr.
25+
26+
Args:
27+
container (dagger.Container): The container to run the command in.
28+
command (str): The command to run.
29+
30+
Returns:
31+
Tuple[str, str]: The stdout and stderr of the command.
32+
"""
33+
container = container.with_exec(["poetry", "run", *command.split(" ")])
34+
return await container.stdout(), await container.stderr()
35+
1536

1637
@click.command()
1738
@click.argument("poetry_package_path")
@@ -89,6 +110,15 @@ async def test(pipeline_context: ClickPipelineContext):
89110
.with_env_variable("CI", str(pipeline_context.params["is_ci"]))
90111
.with_workdir(f"/airbyte/{poetry_package_path}")
91112
)
92-
for command in commands_to_run:
93-
test_container = test_container.with_exec(["poetry", "run", *command.split(" ")])
94-
await test_container
113+
114+
soon_command_executions_results = []
115+
async with asyncer.create_task_group() as poetry_commands_task_group:
116+
for command in commands_to_run:
117+
logger.info(f"Running command: {command}")
118+
soon_command_execution_result = poetry_commands_task_group.soonify(run_poetry_command)(test_container, command)
119+
soon_command_executions_results.append(soon_command_execution_result)
120+
121+
for result in soon_command_executions_results:
122+
stdout, stderr = result.value
123+
logger.info(stdout)
124+
logger.error(stderr)

0 commit comments

Comments
 (0)