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

Suggest setup without cache on dependencies error #2716

Merged
merged 1 commit into from
Jul 19, 2024
Merged
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
1 change: 1 addition & 0 deletions lib/livebook/runtime.ex
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,7 @@ defprotocol Livebook.Runtime do
{:missing_secret, name :: String.t()}
| {:interrupt, variant :: :normal | :error, message :: String.t()}
| {:file_entry_forbidden, name :: String.t()}
| :dependencies
| nil
}

Expand Down
3 changes: 3 additions & 0 deletions lib/livebook/runtime/evaluator/formatter.ex
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,9 @@ defmodule Livebook.Runtime.Evaluator.Formatter do
defp error_context(error) when is_struct(error, Kino.FS.ForbiddenError),
do: {:file_entry_forbidden, error.name}

defp error_context(error) when is_struct(error, Mix.Error),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mix.Error can happen for several other reasons. Should we check the message as well?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which ones do you suggest? We only show the special action in the setup cell, so I would be fine with not matching the message. Your call!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, lets give this a try as is then!

do: :dependencies

defp error_context(_), do: nil

defp erlang_to_output(value) do
Expand Down
49 changes: 39 additions & 10 deletions lib/livebook_web/live/output.ex
Original file line number Diff line number Diff line change
Expand Up @@ -260,11 +260,8 @@ defmodule LivebookWeb.Output do
assigns = %{message: output.message, secret_name: secret_name, session_id: session_id, id: id}

~H"""
<div class="-m-4 space-x-4 py-4">
<div
class="flex items-center justify-between border-b px-4 pb-4 mb-4"
style="color: var(--ansi-color-red);"
>
<div class="flex flex-col gap-4">
<div class="flex items-center justify-between gap-2" style="color: var(--ansi-color-red);">
<div class="flex space-x-2 font-editor">
<.remix_icon icon="close-circle-line" />
<span>Missing secret <%= inspect(@secret_name) %></span>
Expand All @@ -273,6 +270,7 @@ defmodule LivebookWeb.Output do
Add secret
</.button>
</div>
<div class="border-t border-gray-200 -mx-4" />
<%= render_formatted_error_message(@id, @message) %>
</div>
"""
Expand All @@ -290,11 +288,8 @@ defmodule LivebookWeb.Output do
}

~H"""
<div class="-m-4 space-x-4 py-4">
<div
class="flex items-center justify-between border-b px-4 pb-4 mb-4"
style="color: var(--ansi-color-red);"
>
<div class="flex flex-col gap-4">
<div class="flex items-center justify-between gap-2" style="color: var(--ansi-color-red);">
<div class="flex space-x-2 font-editor">
<.remix_icon icon="close-circle-line" />
<span>Forbidden access to file <%= inspect(@file_entry_name) %></span>
Expand All @@ -306,6 +301,7 @@ defmodule LivebookWeb.Output do
Review access
</.button>
</div>
<div class="border-t border-gray-200 -mx-4" />
<%= render_formatted_error_message(@id, @message) %>
</div>
"""
Expand Down Expand Up @@ -346,6 +342,39 @@ defmodule LivebookWeb.Output do
"""
end

defp render_output(%{type: :error, context: :dependencies} = output, %{id: id, cell_id: cell_id}) do
assigns = %{message: output.message, id: id, cell_id: cell_id}

if cell_id == Livebook.Notebook.Cell.setup_cell_id() do
~H"""
<div class="flex flex-col gap-4">
<div class="flex items-center justify-between gap-2" style="color: var(--ansi-color-red);">
<div class="flex space-x-2 font-editor">
<.remix_icon icon="close-circle-line" />
<span>
Trouble installing dependencies? You may want to retry without cache.
</span>
</div>
<.button
color="gray"
phx-click={
JS.push("queue_cell_evaluation",
value: %{cell_id: @cell_id, disable_dependencies_cache: true}
)
}
>
Setup without cache
</.button>
</div>
<div class="border-t border-gray-200 -mx-4" />
<%= render_formatted_error_message(@id, @message) %>
</div>
"""
else
render_formatted_error_message(id, output.message)
end
end

defp render_output(%{type: :error, message: message}, %{id: id}) do
render_formatted_error_message(id, message)
end
Expand Down
Loading