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: ClickPipelineContext handles dagger logging #33419

Conversation

alafanechere
Copy link
Contributor

@alafanechere alafanechere commented Dec 13, 2023

What

ClickPipelineContext users rely on the get_dagger_client method to get the dagger client as a singleton.
We originally exposed a log_output parameter to this method, but as it returns a singleton dagger client, the passed log_output is not taken into account if the singleton already exists.

How

The get_dagger_client defines the log output path according to the show_dagger_logs params.
If show_dagger_logs is true: show the logs in the stdout, otherwise log to a file.

Next:

  • Remove the show_dagger_logs param/options and always log to a file
  • Users can see the dagger logs if they're using a dagger run wrapped command
  • Broaden the use of ClickPipelineContext to have a consistent logging management implementation

Copy link

vercel bot commented Dec 13, 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 Dec 15, 2023 8:00am

Copy link
Contributor Author

Current dependencies on/for this PR:

This stack of pull requests is managed by Graphite.

@alafanechere alafanechere marked this pull request as ready for review December 13, 2023 14:37
@alafanechere alafanechere requested review from a team and bnchrch December 13, 2023 14:37
@alafanechere alafanechere force-pushed the augustin/12-13-airbyte-ci_ClickPipelineContext_handles_dagger_logging branch 2 times, most recently from 6ddfdf5 to 68e0adc Compare December 13, 2023 17:01
Copy link
Contributor

@bnchrch bnchrch left a comment

Choose a reason for hiding this comment

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

Good change! Just have a question on where this should live.

Comment on lines 89 to 92
if self.params.get("show_dagger_logs", False):
log_output = sys.stdout
else:
log_output, self._click_context().obj["dagger_logs_path"] = self._create_dagger_client_log_file()
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice change!

One house keeping thing

1. Move this logic to its own method

def get_log_output(self):
    if self.params.get("show_dagger_logs", False):
        log_output = sys.stdout
    else:
        log_output, self._click_context().obj["dagger_logs_path"] = self._create_dagger_client_log_file()

    return log_output

@@ -97,6 +103,14 @@ async def get_dagger_client(self, pipeline_name: Optional[str] = None, log_outpu
assert self._dagger_client, "Error initializing Dagger client"
return self._dagger_client.pipeline(pipeline_name) if pipeline_name else self._dagger_client

def _create_dagger_client_log_file(self) -> Tuple[io.FileIO, str]:
Copy link
Contributor

Choose a reason for hiding this comment

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

❓ Instead of adding this logic here, could we not hoist it into airbyte_ci.py or dagger_run.py and make it shared between all pipelines?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's something I considered but as the log file is tightly coupled to the client I prefer to keep it where the client is instantiated.
I'm also conscious that we currently have inconsistencies in the way we handle dagger client logging in our commands.
I created this issue to consolidate the approach.
TLDR; all our commands should get their dagger client from ClickPipelineContext

Copy link
Contributor

Choose a reason for hiding this comment

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

That sounds fine then!

At that point in time we should be in a good place to introduce the GlobalSettings pattern from aircmd,

@alafanechere alafanechere force-pushed the augustin/12-13-airbyte-ci_ClickPipelineContext_handles_dagger_logging branch 2 times, most recently from 34beb12 to 3e1ad9e Compare December 14, 2023 10:20
Copy link
Contributor

@bnchrch bnchrch left a comment

Choose a reason for hiding this comment

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

lgtm!

@@ -97,6 +103,14 @@ async def get_dagger_client(self, pipeline_name: Optional[str] = None, log_outpu
assert self._dagger_client, "Error initializing Dagger client"
return self._dagger_client.pipeline(pipeline_name) if pipeline_name else self._dagger_client

def _create_dagger_client_log_file(self) -> Tuple[io.FileIO, str]:
Copy link
Contributor

Choose a reason for hiding this comment

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

That sounds fine then!

At that point in time we should be in a good place to introduce the GlobalSettings pattern from aircmd,

@alafanechere alafanechere force-pushed the augustin/12-13-airbyte-ci_ClickPipelineContext_handles_dagger_logging branch from 3e1ad9e to fe819b4 Compare December 15, 2023 08:00
@alafanechere alafanechere enabled auto-merge (squash) December 15, 2023 08:02
@alafanechere alafanechere merged commit 2b6bcfc into master Dec 15, 2023
21 checks passed
@alafanechere alafanechere deleted the augustin/12-13-airbyte-ci_ClickPipelineContext_handles_dagger_logging branch December 15, 2023 08:12
Copy link

sentry-io bot commented Dec 18, 2023

Suspect Issues

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

  • ‼️ SessionError: Failed to start Dagger engine session: Command '/home/runner/.cache/dagger/dagger-0.6.4 session -... dagger.engine.cli in _get_conn 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

2 participants