neural_lam/utils.py has grown past 800 lines and mixes unrelated concerns graph loading/zero-indexing, MLP construction, plotting/LaTeX detection, training-logger setup, tensor math, and time conversion. New work (e.g. the latent encoder/decoder infra) adds more graph helpers and has had to introduce a TYPE_CHECKING, guarded BaseDatastore import to dodge a circular import.
Proposal
Turn utils.py into a utils/ package, mirroring the models/ layout, with one module per concern:
buffer_list.py : BufferList
graph.py : load_graph, zero_index_*
networks.py : make_mlp
plot.py : has_working_latex, fractional_plot_bundle
logging.py : setup_training_logger, init_training_logger_metrics, log_on_rank_zero
tensor.py : inverse_softplus, inverse_sigmoid
time.py : get_integer_time
utils/__init__.py re-exports the full public API so existing imports (from neural_lam import utils, from neural_lam.utils import load_graph, …) keep working unchanged. This should also let graph-related helpers sit next to BaseDatastoreaware code and remove the TYPE_CHECKING workaround.
Notes
neural_lam/utils.pyhas grown past 800 lines and mixes unrelated concerns graph loading/zero-indexing, MLP construction, plotting/LaTeX detection, training-logger setup, tensor math, and time conversion. New work (e.g. the latent encoder/decoder infra) adds more graph helpers and has had to introduce aTYPE_CHECKING, guardedBaseDatastoreimport to dodge a circular import.Proposal
Turn
utils.pyinto autils/package, mirroring themodels/layout, with one module per concern:buffer_list.py:BufferListgraph.py:load_graph,zero_index_*networks.py:make_mlpplot.py:has_working_latex,fractional_plot_bundlelogging.py:setup_training_logger,init_training_logger_metrics,log_on_rank_zerotensor.py:inverse_softplus,inverse_sigmoidtime.py:get_integer_timeutils/__init__.pyre-exports the full public API so existing imports (from neural_lam import utils,from neural_lam.utils import load_graph, …) keep working unchanged. This should also let graph-related helpers sit next toBaseDatastoreaware code and remove theTYPE_CHECKINGworkaround.Notes