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

airbyte-ci: make airbyte-ci test able to run any poetry run command #33784

Conversation

alafanechere
Copy link
Contributor

@alafanechere alafanechere commented Dec 26, 2023

What

Relates to #33719

The current airbyte-ci test command is made to run tests on a poetry project.
It's currently only running a pytest command.
We have to change this command if we want to run other kind of commands to assess the health of the package (e.g. mypy) .

How

  • Add a --poetry-run-command options (mulitple) that will be run on the container where the poetry package is installed
  • Make required changes to our workflow according to this interface change.

Copy link

vercel bot commented Dec 26, 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 Jan 3, 2024 4:24pm

Copy link
Contributor Author

alafanechere commented Dec 26, 2023

Copy link
Contributor

Warning

Soft code freeze is in effect until 2024-01-02. Please avoid merging to master. #freedom-and-responsibility

@alafanechere alafanechere force-pushed the augustin/12-26-airbyte-ci_make_airbyte-ci_test_able_to_run_any_poetry_run_command branch from 9a6d133 to ab794c1 Compare December 26, 2023 19:16
@alafanechere alafanechere marked this pull request as ready for review December 27, 2023 07:52
@alafanechere alafanechere requested a review from a team December 27, 2023 07:52
@alafanechere alafanechere force-pushed the augustin/12-26-airbyte-ci_make_airbyte-ci_test_able_to_run_any_poetry_run_command branch from 3a4bd1e to 6b1ff5e Compare December 27, 2023 12:02
Copy link
Contributor

@erohmensing erohmensing left a comment

Choose a reason for hiding this comment

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

Functionally this seems fine - but I am wondering, why did we decide to do this under airbyte-ci test instead of introducing e.g. a airbyte-ci lint, similar to formatting, or trying to put format and lint in similar places?

To me, test implies running test, while running e.g mypy involves static checking that could for example have a certain list of files to ignore (as format does) or other linting-specific configuration.

@alafanechere
Copy link
Contributor Author

Functionally this seems fine - but I am wondering, why did we decide to do this under airbyte-ci test instead of introducing e.g. a airbyte-ci lint, similar to formatting, or trying to put format and lint in similar places?

To me, test implies running test, while running e.g mypy involves static checking that could for example have a certain list of files to ignore (as format does) or other linting-specific configuration.

I agree it would be more elegant to place this under a different command.
But I'm not sure lint can be similar to format in this scenario as the linting rules are poetry package specific.
I introduced this in test as airbyte-ci test is poetry package specific.

Maybe it's time for a poetry command group or a different approach for CI for poetry packages.
@erohmensing I filled up this issue with a couple of options I came up with. Do you agree this can be done in a follow-up change?

@alafanechere alafanechere force-pushed the augustin/12-26-airbyte-ci_make_airbyte-ci_test_able_to_run_any_poetry_run_command branch from 6b1ff5e to b8a63f7 Compare January 3, 2024 13:21
@erohmensing
Copy link
Contributor

@alafanechere thanks! this actually clears things up for me - we're only linting our code, not the whole codebase. So if we wanted to e.g. lint connector code, we would probably be doing that in connectors test, and if we wanted to do it for the cdk... i'm not sure where we'd do it. But I agree that in the way we're doing it now, it is closer to our testing than our formatting.

Yes, a follow up PR sounds fine to me. Will do a proper review!

Copy link
Contributor

@erohmensing erohmensing left a comment

Choose a reason for hiding this comment

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

One question about erroring on failure, otherwise looks 🚢 able to me! I agree that the behavior is starting to look more like "airbyte ci do whatever poetry wants to perform on this package", thanks for writing up the other issue :)

airbyte-ci/connectors/pipelines/README.md Outdated Show resolved Hide resolved
`airbyte-ci test airbyte-ci/connectors/pipelines --test-directory=tests`
`airbyte-ci tests airbyte-integrations/bases/connector-acceptance-test --test-directory=unit_tests`
`airbyte-ci test airbyte-ci/connectors/pipelines --poetry-run-command='pytest tests'`
`airbyte-ci tests airbyte-integrations/bases/connector-acceptance-test--poetry-run-command='pytest tests/unit_tests'`
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
`airbyte-ci tests airbyte-integrations/bases/connector-acceptance-test--poetry-run-command='pytest tests/unit_tests'`
`airbyte-ci tests airbyte-integrations/bases/connector-acceptance-test--poetry-run-command='pytest unit_tests'`

