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

[BUGFIX] Ensure that SlackNotificationAction renders properly #9885

Merged
merged 4 commits into from
May 7, 2024

Conversation

cdkini
Copy link
Member

@cdkini cdkini commented May 6, 2024

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

  • Description of PR changes above includes a link to an existing GitHub issue
  • PR title is prefixed with one of: [BUGFIX], [FEATURE], [DOCS], [MAINTENANCE], [CONTRIB]
  • Code is linted - run invoke lint (uses ruff format + ruff check)
  • Appropriate tests and docs have been updated

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!

Copy link

netlify bot commented May 6, 2024

Deploy Preview for niobium-lead-7998 canceled.

Name Link
🔨 Latest commit 88025d4
🔍 Latest deploy log https://app.netlify.com/sites/niobium-lead-7998/deploys/6639202cbe109300082b9880

Copy link

netlify bot commented May 6, 2024

Deploy Preview for niobium-lead-7998 canceled.

Name Link
🔨 Latest commit 1fc580d
🔍 Latest deploy log https://app.netlify.com/sites/niobium-lead-7998/deploys/6639511ff5c34b0008246e89

Comment on lines -320 to -329
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
Copy link
Member Author

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:
Copy link
Member Author

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

@cdkini cdkini self-assigned this May 6, 2024
Copy link

codecov bot commented May 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 77.28%. Comparing base (db080d4) to head (1fc580d).

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     
Flag Coverage Δ
3.10 64.21% <100.00%> (-0.01%) ⬇️
3.10 athena or clickhouse or openpyxl or pyarrow or project or sqlite or aws_creds ?
3.10 aws_deps ?
3.10 big ?
3.10 databricks ?
3.10 filesystem ?
3.10 mssql ?
3.10 mysql ?
3.10 postgresql ?
3.10 snowflake ?
3.10 spark ?
3.10 trino ?
3.11 64.21% <100.00%> (-0.01%) ⬇️
3.11 athena or clickhouse or openpyxl or pyarrow or project or sqlite or aws_creds 53.87% <29.41%> (+0.01%) ⬆️
3.11 aws_deps 44.79% <29.41%> (+0.01%) ⬆️
3.11 big ?
3.11 databricks 45.97% <29.41%> (+0.01%) ⬆️
3.11 filesystem 61.18% <29.41%> (+0.01%) ⬆️
3.11 mssql 48.78% <29.41%> (+0.01%) ⬆️
3.11 mysql 48.84% <29.41%> (+0.01%) ⬆️
3.11 postgresql 52.75% <29.41%> (+0.01%) ⬆️
3.11 snowflake 46.57% <29.41%> (+<0.01%) ⬆️
3.11 spark 57.18% <29.41%> (+0.01%) ⬆️
3.11 trino 50.75% <29.41%> (+0.01%) ⬆️
3.8 64.23% <100.00%> (-0.01%) ⬇️
3.8 athena or clickhouse or openpyxl or pyarrow or project or sqlite or aws_creds 53.88% <29.41%> (+0.01%) ⬆️
3.8 aws_deps ?
3.8 big ?
3.8 databricks 45.98% <29.41%> (+0.01%) ⬆️
3.8 filesystem 61.19% <29.41%> (+0.01%) ⬆️
3.8 mssql 48.76% <29.41%> (+0.01%) ⬆️
3.8 mysql 48.82% <29.41%> (+0.01%) ⬆️
3.8 postgresql 52.74% <29.41%> (+0.01%) ⬆️
3.8 snowflake 46.59% <29.41%> (+<0.01%) ⬆️
3.8 spark 57.14% <29.41%> (+0.01%) ⬆️
3.8 trino 50.74% <29.41%> (+0.01%) ⬆️
3.9 64.23% <100.00%> (-0.01%) ⬇️
3.9 athena or clickhouse or openpyxl or pyarrow or project or sqlite or aws_creds ?
3.9 aws_deps ?
3.9 big ?
3.9 databricks ?
3.9 filesystem ?
3.9 mssql ?
3.9 mysql ?
3.9 postgresql ?
3.9 snowflake ?
3.9 spark ?
3.9 trino ?
cloud 0.00% <0.00%> (ø)
docs-basic 49.11% <29.41%> (+0.01%) ⬆️
docs-creds-needed 50.24% <29.41%> (+0.01%) ⬆️
docs-spark 48.32% <29.41%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -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(
Copy link
Contributor

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):
Copy link
Contributor

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?

@cdkini cdkini enabled auto-merge May 6, 2024 21:52
@cdkini cdkini added this pull request to the merge queue May 6, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks May 6, 2024
@cdkini cdkini added this pull request to the merge queue May 7, 2024
Merged via the queue into develop with commit 8db76eb May 7, 2024
69 checks passed
@cdkini cdkini deleted the m/_/patch_slack_notification_action_rendering branch May 7, 2024 00:46
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