From b40c835afa9ad7c63123af265e66719846b5b0a6 Mon Sep 17 00:00:00 2001 From: Jammy2211 Date: Thu, 14 May 2026 20:47:36 +0100 Subject: [PATCH] Disable model.graph output by default; gate via output.yaml Adds a `model_graph` flag in autofit/config/output.yaml (default `false`) and gates the `_save_model_info` write in directory.py with `should_output("model_graph") and hasattr(model, "graph_info")`. The previous `try/except AttributeError` block opened the file before accessing `model.graph_info`, so an empty `model.graph` was created for every non-graphical-model fit. The new gate avoids the empty file and lets users opt in via the config flag. The `metadata` file in the output folder is intentionally unchanged: it is the sentinel Aggregator.from_directory() uses to detect search output directories, and SearchOutput parses its key=value lines into attributes. --- autofit/config/output.yaml | 4 +++- autofit/non_linear/paths/directory.py | 6 ++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/autofit/config/output.yaml b/autofit/config/output.yaml index d36a9e1f3..52c885954 100644 --- a/autofit/config/output.yaml +++ b/autofit/config/output.yaml @@ -99,4 +99,6 @@ covariance: true # `covariance.csv`: The [free parameters x free parameters] cov data: true # `data.json`: The value of every data point in the data. noise_map: true # `noise_map.json`: The value of every RMS noise map value. -search_log: true # `search.log`: logging produced whilst running the fit method \ No newline at end of file +search_log: true # `search.log`: logging produced whilst running the fit method + +model_graph: false # `model.graph`: graphical-model factor graph summary. Only meaningful for graphical models (autofit.graphical); empty for ordinary PriorModel/Collection fits, so disabled by default. \ No newline at end of file diff --git a/autofit/non_linear/paths/directory.py b/autofit/non_linear/paths/directory.py index d00edb5ad..db2c6d6ae 100644 --- a/autofit/non_linear/paths/directory.py +++ b/autofit/non_linear/paths/directory.py @@ -470,11 +470,9 @@ def _save_model_info(self, model): with open_(self.output_path / "model.info", "w+") as f: f.write(model.info) - try: + if should_output("model_graph") and hasattr(model, "graph_info"): with open_(self.output_path / "model.graph", "w+") as f: - f.write( model.graph_info) - except AttributeError: - pass + f.write(model.graph_info) def _save_model_start_point(self, info): """