@@ -117,9 +117,9 @@ def _run_clustering(
117117
118118 if run is not None :
119119 _log_merge_history_plots_to_wandb (run , history )
120- # _save_merge_history_to_wandb(
121- # run, history_save_path, batch_id, config.config_identifier, history
122- # )
120+ _save_merge_history_to_wandb (
121+ run , history_save_path , batch_id , config .config_identifier , history
122+ )
123123
124124 run .finish ()
125125
@@ -155,12 +155,30 @@ def _setup_wandb(
155155
156156def _log_merge_history_plots_to_wandb (run : Run , history : MergeHistory ):
157157 fig_cs = plot_merge_history_cluster_sizes (history = history )
158-
159158 run .log (
160- {
161- "plots/merge_history_cluster_sizes" : wandb .Image (fig_cs ),
162- },
159+ {"plots/merge_history_cluster_sizes" : wandb .Image (fig_cs )},
163160 step = history .n_iters_current ,
164161 )
165-
166162 plt .close (fig_cs )
163+
164+
165+ def _save_merge_history_to_wandb (
166+ run : Run ,
167+ history_path : Path ,
168+ batch_id : str ,
169+ config_identifier : str ,
170+ history : MergeHistory ,
171+ ):
172+ artifact = wandb .Artifact (
173+ name = f"merge_history_{ batch_id } " ,
174+ type = "merge_history" ,
175+ description = f"Merge history for batch { batch_id } " ,
176+ metadata = {
177+ "batch_name" : batch_id ,
178+ "config_identifier" : config_identifier ,
179+ "n_iters_current" : history .n_iters_current ,
180+ "filename" : history_path ,
181+ },
182+ )
183+ artifact .add_file (str (history_path ))
184+ run .log_artifact (artifact )
0 commit comments