Skip to content

Conversation

Copy link

Copilot AI commented Feb 8, 2026

Multiple modules import optional dependencies (torch, numpy, pandas, datasets, tqdm, rouge, tree_sitter) at module level, causing ImportError when those packages aren't installed.

Changes

  • camel/models/reward/skywork_model.py — Add @dependencies_required('torch', 'transformers') on __init__; torch already deferred into methods
  • camel/datasets/static_dataset.pyHFDataset via try/except with None fallback + isinstance guard
  • camel/datasets/base_generator.py — try/except fallback stub for torch.utils.data.IterableDataset
  • camel/benchmarks/ragbench.pyTYPE_CHECKING for Dataset type hints, lazy numpy/datasets in functions, @dependencies_required('datasets') on class init
  • camel/benchmarks/nexus.py@dependencies_required('datasets', 'pandas'), lazy pandas/datasets/tqdm
  • camel/benchmarks/apibank.py — Lazy numpy, rouge, tqdm
  • camel/benchmarks/apibench.py — Lazy tree_sitter_python, tree_sitter, tqdm
  • camel/benchmarks/gaia.py, camel/datagen/evol_instruct/evol_instruct.py, camel/datagen/source2synth/data_processor.py, camel/runtimes/docker_runtime.py — Lazy tqdm
  • camel/datagen/self_instruct/filter/filter_function.py — Lazy rouge
  • camel/personas/persona_hub.py — Lazy numpy

Pattern

Follows existing codebase convention:

from camel.utils import dependencies_required

class RAGBenchBenchmark(BaseBenchmark):
    @dependencies_required('datasets')
    def __init__(self, ...):
        ...

    def download(self):
        from datasets import load_dataset  # lazy
        self.dataset = load_dataset(...)

All 66 subpackages import cleanly without optional deps installed.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Fix module imports and resolve related issues Defer torch imports to fix module-level ImportError when torch is not installed Feb 8, 2026
Copilot AI requested a review from lightaime February 8, 2026 08:08
Copilot AI changed the title Defer torch imports to fix module-level ImportError when torch is not installed Convert module-level optional dependency imports to lazy imports with @dependencies_required Feb 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants