-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
[BUGFIX] Ensure that SlackNotificationAction
renders properly
#9885
Conversation
…_expectations into m/_/patch_slack_notification_action_rendering
✅ Deploy Preview for niobium-lead-7998 canceled.
|
✅ Deploy Preview for niobium-lead-7998 canceled.
|
def _send_notifications_in_batches(self, blocks, payload, result): | ||
text = blocks[0]["text"]["text"] | ||
chunks, chunk_size = len(text), len(text) // 4 | ||
split_text = [ | ||
text[position : position + chunk_size] for position in range(0, chunks, chunk_size) | ||
] | ||
for batch in split_text: | ||
payload["text"] = batch | ||
result = self._get_slack_result(payload) | ||
return result |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feels like an optimization we don't need - would be easy enough to add something like this if we need it later on
@@ -142,17 +141,28 @@ def _build_report_element_block( | |||
|
|||
return None | |||
|
|||
def _build_divider_block(self) -> dict: | |||
return {"type": "divider"} | |||
def concatenate_text_blocks(self, text_blocks: list[dict], name: str, success: bool) -> dict: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some minor refactoring of existing logic
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #9885 +/- ##
===========================================
- Coverage 77.99% 77.28% -0.71%
===========================================
Files 495 493 -2
Lines 42539 42527 -12
===========================================
- Hits 33178 32867 -311
- Misses 9361 9660 +299
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
tests/actions/test_core_actions.py
Outdated
@@ -533,39 +533,51 @@ def test_SlackNotificationAction_run(self, checkpoint_result: CheckpointResult): | |||
with mock.patch.object(Session, "post") as mock_post: | |||
output = action.run(checkpoint_result=checkpoint_result) | |||
|
|||
assert mock_post.call_count == 5 # Sent in batches | |||
assert mock_post.call_count == 1 | |||
mock_post.assert_called_with( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assert_called_once_with
seems like the most descriptive way to do this, rather than also use the call count
payload["text"] = batch | ||
result = self._get_slack_result(payload) | ||
return result | ||
|
||
def _get_slack_result(self, payload): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know you didn't change it in this PR, but this is method should be renamed. Might as well do it now?
We were seeing duplicative Slack posts from our current logic - this should resolve the matter
What it should now look like:
![Screenshot 2024-05-06 at 2 24 07 PM](https://private-user-images.githubusercontent.com/49923762/328278121-ce9d6469-7245-4195-a590-4739b7173aa2.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTgyNzA2NTQsIm5iZiI6MTcxODI3MDM1NCwicGF0aCI6Ii80OTkyMzc2Mi8zMjgyNzgxMjEtY2U5ZDY0NjktNzI0NS00MTk1LWE1OTAtNDczOWI3MTczYWEyLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA2MTMlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNjEzVDA5MTkxNFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWNkOTJlZDc1Yzk4NDMxYjU5OGM0ODFkNzAyMjg0YTI0ZDU3MjViMWI3NzZjYWM0OTc0M2IxYmJjMjgzNTgzNDEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.q5rx2oQRsGp07MvwSSIR8KKFJSbSpueTS1RU4LUhiBk)
invoke lint
(usesruff format
+ruff check
)For more information about contributing, see Contribute.
After you submit your PR, keep the page open and monitor the statuses of the various checks made by our continuous integration process at the bottom of the page. Please fix any issues that come up and reach out on Slack if you need help. Thanks for contributing!