From 1ceb93232173378848a129ca3a8780e6ab38176f Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Tue, 28 Jul 2026 08:19:23 -0500 Subject: [PATCH] fix: use apply/3 to avoid undefined-module warnings with Conditional ML module 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. --- Dockerfile | 2 +- lib/microwaveprop/propagation.ex | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6b209ceb..8e78b0a4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 diff --git a/lib/microwaveprop/propagation.ex b/lib/microwaveprop/propagation.ex index baefc8e4..0ac7d10c 100644 --- a/lib/microwaveprop/propagation.ex +++ b/lib/microwaveprop/propagation.ex @@ -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