@@ -37,13 +37,14 @@ def _check_non_zero(std):
3737 return std
3838
3939
40- def get_mace_mp_model_path (model : Optional [str ] = None ) -> str :
40+ def get_mace_mp_model_path (model : Optional [str ] = None , supress_print = True ) -> str :
4141 """Get the default MACE MP model. Replicated from the MACE codebase,
4242 Copyright (c) 2022 ACEsuit/mace and licensed under the MIT license.
4343
4444 Args:
4545 model (str, optional): MACE_MP model that you want to get.
4646 Defaults to None. Can be "small", "medium", "large", or a URL.
47+ supress_print (bool, optional): Whether to suppress print statements. Defaults to True.
4748
4849 Raises:
4950 RuntimeError: raised if the model download fails and no local model is found
@@ -53,7 +54,8 @@ def get_mace_mp_model_path(model: Optional[str] = None) -> str:
5354 """
5455 if model in (None , "medium" ) and os .path .isfile (LOCAL_MODEL_PATH ):
5556 model_path = LOCAL_MODEL_PATH
56- print (f"Using local medium Materials Project MACE model for MACECalculator { model } " )
57+ if not supress_print :
58+ print (f"Using local medium Materials Project MACE model for MACECalculator { model } " )
5759 elif model in (None , "small" , "medium" , "large" ) or str (model ).startswith ("https:" ):
5860 try :
5961 checkpoint_url = (
@@ -65,11 +67,13 @@ def get_mace_mp_model_path(model: Optional[str] = None) -> str:
6567 if not os .path .isfile (model_path ):
6668 os .makedirs (cache_dir , exist_ok = True )
6769 # download and save to disk
68- print (f"Downloading MACE model from { checkpoint_url !r} " )
6970 urllib .request .urlretrieve (checkpoint_url , model_path )
70- print (f"Cached MACE model to { model_path } " )
71- msg = f"Loading Materials Project MACE with { model_path } "
72- print (msg )
71+ if not supress_print :
72+ print (f"Downloading MACE model from { checkpoint_url !r} " )
73+ print (f"Cached MACE model to { model_path } " )
74+ if not supress_print :
75+ msg = f"Loading Materials Project MACE with { model_path } "
76+ print (msg )
7377 except Exception as exc :
7478 raise RuntimeError ("Model download failed and no local model found" ) from exc
7579 else :
0 commit comments