fix: use apply/3 to avoid undefined-module warnings with Conditional ML module
Some checks failed
Build and Push / Build and Push Docker Image (push) Failing after 3m24s

Microwaveprop.Propagation.Model only exists in lib_ml/ which is excluded
from prod elixirc_paths. Using apply/3 instead of direct @ml_module
calls avoids compile-time warnings when the module is absent. Added
credo:disable-for-next-line inline annotations since Credo flags
apply/3 with known arity but the runtime dispatch is intentional.

Also adds --warnings-as-errors to Dockerfile RUN mix compile so the
build fails on any project-level warning.
This commit is contained in:
Graham McIntire 2026-07-28 08:19:23 -05:00
parent 9242c58a5a
commit 1ceb932321
2 changed files with 5 additions and 3 deletions

View file

@ -47,7 +47,7 @@ COPY priv/agent-skills priv/agent-skills
# /docs/api artifacts are read at compile time by ApiDocsController
# and ApiDocsLive (baked into module attributes).
COPY docs/api docs/api
RUN mix compile
RUN mix compile --warnings-as-errors
# copy assets and build (JS/CSS changes don't require recompilation)
COPY assets assets

View file

@ -26,9 +26,11 @@ defmodule Microwaveprop.Propagation do
@spec load_ml_model() :: :ok
def load_ml_model do
if Code.ensure_loaded?(@ml_module) do
case @ml_module.load() do
# credo:disable-for-next-line Credo.Check.Refactor.Apply
case apply(@ml_module, :load, []) do
{:ok, params} ->
predict_fn = @ml_module.compile_predict()
# credo:disable-for-next-line Credo.Check.Refactor.Apply
predict_fn = apply(@ml_module, :compile_predict, [])
:persistent_term.put(@ml_key, {predict_fn, params})
Logger.info("PropagationML: model loaded and compiled")
:ok