Chore(cicd_bot): Show logged warnings/errors in the check output#4938
Chore(cicd_bot): Show logged warnings/errors in the check output#4938
Conversation
themisvaltinos
left a comment
There was a problem hiding this comment.
lgtm the alert block is really nice there! one question I have is about the error alert and how it looks because I can't find examples of it on GitHub
| return f"No changes to apply.{plan_flags_section}" | ||
|
|
||
| return f"{difference_summary}\n{missing_dates}{plan_flags_section}" | ||
| warnings_block = self._console.captured_warnings |
There was a problem hiding this comment.
fmi what is the reason that here you don't consume so the error and warnings remain but in get_pr_environment_summary you use consume_captured_warnings instead
There was a problem hiding this comment.
Good question.
I need to revisit this, upon further reflection it's essentially a no-op and because the warnings already get consumed in get_pr_environment_summary which means self._console.captured_warnings always returns ''
There was a problem hiding this comment.
I've updated these to the consume() equivalents. Most of the time, warnings in particular will be already consumed by the PR Environment Synced step, this would just capture any extra ones raised between the steps
There was a problem hiding this comment.
yes i see, it is indeed a bit hard to follow the steps and see what has been consumed
sqlmesh/core/console.py
Outdated
| if errors: | ||
| self._errors.append("\n".join(str(ex) for ex in errors)) | ||
| super().log_failed_models(errors) | ||
| self._errors.extend([str(ex) for ex in errors]) |
There was a problem hiding this comment.
should this have similar logic check like in log_error if message not in self._errors: or the errors can't have duplicates here
There was a problem hiding this comment.
Yeah I was torn between preserving the existing logic or adjusting it.
I should just make this consistent with _warnings
There was a problem hiding this comment.
I've added in deduplication step. However, I need to do more testing because im not actually sure if this codepath is ever hit.
I've noticed another issue with how failures are reported when a model throws an exception but i'll raise a new PR for that
sqlmesh/core/console.py
Outdated
| self._print(f"```\n\\[WARNING] {short_message}```\n\n") | ||
| @property | ||
| def captured_errors(self) -> str: | ||
| return self._render_alert_block("ERROR", self._errors) |
There was a problem hiding this comment.
how does this look in this ERROR case? is it like the caution one here: https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#alerts
There was a problem hiding this comment.
🤦♂️ I should actually read the documentation I linked.
Yes, this should be CAUTION and not ERROR because there is no ERROR
There was a problem hiding this comment.
great and thanks for providing a example of how it looks
|
The warning looks great! Some things to think about (sorry if this is addressed in PR I just quickly reviewed it)
|
|
Oh, interesting, it looks like collapsible sections can go inside alert blocks: Warning The PR plan produced the following warnings:fooWould that be preferable, coupled with truncating the warning text if it goes over a certain threshold? |
bc3f02a to
b94bc9c
Compare
| self.alert_block_max_content_length = int(kwargs.pop("alert_block_max_content_length", 500)) | ||
| self.alert_block_collapsible_threshold = int( | ||
| kwargs.pop("alert_block_collapsible_threshold", 200) | ||
| ) |
There was a problem hiding this comment.
I've hardcoded these thresholds for now but it would be a low lift to make them configurable if required.
alert_block_max_content_length - maximum amount of text to put inside a [!WARNING] block
alert_block_collapsible_threshold - if the text is longer than this, it isn't truncated (unless it exceeds alert_block_max_content_length), but it's wrapped inside a collapsible section within the [!WARNING] block
There was a problem hiding this comment.
yes I feel the collapsible section within the block is much better and since it is collapsible I don't see the need to truncate and have the please check the console message anymore
b94bc9c to
2622d0b
Compare
2622d0b to
0cf8f9d
Compare

Prior to this PR, warnings were logged to the console only. This made them vastly less noticeable/actionable because you'd only ever see them if you were trying to troubleshoot an issue.
PR #4900 introduces a warning that we want people to take notice of / action.
So, this PR:
PR Environment SummaryMarkdown is generated as it was getting quite large and unwieldyMarkdownConsoleerrors / warnings captured output to produce alert blocks instead of code blocksBefore (warnings/errors not shown in check output):

After (warnings collapsed if too long):

After (warnings expanded)

After (warnings truncated if too long)

After (error example)
