Skip to content

Commit

Permalink
fix: cannot import text_unidecode, nemo-toolkit (#2068)
Browse files Browse the repository at this point in the history
  • Loading branch information
thundergolfer committed Aug 2, 2024
1 parent f970422 commit 497c8e6
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions modal/_telemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,28 @@ def create_module(self, spec):
spec.loader = self
return module

def get_data(self, path: str) -> bytes:
"""
Implementation is required to support pkgutil.get_data.
> If the package cannot be located or loaded, or it uses a loader which does
> not support get_data, then None is returned.
ref: https://docs.python.org/3/library/pkgutil.html#pkgutil.get_data
"""
return self.loader.get_data(path)

def get_resource_reader(self, fullname: str):
"""
Support reading a binary artifact that is shipped within a package.
> Loaders that wish to support resource reading are expected to provide a method called
> get_resource_reader(fullname) which returns an object implementing this ABC’s interface.
ref: docs.python.org/3.10/library/importlib.html?highlight=traversableresources#importlib.abc.ResourceReader
"""
return self.loader.get_resource_reader(fullname)


class ImportInterceptor(importlib.abc.MetaPathFinder):
loading: typing.Dict[str, typing.Tuple[str, float]]
Expand Down

0 comments on commit 497c8e6

Please sign in to comment.