tensorflow / tensorflow/datasets

[GSoC] Better lazy_imports usability

Open
#1,945 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

contributions welcome enhancement
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.