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

frontend: provide log-detective explain integration for failed builds #3608

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion frontend/coprs_frontend/coprs/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ class Config(object):

RECENT_BUILDS_ON_FRONTPAGE = False

LOG_DETECTIVE_BUTTON = False
LOG_DETECTIVE_BUTTON = True

ROLLING_CHROOTS_INACTIVITY_WARNING = 180
ROLLING_CHROOTS_INACTIVITY_REMOVAL = 180
Expand Down
21 changes: 20 additions & 1 deletion frontend/coprs_frontend/coprs/templates/_helpers.html
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,26 @@
{% endif %}
{% endmacro %}

{% macro build_state_text(state, reason=None) %}
{% macro log_detective_ai_link(failed_log_url, build_id, chroot_name) %}
{% if config.LOG_DETECTIVE_BUTTON %}
{% if failed_log_url %}
{% set url = "https://log-detective.com/explain?url=%s" %}
<a href="{{ url | format(failed_log_url | urlencode) }}"
class="pficon pficon-info"
title="See what AI can tell you about the build failure">
Ask AI
</a> &nbsp&nbsp / &nbsp&nbsp
{% endif %}
{% set url = "https://log-detective.com/contribute/copr/%s/%s" %}
<a href="{{ url | format(build_id, chroot_name) }}"
class="pficon pficon-info"
title="Teach AI about this build failure">
Teach AI
</a>
{% endif %}
{% endmacro %}

{% macro build_state_text(state, reason=None, builder_live_log=None) %}
<span class="build-{{ state }}"
title="{{ reason or state | build_state_description }}">
{% if state == "importing" %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,25 +295,3 @@ <h3> New Build Options </h3>
});
</script>
{% endmacro %}

{% macro copr_build_feed_log_detective(build, class="") %}
{% set url = "https://log-detective.com/contribute/copr/%s/%s" %}
{% set chroots = build.build_chroots|selectattr("state", "equalto", "failed") %}
<div class="dropdown {{ class }}">
<button class="btn btn-success dropdown-toggle" type="button" data-toggle="dropdown"
title="Annotate the failure in Log Detective to train AI to recognize this issue">
<span class="fa fa-external-link"></span>
Log Detective
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
{% if build.source_state == "failed" %}
<li><a href="{{ url |format(build.id, 'srpm-builds') }}">Report SRPM build</a></li>
{% else %}
{% for chroot in chroots %}
<li><a href="{{ url |format(build.id, chroot.name) }}">Report {{ chroot.name }}</a></li>
{% endfor %}
{% endif %}
</ul>
</div>
{% endmacro %}
42 changes: 33 additions & 9 deletions frontend/coprs_frontend/coprs/templates/coprs/detail/build.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,17 @@
copr_build_cancel_form,
copr_build_repeat_form,
copr_resubmit_allow_user_ssh_form,
copr_build_delete_form,
copr_build_feed_log_detective
copr_build_delete_form
%}
{% from "coprs/detail/_describe_source.html" import describe_source %}
{% from "coprs/detail/_describe_failure.html" import describe_failure %}
{% from "_helpers.html" import chroot_to_os_logo, build_state_text, build_state, copr_name %}
{% from "_helpers.html" import
chroot_to_os_logo,
build_state_text,
build_state,
copr_name,
log_detective_ai_link
%}
{% block title %}Build {{ build.id }} in {{ copr_name(build.copr) }}{% endblock %}

{% set selected_tab = "builds" %}
Expand All @@ -35,10 +40,6 @@ <h2 class="build-detail"> Build {{ build.id }} doesn't belong to this project. <
{% endif %}
{% endif %}

{% if config.LOG_DETECTIVE_BUTTON and build.state == "failed" %}
{{ copr_build_feed_log_detective(build, class="pull-right button-build-action") }}
{% endif %}

{% if g.user and g.user.can_build_in(copr) and build.cancelable %}
{{ copr_build_cancel_form(build, page, class="pull-right button-build-action") }}
{% endif %}
Expand Down Expand Up @@ -201,7 +202,18 @@ <h3 class="panel-title">Results</h3>
<dl class="dl-horizontal">
{{ describe_failure(build) }}
<dt>Source state:</dt>
<dd>{{ build_state_text(build.source_state) }} </dd>
<dd>
{{ build_state_text(build.source_state) }}
{% if build.source_state == "failed" %}
{% set link_shown = namespace(value=False) %}
{% for url in build.get_source_log_urls %}
{% if not link_shown.value %}
&nbsp&nbsp {{ log_detective_ai_link(url, build.id, "srpm-builds") }}
{% set link_shown.value = true %}
{% endif %}
{% endfor %}
{% endif %}
</dd>
<dt>Source build logs:</dt>
<dd>
{% if build.resubmitted_from_id and build.source_is_uploaded %}
Expand Down Expand Up @@ -244,6 +256,9 @@ <h3 class="panel-title">Results</h3>
<th>Build Time</th>
<th>Logs</th>
<th>State</th>
{% if build.state == "failed" and build.source_state == "succeeded" %}
<th>Log Detective AI</th>
{% endif %}
</tr>
</thead>
<tbody>
Expand Down Expand Up @@ -283,8 +298,17 @@ <h3 class="panel-title">Results</h3>
{% endfor %}
</td>
<td>
{{ build_state_text(chroot.state, chroot.status_reason) }}
{{ build_state_text(chroot.state, chroot.status_reason, chroot.rpm_live_log_url) }}
</td>
{% if build.state == "failed" and build.source_state == "succeeded" %}
<td>
{% if chroot.state == "failed" %}
{{ log_detective_ai_link(chroot.rpm_live_log_url, build.id, chroot.name) }}
{% else %}
-
{% endif %}
</td>
{% endif %}
</tr>
{% endfor %}
</tbody>
Expand Down