Reduce startup cost by loading heavy AI/ML libraries only when a code path actually uses them.
Odipie is a lightweight Python toolkit and project template for lazy-loading optional AI/ML dependencies. The base install stays small. Frameworks such as TensorFlow, PyTorch, scikit-learn, Transformers, Pandas, NumPy, Matplotlib, and OpenCV can be installed as optional extras.
- Lazy proxy objects for common AI/ML libraries.
- Optional dependency extras instead of one oversized required install.
- Compatibility shim for older examples that use
import lazy_init_py as odipie. - Small CLI and smoke-check app for verifying the package install.
- Docker and Compose workflow that builds from the real repository tree.
- Wiki source files under
docs/wiki-src/for longer engineering notes.
odipie/
βββ odipie/
β βββ __init__.py
β βββ __main__.py
βββ ROProj/
β βββ README.md
β βββ app.py
β βββ config.py
β βββ docker-compose.yml
β βββ requirements.txt
βββ docker/
β βββ Dockerfile
β βββ .dockerignore
β βββ entrypoint.sh
β βββ README.md
βββ docs/
β βββ wiki-src/
βββ tests/
β βββ test_imports.py
βββ .dockerignore
βββ app.py
βββ config.py
βββ docker-compose.yml
βββ lazy_init_py.py
βββ pyproject.toml
βββ requirements.txt
βββ README.md
Create and activate a virtual environment, then install the package in editable mode:
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -e .Install optional stacks only when you need them:
pip install -e .[data]
pip install -e .[tensorflow]
pip install -e .[torch]
pip install -e .[ml]import odipie
print("App ready")
print(odipie.get_loaded_modules())
# TensorFlow imports only when this attribute chain is used.
model = odipie.tensorflow.keras.Sequential([...])
# scikit-learn imports only when this code path runs.
processed = odipie.preprocess_data(data, method="standard")Older examples still work:
import lazy_init_py as odipiepython -m odipie --loaded
python -m odipie --versions
python app.pypip install -e .[dev]
pytestdocker compose build
docker compose upSee docker-setup.md for the Docker walkthrough.
| Resource | Description | Link |
|---|---|---|
| Wiki Home | Complete knowledge base | Wiki |
| Getting Started | Install, optional extras, Docker, and troubleshooting | docs/wiki-src/Getting-Started.md |
| Docker Guide | Build and run the package in Docker | docker-setup.md |
| AI Terminology & FAQ | Plain-language AI and agentic-system reference | docs/wiki-src/AI-Terminology-and-FAQ.md |
| Agents, MCP & Orchestration | Agents, graph workflows, MCP, and WebMCP | docs/wiki-src/Agents-MCP-and-Orchestration.md |
| Prompt Engineering | Prompt ideation and context engineering | adv_promptGuide.md |
| Wiki Sources | Source markdown for wiki pages | docs/wiki-src |
Do not use wildcard imports in project code. For PyTorch model files, only load artifacts from trusted sources; Odipie uses safer torch.load(..., weights_only=True) defaults when supported by the installed PyTorch version.
This project is licensed under the Apache License 2.0.