mirror of
https://github.com/ANL-CEEESA/MIPLearn.git
synced 2025-12-06 01:18:52 -06:00
BasicCollector: Do not crash on exception
This commit is contained in:
@@ -9,6 +9,7 @@ import sys
|
|||||||
from io import StringIO
|
from io import StringIO
|
||||||
from os.path import exists
|
from os.path import exists
|
||||||
from typing import Callable, List, Any
|
from typing import Callable, List, Any
|
||||||
|
import traceback
|
||||||
|
|
||||||
from ..h5 import H5File
|
from ..h5 import H5File
|
||||||
from ..io import _RedirectOutput, gzip, _to_h5_filename
|
from ..io import _RedirectOutput, gzip, _to_h5_filename
|
||||||
@@ -29,6 +30,7 @@ class BasicCollector:
|
|||||||
verbose: bool = False,
|
verbose: bool = False,
|
||||||
) -> None:
|
) -> None:
|
||||||
def _collect(data_filename: str) -> None:
|
def _collect(data_filename: str) -> None:
|
||||||
|
try:
|
||||||
h5_filename = _to_h5_filename(data_filename)
|
h5_filename = _to_h5_filename(data_filename)
|
||||||
mps_filename = h5_filename.replace(".h5", ".mps")
|
mps_filename = h5_filename.replace(".h5", ".mps")
|
||||||
|
|
||||||
@@ -75,6 +77,10 @@ class BasicCollector:
|
|||||||
gzip(mps_filename)
|
gzip(mps_filename)
|
||||||
|
|
||||||
h5.put_scalar("mip_log", streams[0].getvalue())
|
h5.put_scalar("mip_log", streams[0].getvalue())
|
||||||
|
except:
|
||||||
|
print(f"Error processing: data_filename")
|
||||||
|
traceback.print_exc()
|
||||||
|
|
||||||
|
|
||||||
if n_jobs > 1:
|
if n_jobs > 1:
|
||||||
p_umap(
|
p_umap(
|
||||||
|
|||||||
@@ -87,7 +87,10 @@ def read_pkl_gz(filename: str) -> Any:
|
|||||||
def _to_h5_filename(data_filename: str) -> str:
|
def _to_h5_filename(data_filename: str) -> str:
|
||||||
output = f"{data_filename}.h5"
|
output = f"{data_filename}.h5"
|
||||||
output = output.replace(".gz.h5", ".h5")
|
output = output.replace(".gz.h5", ".h5")
|
||||||
output = output.replace(".json.h5", ".h5")
|
output = output.replace(".csv.h5", ".h5")
|
||||||
output = output.replace(".pkl.h5", ".h5")
|
|
||||||
output = output.replace(".jld2.h5", ".h5")
|
output = output.replace(".jld2.h5", ".h5")
|
||||||
|
output = output.replace(".json.h5", ".h5")
|
||||||
|
output = output.replace(".lp.h5", ".h5")
|
||||||
|
output = output.replace(".mps.h5", ".h5")
|
||||||
|
output = output.replace(".pkl.h5", ".h5")
|
||||||
return output
|
return output
|
||||||
|
|||||||
Reference in New Issue
Block a user