Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: cannot import text_unidecode, nemo-toolkit #2068

Merged
merged 1 commit into from
Aug 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading