-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Connector CI: Upload complete.json file on pipeline complete (#27051)
* Write complete.json file at end of run * Move state tranform * Move file_path_key logic into report * Use property decorator --------- Co-authored-by: Octavia Squidington III <octavia-squidington-iii@sers.noreply.github.com>
- Loading branch information
Showing
10 changed files
with
178 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
tools/ci_connector_ops/ci_connector_ops/pipelines/helpers/steps.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# | ||
# Copyright (c) 2023 Airbyte, Inc., all rights reserved. | ||
# | ||
"""The actions package is made to declare reusable pipeline components.""" | ||
|
||
from __future__ import annotations | ||
|
||
from typing import TYPE_CHECKING, List, Tuple, Union | ||
|
||
import asyncer | ||
from ci_connector_ops.pipelines.bases import Step, StepStatus | ||
|
||
if TYPE_CHECKING: | ||
from ci_connector_ops.pipelines.bases import StepResult | ||
|
||
|
||
async def run_steps( | ||
steps_and_run_args: List[Union[Step, Tuple[Step, Tuple]] | List[Union[Step, Tuple[Step, Tuple]]]], results: List[StepResult] = [] | ||
) -> List[StepResult]: | ||
"""Run multiple steps sequentially, or in parallel if steps are wrapped into a sublist. | ||
Args: | ||
steps_and_run_args (List[Union[Step, Tuple[Step, Tuple]] | List[Union[Step, Tuple[Step, Tuple]]]]): List of steps to run, if steps are wrapped in a sublist they will be executed in parallel. run function arguments can be passed as a tuple along the Step instance. | ||
results (List[StepResult], optional): List of step results, used for recursion. | ||
Returns: | ||
List[StepResult]: List of step results. | ||
""" | ||
# If there are no steps to run, return the results | ||
if not steps_and_run_args: | ||
return results | ||
|
||
# If any of the previous steps failed, skip the remaining steps | ||
if any(result.status is StepStatus.FAILURE for result in results): | ||
skipped_results = [] | ||
for step_and_run_args in steps_and_run_args: | ||
if isinstance(step_and_run_args, Tuple): | ||
skipped_results.append(step_and_run_args[0].skip()) | ||
else: | ||
skipped_results.append(step_and_run_args.skip()) | ||
return results + skipped_results | ||
|
||
# Pop the next step to run | ||
steps_to_run, remaining_steps = steps_and_run_args[0], steps_and_run_args[1:] | ||
|
||
# wrap the step in a list if it is not already (allows for parallel steps) | ||
if not isinstance(steps_to_run, list): | ||
steps_to_run = [steps_to_run] | ||
|
||
async with asyncer.create_task_group() as task_group: | ||
tasks = [] | ||
for step in steps_to_run: | ||
if isinstance(step, Step): | ||
tasks.append(task_group.soonify(step.run)()) | ||
elif isinstance(step, Tuple) and isinstance(step[0], Step) and isinstance(step[1], Tuple): | ||
step, run_args = step | ||
tasks.append(task_group.soonify(step.run)(*run_args)) | ||
|
||
new_results = [task.value for task in tasks] | ||
|
||
return await run_steps(remaining_steps, results + new_results) |
Oops, something went wrong.