2021-06-09 22:24:02 +08:00
|
|
|
defmodule Livebook.Runtime.NoopRuntime do
|
|
|
|
@moduledoc false
|
|
|
|
|
|
|
|
# A runtime that doesn't do any actual evaluation,
|
|
|
|
# thus not requiring any underlying resources.
|
|
|
|
|
2022-04-02 02:13:37 +08:00
|
|
|
defstruct [:started]
|
2021-06-09 22:24:02 +08:00
|
|
|
|
2022-04-02 02:13:37 +08:00
|
|
|
def new() do
|
|
|
|
%__MODULE__{started: false}
|
|
|
|
end
|
2021-06-09 22:24:02 +08:00
|
|
|
|
|
|
|
defimpl Livebook.Runtime do
|
2022-04-02 02:13:37 +08:00
|
|
|
def describe(_runtime) do
|
|
|
|
[{"Type", "Noop"}]
|
|
|
|
end
|
|
|
|
|
|
|
|
def connect(runtime), do: {:ok, %{runtime | started: true}}
|
|
|
|
def connected?(runtime), do: runtime.started
|
|
|
|
def take_ownership(_, _), do: make_ref()
|
|
|
|
def disconnect(runtime), do: {:ok, %{runtime | started: false}}
|
|
|
|
def duplicate(_), do: Livebook.Runtime.NoopRuntime.new()
|
|
|
|
|
2021-07-16 00:19:36 +08:00
|
|
|
def evaluate_code(_, _, _, _, _ \\ []), do: :ok
|
|
|
|
def forget_evaluation(_, _), do: :ok
|
2021-06-09 22:24:02 +08:00
|
|
|
def drop_container(_, _), do: :ok
|
2022-04-04 18:19:11 +08:00
|
|
|
def handle_intellisense(_, _, _, _), do: make_ref()
|
2022-02-28 20:53:33 +08:00
|
|
|
|
2023-02-06 22:50:48 +08:00
|
|
|
def read_file(_, path) do
|
|
|
|
case File.read(path) do
|
|
|
|
{:ok, binary} -> {:ok, binary}
|
|
|
|
{:error, reason} -> {:error, "failed to read the file, got: #{inspect(reason)}"}
|
|
|
|
end
|
|
|
|
end
|
2023-02-02 01:49:12 +08:00
|
|
|
|
|
|
|
def transfer_file(_runtime, path, _file_id, callback) do
|
|
|
|
callback.(path)
|
|
|
|
:ok
|
|
|
|
end
|
|
|
|
|
|
|
|
def revoke_file(_, _), do: :ok
|
2023-01-05 04:44:04 +08:00
|
|
|
|
2022-03-05 20:19:42 +08:00
|
|
|
def start_smart_cell(_, _, _, _, _), do: :ok
|
2022-11-09 21:40:44 +08:00
|
|
|
def set_smart_cell_parent_locators(_, _, _), do: :ok
|
2022-02-28 20:53:33 +08:00
|
|
|
def stop_smart_cell(_, _), do: :ok
|
2022-04-02 02:13:37 +08:00
|
|
|
|
|
|
|
def fixed_dependencies?(_), do: false
|
|
|
|
|
|
|
|
def add_dependencies(_runtime, code, dependencies) do
|
2022-12-03 23:23:43 +08:00
|
|
|
Livebook.Runtime.Dependencies.add_dependencies(code, dependencies)
|
2022-04-02 02:13:37 +08:00
|
|
|
end
|
|
|
|
|
2023-05-09 22:49:02 +08:00
|
|
|
def has_dependencies?(_runtime, _dependencies), do: true
|
|
|
|
|
|
|
|
def code_block_definitions(_runtime), do: []
|
|
|
|
|
2022-04-30 23:14:10 +08:00
|
|
|
def search_packages(_, _, _), do: make_ref()
|
2022-08-26 04:24:24 +08:00
|
|
|
|
2023-01-03 19:24:22 +08:00
|
|
|
def disable_dependencies_cache(_), do: :ok
|
|
|
|
|
2022-08-26 04:24:24 +08:00
|
|
|
def put_system_envs(_, _), do: :ok
|
2022-09-17 01:22:27 +08:00
|
|
|
def delete_system_envs(_, _), do: :ok
|
2021-06-09 22:24:02 +08:00
|
|
|
end
|
|
|
|
end
|