prop/lib/microwaveprop/application.ex
Graham McIntire 2c16fd979d
Move ML deps to dev/test only, exclude from production build
- Nx, Axon, EXLA, Polaris deps restricted to only: [:dev, :test]
- model.ex and training mix tasks moved to lib_ml/ (compiled via
  elixirc_paths in dev/test only)
- load_ml_model uses Code.ensure_loaded? + apply/3 to avoid
  compile-time references to ML modules in production
- Verified: MIX_ENV=prod compiles clean with no ML warnings
2026-04-01 12:10:31 -05:00

47 lines
1.4 KiB
Elixir

defmodule Microwaveprop.Application do
# See https://hexdocs.pm/elixir/Application.html
# for more information on OTP Applications
@moduledoc false
use Application
@impl true
def start(_type, _args) do
migrate()
children = [
MicrowavepropWeb.Telemetry,
Microwaveprop.Repo,
{DNSCluster, query: Application.get_env(:microwaveprop, :dns_cluster_query) || :ignore},
{Phoenix.PubSub, name: Microwaveprop.PubSub},
{Oban, Application.fetch_env!(:microwaveprop, Oban)},
# Start to serve requests, typically the last entry
MicrowavepropWeb.Endpoint,
Microwaveprop.Propagation.FreshnessMonitor
]
# See https://hexdocs.pm/elixir/Supervisor.html
# for other strategies and supported options
opts = [strategy: :one_for_one, name: Microwaveprop.Supervisor]
result = Supervisor.start_link(children, opts)
# Load ML model in dev/test only (Nx/Axon not compiled for prod)
if Application.get_env(:microwaveprop, :load_ml_model, false) do
Microwaveprop.Propagation.load_ml_model()
end
result
end
# Tell Phoenix to update the endpoint configuration
# whenever the application is updated.
defp migrate do
Microwaveprop.Release.migrate()
end
@impl true
def config_change(changed, _new, removed) do
MicrowavepropWeb.Endpoint.config_change(changed, removed)
:ok
end
end