Dagger is a tool for modeling your workflows as data that can be composed together at runtime.
Dagger constructs can be integrated into a Dagger.Workflow and evaluated lazily in concurrent contexts.
| defp create_table() do | |
| case :mnesia.create_table(@module, [ | |
| {:ram_copies, [node()]}, | |
| storage_properties: [[ets: [:compressed]]], | |
| attributes: @attributes, | |
| index: @indexes | |
| ]) do | |
| :ok -> :ok | |
| {:atomic, :ok} -> :ok | |
| {:aborted, {:already_exists, @module}} -> :ok |
What do Tensorflow, Apache Airflow, Rule Engines, and Excel have in common?
Under the hood they all use DAGs to model data-flow dependencies of the program. Using graphs to model programs is great because you can modify the program at runtime. Lets talk about doing this in Elixir for great good.
| export PAGER=less | |
| export LESS="-iMSx4 -FX" |
Erlang ships with two amazing command line utilities which you can use to run any application and connect to it any time you want. They are called run_erl and to_erl:
run_erl ./my_app /dir/for/logging iex -S mix The command above will execute iex -S mix and give it a name of my_app and will log any entries to “/dir/for/logging”. Make sure the logging directory exists otherwise run_erl may fail silently.
Now you can connect to the iex terminal of that node at any time by doing this:
to_erl ./my_app This means that, if you use run_erl to start Elixir with IEx inside Docker, you can connect to IEx and issue :init.stop/0 for proper node shutdown. :init.stop/0 will go application by application and shutdown their supervision tree respecting the configured timeouts. You can automate it by running:
| # Day List | |
| ## Module | |
| ```elixir | |
| defmodule DayList do | |
| @days [:sun, :mon, :tues, :wed, :thurs, :fri, :sat] | |
| @spec build_list(first :: atom(), last :: atom()) :: list() | {:error, :invalid_day} | |
| def build_list(first, last) when first in @days and last in @days do |
| export ERL_AFLAGS="-kernel shell_history enabled" | |
| export KERL_BUILD_DOCS="yes" | |
| export KERL_DOC_TARGETS=chunks | |
| export KERL_BUILD_DOCS=yes | |
| export WX_CONFIG="/usr/local/bin/wx-config" | |
| export KERL_CONFIGURE_OPTIONS="--with-wx-config=$WX_CONFIG" |
| with {:ok, list} <- :application.get_key(:my_app, :modules) do | |
| list | |
| |> Enum.filter(& &1 |> Module.split |> Enum.take(1) == ~w|UserHelpers|) | |
| |> Enum.reduce(user_data, fn m, acc -> apply(m, :create, acc) end) | |
| end |
| @doc """ | |
| Stream chunks of results from the given queryable. | |
| Unlike Repo.stream, this function does not keep a long running transaction open. | |
| Hence, consistency is not guarenteed in the presence of rows being deleted or sort criteria changing. | |
| ## Example | |
| Ecto.Query.from(u in Users, order_by: [asc: :created_at]) | |
| |> Repo.chunk(100) |
| defmodule MissingFunction do | |
| def unquote(:"$handle_undefined_function")(func, args), do: [func, args] | |
| end | |
| # iex(3)> MissingFunction.asdf(1,2,3) | |
| # [:asdf, [1, 2, 3]] |