From fe991497a7f991ba72e17c927e9f0d189174c851 Mon Sep 17 00:00:00 2001 From: siege Date: Tue, 7 Jan 2025 12:16:02 -0800 Subject: [PATCH] Support loaders which don't set the filename on the ModuleSpec. PiperOrigin-RevId: 712999091 --- spinoffs/fun_mc/fun_mc/backends/rewrite.py | 5 ++++- spinoffs/inference_gym/inference_gym/backends/rewrite.py | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/spinoffs/fun_mc/fun_mc/backends/rewrite.py b/spinoffs/fun_mc/fun_mc/backends/rewrite.py index 1198c7c38e..ca9e883f54 100644 --- a/spinoffs/fun_mc/fun_mc/backends/rewrite.py +++ b/spinoffs/fun_mc/fun_mc/backends/rewrite.py @@ -83,7 +83,10 @@ def __init__(self, orig_module_name, orig_loader, orig_filename, def get_filename(self, fullname): del fullname - return self._orig_filename + try: + return self._orig_loader.get_filename(self._orig_module_name) + except: # pylint: disable=bare-except + return self._orig_filename def get_data(self, path): if DEBUG: diff --git a/spinoffs/inference_gym/inference_gym/backends/rewrite.py b/spinoffs/inference_gym/inference_gym/backends/rewrite.py index 96853f852c..4af88ccc01 100644 --- a/spinoffs/inference_gym/inference_gym/backends/rewrite.py +++ b/spinoffs/inference_gym/inference_gym/backends/rewrite.py @@ -137,7 +137,10 @@ def __init__(self, orig_module_name, orig_loader, orig_filename, def get_filename(self, fullname): del fullname - return self._orig_filename + try: + return self._orig_loader.get_filename(self._orig_module_name) + except: # pylint: disable=bare-except + return self._orig_filename def get_data(self, path): if DEBUG: