@@ -51,15 +51,15 @@ def _get_package_metadata(imp) -> Dict[str, Any]:
5151
5252
5353@contextlib .contextmanager
54- def _suppress_package_importer_warnings ():
54+ def _suppress_package_importer_exporter_warnings ():
5555 # Ideally this ceases to exist or becomes a no-op in future versions of PyTorch
5656 with warnings .catch_warnings ():
5757 # suppress torch.package TypedStorage warning
5858 warnings .filterwarnings (
5959 "ignore" ,
6060 message = "TypedStorage is deprecated.*" ,
6161 category = UserWarning ,
62- module = "torch.package. package_importer" ,
62+ module = r "torch\ .package\.(package_exporter| package_importer) " ,
6363 )
6464 yield
6565
@@ -104,7 +104,7 @@ def ModelFromPackage(package_path: str, compile_mode: str = _EAGER_MODEL_KEY):
104104
105105 # === load model ===
106106 logger .info (f"Loading model from package file: { package_path } ..." )
107- with _suppress_package_importer_warnings ():
107+ with _suppress_package_importer_exporter_warnings ():
108108 # during `nequip-package`, we need to use the same importer for all the models for successful repackaging
109109 # see https://pytorch.org/docs/stable/package.html#re-export-an-imported-object
110110 if workflow_state == "package" :
@@ -141,7 +141,7 @@ def ModelFromPackage(package_path: str, compile_mode: str = _EAGER_MODEL_KEY):
141141
142142def data_dict_from_package (package_path : str ) -> AtomicDataDict .Type :
143143 """Load example data from a .nequip.zip package file."""
144- with _suppress_package_importer_warnings ():
144+ with _suppress_package_importer_exporter_warnings ():
145145 imp = torch .package .PackageImporter (package_path )
146146 data = imp .load_pickle (package = "model" , resource = "example_data.pkl" )
147147 return data
@@ -159,7 +159,7 @@ def ModelTypeNamesFromPackage(package_path: str):
159159
160160 _check_file_exists (file_path = package_path , file_type = "package" )
161161
162- with _suppress_package_importer_warnings ():
162+ with _suppress_package_importer_exporter_warnings ():
163163 imp = torch .package .PackageImporter (package_path )
164164 pkg_metadata = _get_package_metadata (imp )
165165
0 commit comments