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

[Notifications] Display Step Kind In Pipeline Notification #5538

Merged
merged 20 commits into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
0b9a6bd
Merge branch 'development' of github.com:mlrun/mlrun into development
Apr 3, 2024
b5c9c51
Merge branch 'development' of github.com:mlrun/mlrun into development
Apr 4, 2024
4f123bc
Merge branch 'development' of github.com:mlrun/mlrun into development
Apr 4, 2024
7e2361a
Merge branch 'development' of github.com:mlrun/mlrun into development
Apr 8, 2024
0494f74
Merge branch 'development' of github.com:mlrun/mlrun into development
Apr 10, 2024
d94e63c
Merge branch 'development' of github.com:mlrun/mlrun into development
Apr 16, 2024
467895d
Merge branch 'development' of github.com:mlrun/mlrun into development
Apr 18, 2024
7b8d539
Merge branch 'development' of github.com:mlrun/mlrun into development
May 2, 2024
4f25791
Merge branch 'development' of github.com:mlrun/mlrun into development
May 2, 2024
9f11f2c
Merge branch 'development' of github.com:mlrun/mlrun into development
May 2, 2024
6eaa6bb
Merge branch 'development' of github.com:mlrun/mlrun into development
May 6, 2024
18ba739
Merge branch 'development' of github.com:mlrun/mlrun into development
May 7, 2024
1633265
Merge branch 'development' of github.com:mlrun/mlrun into development
May 7, 2024
0ff4d02
Merge branch 'development' of github.com:mlrun/mlrun into development
May 9, 2024
b6676b3
Add step kind to pipeline notification
May 9, 2024
4874ee5
better system test
May 9, 2024
74caec3
redundant comment
May 9, 2024
a6f647f
Merge branch 'development' into pipeline-notification-extra-info
quaark May 9, 2024
263cee8
fix ut
May 9, 2024
16e8ba9
Merge branch 'pipeline-notification-extra-info' of github.com:quaark/…
May 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions mlrun/utils/notifications/notification/slack.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,18 +154,21 @@ def _get_run_line(self, run: dict) -> dict:
url = mlrun.utils.helpers.get_ui_url(meta.get("project"), meta.get("uid"))

# Only show the URL if the run is not a function (serving or mlrun function)
if run.get("kind") not in ["serving", None] and url:
kind = run.get("step_kind")
if url and not kind or kind == "run":
line = f'<{url}|*{meta.get("name")}*>'
else:
line = meta.get("name")
state = run["status"].get("state", "")
if kind:
line = f'{line} *({run.get("step_kind", run.get("kind", ""))})*'
line = f'{self.emojis.get(state, ":question:")} {line}'
return self._get_slack_row(line)

def _get_run_result(self, run: dict) -> dict:
state = run["status"].get("state", "")
if state == "error":
error_status = run["status"].get("error", "")
error_status = run["status"].get("error", "") or state
result = f"*{error_status}*"
else:
result = mlrun.utils.helpers.dict_to_str(
Expand Down
19 changes: 10 additions & 9 deletions mlrun/utils/notifications/notification_pusher.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,15 +392,15 @@ def get_workflow_steps(self, run: mlrun.model.RunObject) -> list:
steps = []
db = mlrun.get_run_db()

def _add_run_step(_node_name, _):
steps.append(
db.list_runs(
project=run.metadata.project,
labels=f"mlrun/runner-pod={_node_name}",
)[0]
)
def _add_run_step(_node_name, _node_template, _step_kind):
_run = db.list_runs(
project=run.metadata.project,
labels=f"mlrun/runner-pod={_node_name}",
)[0]
_run["step_kind"] = _step_kind
steps.append(_run)

def _add_deploy_function_step(_, _node_template):
def _add_deploy_function_step(_, _node_template, _step_kind):
project, name, hash_key = self._extract_function_uri(
_node_template["metadata"]["annotations"]["mlrun/function-uri"]
)
Expand Down Expand Up @@ -428,6 +428,7 @@ def _add_deploy_function_step(_, _node_template):
function["metadata"]["updated"] = function["metadata"][
"updated"
].isoformat()
function["step_kind"] = _step_kind
steps.append(function)

step_methods = {
Expand Down Expand Up @@ -464,7 +465,7 @@ def _add_deploy_function_step(_, _node_template):
)
step_method = step_methods.get(step_type)
if step_method:
step_method(node_name, node_template)
step_method(node_name, node_template, step_type)
return steps
except Exception:
# If we fail to read the pipeline steps, we will return the list of runs that have the same workflow id
Expand Down
16 changes: 7 additions & 9 deletions tests/system/projects/test_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -650,14 +650,12 @@ def test_remote_pipeline_with_kfp_engine_from_github(self):
engine="remote",
watch=True,
notification_steps={
# workflow runner, summary, train, test and model testing steps
"run": 5,
# gen data step
"job": 1,
# gen data function build step
"build": 1,
# workflow runner, gen data, summary, train, test and model testing steps
"run": 6,
# serving step
"serving": 1,
# gen data function build step (doesn't have a `kind` field)
None: 1,
"deploy": 1,
},
)
self._test_remote_pipeline_from_github(
Expand Down Expand Up @@ -1585,7 +1583,7 @@ def _assert_pipeline_notification_steps(
)[0]
notification_data_steps = {}
for step in notification_data:
notification_data_steps.setdefault(step.get("kind"), 0)
notification_data_steps[step.get("kind")] += 1
notification_data_steps.setdefault(step.get("step_kind"), 0)
notification_data_steps[step.get("step_kind")] += 1

assert notification_data_steps == notification_steps
2 changes: 1 addition & 1 deletion tests/utils/test_notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ def set_result(result):
{"text": "*Runs*", "type": "mrkdwn"},
{"text": "*Results*", "type": "mrkdwn"},
{"text": ":x: test-run", "type": "mrkdwn"},
{"text": "**", "type": "mrkdwn"},
{"text": "*error*", "type": "mrkdwn"},
],
"type": "section",
},
Expand Down
Loading