@click.option(
"-c",
"--poetry-run-command",
multiple=True,
Copy link
Contributor

Choose a reason for hiding this comment

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

This means you can pass the option multiple times, not that you can pass multiple arguements to the option, right? An example in the docs of how to pass multiple may be helpful, as well as noting somewhere (new column?) that it can be passed multiple times.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes you're right. I added an example to the README.

Comment on lines +114 to +124
soon_command_executions_results = []
async with asyncer.create_task_group() as poetry_commands_task_group:
for command in commands_to_run:
logger.info(f"Running command: {command}")
soon_command_execution_result = poetry_commands_task_group.soonify(run_poetry_command)(test_container, command)
soon_command_executions_results.append(soon_command_execution_result)

for result in soon_command_executions_results:
stdout, stderr = result.value
logger.info(stdout)
logger.error(stderr)
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we still get the exit on failure behavior that we want? I know in format, when running multiple steps concurrently we had to add explicit error exiting

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If an execution fails the async context will throw an ExceptionGroup which will lead to a click command failure and a failed CI pipeline.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, great! I guess before it was different because we wanted to continue all the others and collect successes and failures? I suppose that could be helpful here too, but it's not blocking for me, as its all our code that we're checking

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes you're right, we could a Dagger exec error handling to better handle success / failure.

@alafanechere alafanechere force-pushed the augustin/12-26-airbyte-ci_make_airbyte-ci_test_able_to_run_any_poetry_run_command branch from 9ed1ae5 to 05f5378 Compare January 3, 2024 16:24
@alafanechere alafanechere enabled auto-merge (squash) January 3, 2024 16:28
@alafanechere alafanechere merged commit 823d122 into master Jan 3, 2024
20 checks passed
@alafanechere alafanechere deleted the augustin/12-26-airbyte-ci_make_airbyte-ci_test_able_to_run_any_poetry_run_command branch January 3, 2024 16:45
for result in soon_command_executions_results:
stdout, stderr = result.value
logger.info(stdout)
logger.error(stderr)
Copy link
Contributor

Choose a reason for hiding this comment

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

With multiple commands this will output a jumble of lines which will be very hard to relate to the command itself. Sequentializing the output will require more code. Is the concurrency here really worth it in terms of the added complexity? I'm asking because I don't actually know; however if it's not really worth it then let's execute the poetry commands sequentially. More code => bigger maintenance burden.

Tuple[str, str]: The stdout and stderr of the command.
"""
container = container.with_exec(["poetry", "run", *command.split(" ")])
return await container.stdout(), await container.stderr()
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't we be better off returning a dagger.Container here? I'm a bit surprised that we're not interested in the exit code, but I guess that dagger handles failures for us transparently.

gisripa pushed a commit that referenced this pull request Jan 3, 2024
…#33784)

Co-authored-by: Ella Rohm-Ensing <erohmensing@gmail.com>
Copy link

sentry-io bot commented Jan 3, 2024

Suspect Issues

This pull request was deployed and Sentry observed the following issues:

  • ‼️ ExecError: process "poetry run mypy pipelines --disallow-untyped-defs" did not complete successfully: exit c... pipelines.airbyte_ci.test.commands in run_poetr... View Issue
  • ‼️ ExecError: process "poetry run ruff check pipelines" did not complete successfully: exit code: 1 pipelines.airbyte_ci.test.commands in run_poetr... View Issue
  • ‼️ ExecError: process "poetry run pytest tests" did not complete successfully: exit code: 1 pipelines.airbyte_ci.test.commands in run_poetr... View Issue
  • ‼️ ExecError: process "poetry run pytest tests" did not complete successfully: exit code: 1 pipelines.airbyte_ci.test.commands in run_poetr... View Issue
  • ‼️ ExecError: process "poetry run ruff check pipelines" did not complete successfully: exit code: 1 pipelines.airbyte_ci.test.commands in run_poetr... View Issue

Did you find this useful? React with a 👍 or 👎

jatinyadav-cc pushed a commit to ollionorg/datapipes-airbyte that referenced this pull request Feb 26, 2024
jatinyadav-cc pushed a commit to ollionorg/datapipes-airbyte that referenced this pull request Feb 26, 2024
jatinyadav-cc pushed a commit to ollionorg/datapipes-airbyte that referenced this pull request Feb 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants