From fdadba52b823f21ae8ed4c2d3880ff24213cc807 Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Thu, 30 Apr 2026 12:19:16 -0500 Subject: [PATCH] fix(prod-build): silence Nx.* undefined warnings in dev/test-only modules MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Recalibrator and FrontalAnalysis use Nx for tensor math, but Nx is declared `only: [:dev, :test]` in mix.exs because neither module has a prod entry point — Recalibrator is invoked by hand from IEx and FrontalAnalysis is research scaffolding. The prod compile would emit "Nx.to_number/1 is undefined" warnings on every Nx call. Add a `@compile {:no_warn_undefined, Nx}` directive to both modules so the prod build is clean without dragging Nx/Axon/EXLA (~hundreds of MB) into the runtime image. --- lib/microwaveprop/propagation/recalibrator.ex | 7 +++++++ lib/microwaveprop/weather/frontal_analysis.ex | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/lib/microwaveprop/propagation/recalibrator.ex b/lib/microwaveprop/propagation/recalibrator.ex index c7705892..f082516c 100644 --- a/lib/microwaveprop/propagation/recalibrator.ex +++ b/lib/microwaveprop/propagation/recalibrator.ex @@ -29,6 +29,13 @@ defmodule Microwaveprop.Propagation.Recalibrator do require Logger + # Nx is `only: [:dev, :test]` in mix.exs because the recalibrator is a + # research / weight-fitting tool that never runs in prod (no scheduled + # job, no cron, no LiveView entry point). Silence the prod-compile + # warnings about Nx.* being undefined — this module wouldn't be called + # without a developer explicitly invoking it. + @compile {:no_warn_undefined, Nx} + @factor_keys ~w(humidity time_of_day td_depression refractivity sky season wind rain pwat pressure)a @doc """ diff --git a/lib/microwaveprop/weather/frontal_analysis.ex b/lib/microwaveprop/weather/frontal_analysis.ex index 94f08526..00f9b3b4 100644 --- a/lib/microwaveprop/weather/frontal_analysis.ex +++ b/lib/microwaveprop/weather/frontal_analysis.ex @@ -21,6 +21,11 @@ defmodule Microwaveprop.Weather.FrontalAnalysis do All grid math uses Nx for vectorized 2D operations. """ + # Nx is `only: [:dev, :test]` in mix.exs. This module is a research + # tool — no prod code path invokes it — so silence the prod-compile + # warnings about Nx.* being undefined. + @compile {:no_warn_undefined, Nx} + @doc """ Detect fronts from a 2D grid of surface temperature and pressure.