tensorflow / tensorflow/datasets
[GSoC] Better lazy_imports usability
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 4.6k
- Forks
- 1.6k
- Avg merge
- 3h 54m
- Merged PRs (30d)
- 1
Description
Part1: Currently, lazy imports feels counter intuitive and confusing. It would be nice to improve the API to allow something like:
with tfds.core.lazy_imports():
import some_module
It would patch the default module import:
- If the module is installed (e.g. tested with
try/except ImportError): Import the module as standard - If the import isn't installed: Replace the module by a dummy ModuleType which raise error when access attribute (use
__getattr__):
with tfds.core.lazy_imports():
import some_module
some_module.some_function() # Raise the lazy import error (please install some_module)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the tfds.core.lazy_imports API and its existing import-handling tests or entry points. Compare the requested context-manager behavior with the current implementation, including installed-module imports and the dummy ModuleType path. Done means missing modules raise the requested lazy-import error only when an attribute is accessed, while installed modules behave like standard imports.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- developer-experience
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100